Skip to Content
Custom Search

SORT JCL to SUM up values

 

SORT JCL to SUM up values
 
 
 
If you wish to sum up the values at a particular position sorted at some value then you can use the following sort card
 
 
The following card will sum values (lets assume salaries) appearing at pos 7th (4 bytes) grouped/sorted on data (emp numbers)
at 37th position of 10bytes.
 
SORT FIELDS=(37,10,CH,A),STOPAFT=10
SUM FIELDS=(7,4,ZD)                
 
 
Example JCL is provided below.
; ; ; ;
 
//SETP001  EXEC PGM=SORT                                         
//SYSPRINT DD SYSOUT=*                                           
//SYSOUT   DD SYSOUT=*                                           
//SYSUDUMP DD SYSOUT=*                                           
//REPORT1  DD SYSOUT=*                                           
//SORTIN   DD DISP=SHR,DSN=USERID.ABC.INPFILE,
//SORTOUT  DD DSN=USERID.ABC.OUTFILE,
//      DISP=(,CATLG),                                           
//      SPACE=(TRK,(30,10),RLSE),                                
//      UNIT=SYSDA,                                              
//      DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)               
//SORTWK01 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)                 
//SORTWK02 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)     
//SORTWK03 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)     
//SYSIN    DD *                                      
SORT FIELDS=(37,10,CH,A),STOPAFT=10
SUM FIELDS=(7,4,ZD)                
/*                                                   
//*  

Comments

its working when changeD the

its working when changeD the 'STOPAFT=10'
to 'FORMAT=CH'

IT WONT WORKING

The above syntax is not executing. After the execution the fields wont be sum only sorting fields has displayed.

It doesnt work

It doesnt work

Click the +1 button  below to share it with your friends and colleagues

 

Share this if you liked it!

 

Disclaimer



Who's online

There are currently 0 users and 74 guests online.
Dr. Radut | page