DFSORT Sort Fields

DFSORT End DFSORT Merge Fields

Advertisements


DFSORT can be used to sort the datasets

Sorting can be done based on the specific position of the dataset

Sorting can be don based on the multiple positions from dataset. But the sorting priority is first to last.

The sorting orders can be either Ascending or descending.

Syntax:

SORT FIELDS=(starting position, length, data format, A/D)
Name Description
starting positionStarting position of field1 to be compared
Length Length of the field to be compared
data formatFormat of the field1 like CH, PD, BI etc,.
A/D Specifies the order

Example:


Input:- MTHUSR1.SORTDATA.INPUT

-------------------------------------------------------------------------------
 BROWSE    MTHUSR1.SORTDATA.INPUT                     Line 00000000 Col 001 080 
 Command ===>                                                  Scroll ===> CSR  
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001    PAWAN     KUMAR     Y         0000010000                               
00004    SRINIVASA RAO       C         0000020000                               
00003    SRIDHAR   R         G         0000030000                               
00002    KAMAL     K         S         0000040000                               
00006    RAJESH    KUMAR     Y         0000050000                               
00005    VENKAT    R         Y         0000060000                               
00004    GURU      R         N         0000010000                               
******************************** Bottom of Data ********************************

Job:

 =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ****** ***************************** Top of Data ******************************
 000001 //jobcard                                            
 000003 //STEP10  EXEC PGM=SORT                                                 
 000004 //SYSOUT    DD SYSOUT=*                                                 
 000005 //SORTIN    DD DSN=MTHUSR1.SORTDATA.INPUT,DISP=SHR                      
 000006 //SORTOUT   DD DSN=MTHUSR1.MULTISRT.OUTPUT,                             
 000007 //            DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,                       
 000008 //            SPACE=(CYL,(1,4),RLSE),                                   
 000009 //            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)                         
 000010 //SYSIN     DD *                                                        
 000011    SORT FIELDS=(1,5,CH,A,40,10,CH,A)                                    
 000012 /*                                                                      
 ****** **************************** Bottom of Data ****************************

Output:

-------------------------------------------------------------------------------
 BROWSE    MTHUSR1.MULTISRT.OUTPUT                    Line 00000000 Col 001 080 
 Command ===>                                                  Scroll ===> CSR  
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001    PAWAN     KUMAR     Y         0000010000                               
00002    KAMAL     K         S         0000040000                               
00003    SRIDHAR   R         G         0000030000                               
00004    GURU      R         N         0000010000                               
00004    SRINIVASA RAO       C         0000020000                               
00005    VENKAT    R         Y         0000060000                               
00006    RAJESH    KUMAR     Y         0000050000                               
******************************** Bottom of Data ********************************

DFSORT End DFSORT Merge Fields

Advertisements