Mainframe Path Start learning free
BeginnerJcl

Sort, filter and reformat in one step

DFSORT control cards doing what would otherwise be a program.

SORTJOB
//SORTJOB  JOB (ACCT01),'EXTRACT',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=PROD.PAY.TRANS,DISP=SHR
//SORTOUT  DD DSN=DEV.PAY.EXTRACT,DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(20,10),RLSE)
//SYSIN    DD *
  SORT    FIELDS=(1,10,CH,A,25,8,CH,D)
  INCLUDE COND=(45,1,CH,EQ,C'Y',AND,
                (60,5,PD,GT,+0))
  OUTREC  FIELDS=(1,10,25,8,60,5,80,30)
  SUM     FIELDS=NONE
/*
CardDoes
SORT FIELDSSort keys: start, length, format, A or D
INCLUDE / OMIT CONDKeep or drop records matching a condition
OUTREC FIELDSRebuild each output record from chosen fields
SUM FIELDS=NONERemove duplicates on the sort key
SUM FIELDS=(60,5,PD)Total a field, one output record per key
OPTION COPYCopy without sorting — for filtering only

Common formats: CH character, ZD zoned decimal, PD packed decimal, BI binary.

Stuck on something else?
Ask the community or search the full course.

Ask a question