DFSORT in JCL - Interview Questions and Answers
1. What is DFSORT in JCL?
DFSORT is a utility program in IBM mainframe used to sort, merge, copy, and filter data in datasets.
2. Commonly used DFSORT keywords?
- SORT FIELDS=
- INCLUDE COND=
- OMIT COND=
- SUM FIELDS=
- OUTREC / INREC / OUTFIL
3. Difference between INREC, OUTREC, and OUTFIL?
- INREC: Reformats input before sorting/copying
- OUTREC: Reformats output after sorting/copying
- OUTFIL: Used for writing to multiple output files
4. Remove duplicate records?
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=NONE
/*
5. Sort records in descending order?
SORT FIELDS=(1,10,CH,D)
6. Sum numeric values?
SORT FIELDS=(1,5,CH,A)
SUM FIELDS=(10,4,ZD)
DFSORT in JCL - Interview Questions and Answers
7. Filter records using INCLUDE or OMIT?
INCLUDE COND=(10,2,CH,EQ,C'AB')
8. Use of OPTION COPY?
Used to copy records without sorting
9. Add sequence numbers?
SORT FIELDS=COPY
OUTREC FIELDS=(1,80,SEQNUM,8,ZD)
10. Change the value in a particular position?
OUTREC FIELDS=(1,4,C'NEW',8,72)
11. Split file into two outputs?
OUTFIL FILES=01,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FILES=02,SAVE
12. Sort a VB file?
SORT FIELDS=(5,10,CH,A)
13. Convert VB to FB?
INREC BUILD=(5,80)
14. Convert FB to VB?
OUTREC BUILD=(RDW,1,80)
15. Select every nth record?
INREC IFTHEN=(WHEN=(5,1,ZD,MOD,5,EQ,0))
DFSORT in JCL - Interview Questions and Answers
16. Mask PAN or account number?
OUTREC FIELDS=(1,4,C'XXXX',9,72)
17. Count number of records?
OPTION COPY
OUTFIL REMOVECC, TRAILER1=(COUNT=(M11,LENGTH=8))
18. Eliminate header/trailer records?
OMIT COND=(1,5,CH,EQ,C'HDR01')
19. Extract records for date range?
INCLUDE COND=(20,10,CH,GE,C'20220101',AND,20,10,CH,LE,C'20221231')
20. Pad or truncate fields?
OUTREC BUILD=(1,10,80:X) <-- Pad
OUTREC BUILD=(1,50) <-- Truncate