BeginnerJcl
Sort, filter and reformat in one step
DFSORT control cards doing what would otherwise be a program.
//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 /*
| Card | Does |
|---|---|
| SORT FIELDS | Sort keys: start, length, format, A or D |
| INCLUDE / OMIT COND | Keep or drop records matching a condition |
| OUTREC FIELDS | Rebuild each output record from chosen fields |
| SUM FIELDS=NONE | Remove duplicates on the sort key |
| SUM FIELDS=(60,5,PD) | Total a field, one output record per key |
| OPTION COPY | Copy 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.