DFSORT Merge Fields

DFSORT Sort Fields DFSORT Including/Omitting Records

Advertisements


DFSORT can be used to merge the two or more datasets.

Merging can be done based on the specific common position of the datasets

Merging can also done based on the multiple positions of dataset (i.e. fields). But the priority is from first field to last field.

If multiple positions of sorting specified, the order of priority is from left to right.

The sorting orders can be either Ascending or Sescending.


Syntax:

SORT FIELDS=(starting position, length, data format, A/D)

Name Description
starting positionStarting position of field to be compared
Length Length of the field to be compared
data formatFormat of the field like CH, PD, BI etc,.
A/D Specifies the sorting order

Example:

Inputs:- MTHUSR1.SORTDATA.INPUT01

-------------------------------------------------------------------------------
 BROWSE    MTHUSR1.SORTDATA.INPUT01                   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    SRINIVASA RAO       C         0000020000                               
00005    VENKAT    R         Y         0000060000                               
00006    RAJESH    KUMAR     Y         0000050000                               
******************************** Bottom of Data ********************************

Inputs:- MTHUSR1.SORTDATA.INPUT02

-------------------------------------------------------------------------------
 BROWSE    MTHUSR1.SORTDATA.INPUT02                   Line 00000000 Col 001 080 
 Command ===>                                                  Scroll ===> CSR  
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00007    GURU      R         N         0000070000                               
00008    KUMAR     K         S         0000060000                               
00009    RAO       A         C         0000020000                               
00010    VENU      K         P         0000030000                               
******************************** 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 //SORTIN01  DD DSN=MTHUSR1.SORTDATA.INPUT01,DISP=SHR                    
000006 //SORTIN02  DD DSN=MTHUSR1.SORTDATA.INPUT02,DISP=SHR                    
000007 //SORTOUT   DD DSN=MTHUSR1.MERGE.OUTPUT,                                
000008 //            DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,                       
000009 //            SPACE=(CYL,(1,4),RLSE),                                   
000010 //            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)                         
000011 //SYSIN     DD *                                                        
000012     MERGE FIELDS=(1,5,A,40,10,A),FORMAT=CH                              
000013 /*                                                                      
000014 //                                                                      
****** **************************** Bottom of Data ****************************

Output:

----+----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    SRINIVASA RAO       C         0000020000                               
00005    VENKAT    R         Y         0000060000                               
00006    RAJESH    KUMAR     Y         0000050000                               
00007    GURU      R         N         0000070000                               
00008    KUMAR     K         S         0000060000                               
00009    RAO       A         C         0000020000                               
00010    VENU      K         P         0000030000                               
******************************** Bottom of Data ********************************

Explaning solution:

  1. MERGE FIELDS=(1,5,A,40,10,A),FORMAT=CH is equal to MERGE FIELDS=(1,5,CH,A,40,10,CH,A)

  2. MERGE FIELDS=(1,5,CH,A,...) - Performs merge on the data in 1 to 5 positions to produce the merge result in ascending order.

  3. MERGE FIELDS=(...,40,10,CH,A) - Performs merge on the result of the above step. Merge performed on the data in 40 to 50 positions to produce the result in ascending order.

DFSORT Sort Fields DFSORT Including/Omitting Records

Advertisements