Sort JCL in Descending Order and Format the output

JCL sort is IBM utility used for sorting input data source such as PS, VSAM or SMS files.

In this example I will demonstrate on How to Sort the Sequential Data set in Descending order and in the last, format the record in such a way that we will only get the selected column values in the output file

JCL: This JCL executes SORT program in 2 steps

Step01 - sorts the input file in Descending Order

Step02 - copy the input file in output while in specified Format only.

//* THIS JCL SORTS THE OUTPUT FILE IN DESCENDING ORDER      
//* AND FORMATS THE OUTFILE                                 
//STEP01   EXEC PGM=SORT                                    
//SYSOUT   DD SYSOUT=*                                      
//SORTIN   DD DSN=G101105.CLAIM.EXTRACT1,DISP=SHR           
//SORTOUT  DD DSN=G101105.CLAIM.SORTED,                     
//         DISP=(NEW,CATLG),UNIT=SYSDA,                     
//         SPACE=(CYL,(100,100),RLSE),                      
//         DCB=(LRECL=135,RECFM=FB,BLKSIZE=1350)            
//SYSIN    DD *                                             
   SORT FIELDS=(1,11,CH,D)                                  
/*                                                          
//STEP02   EXEC PGM=SORT                                    
//SYSOUT   DD SYSOUT=*                                      
//SORTIN   DD DSN=G101105.CLAIM.SORTED,DISP=SHR             
//SORTOUT  DD DSN=G101105.CLAIM.HMO,                        
//         DISP=(NEW,CATLG),UNIT=SYSDA,                     
//         SPACE=(CYL,(100,100),RLSE),           
//         DCB=(LRECL=135,RECFM=FB,BLKSIZE=1350) 
//SYSIN    DD *                                  
   SORT FIELDS=COPY                              
    INREC FIELDS=(1:1,11,13:56,80)               
/*       

              
CLAIM.EXTRACT1 (Input File for step 1)
    

//SYSIN DD *
    SORT FIELDS=(1,11,CH,D)
/*

the above control statement specifies the start of the column value, followed by length of the key value on which the sort is to be performed, followed by the type of data 'CH' stands for character values, followed by D for Descending & A for Ascending 

CLAIM.SORTED (output data of Step01)


//SYSIN DD *
    SORT FIELDS=COPY
        INREC FIELDS=(1:1,11,13:56,80)
/*

the above control statement copies the input data with a formatted view in the SYSOUT DD DSN.
the format is as follows.
1:1,11     = copy 1st to 11th bytes of data from input file to 1st column of output file
13:56,80 = copy 56th to 136th bytes of data from input file to 13th column of output file

CLAIM.HMO (Output data of Step02)












Comments

Popular posts from this blog

Dynamic Allocation of PS Dataset Using a COBOL program.

Fixing DB2 data for A Given table using Batch Program.