Good morning!
I have file with header like this '***HEADER***' and trailer is ***TRAILER***. I want to process the file when we have both header and trailer.
1.if only header record present we should not process the file
2.If only trailer record present we should not process the file
if I use below code, it is handling if file has both header and trailer. if file has only header or trailer it Is not working.
Please help me out.
I used the below code :
//STEP1 EXEC PGM=SORT,PARM='NULLOUT=RC4'
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DSN=INPUT.FILE.NAME,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(01,12,CH,EQ,C'***HEADER***',OR,
01,13,CH,EQ,C'***TRAILER***')
END
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DSN=INPUT.FILE.NAME,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(01,12,CH,EQ,C'***HEADER***',OR,
01,13,CH,EQ,C'***TRAILER***')
END
Scenarios like below:
1.it has to process : This working with above code) - return code -RC0
000001 ***HEADER***
000002 0000000000007FT9X
000003 000000000000Y4ZPM
000004 0000000000007GSXB
000005 000000000000YPLCL
000006 000000000000VM5DT
000007 0000000000000000000
000008 000000000000X34T3
000009 ***TRAILER***
000002 0000000000007FT9X
000003 000000000000Y4ZPM
000004 0000000000007GSXB
000005 000000000000YPLCL
000006 000000000000VM5DT
000007 0000000000000000000
000008 000000000000X34T3
000009 ***TRAILER***
2.Below should not process: (This working with above code) - RC4
0000000000007FT9X
000000000000Y4ZPM
0000000000007GSXB
000000000000YPLCL
000000000000VM5DT
0000000000000000000
000000000000X34T3
000000000000Y4ZPM
0000000000007GSXB
000000000000YPLCL
000000000000VM5DT
0000000000000000000
000000000000X34T3
3.Below should not process: (This is not working with above code)
***HEADER***
0000000000007FT9X
000000000000Y4ZPM
0000000000007GSXB
000000000000YPLCL
000000000000VM5DT
0000000000000000000
000000000000X34T3
0000000000007FT9X
000000000000Y4ZPM
0000000000007GSXB
000000000000YPLCL
000000000000VM5DT
0000000000000000000
000000000000X34T3
4.Below should not process: (This is not working with above code)
0000000000007FT9X
000000000000Y4ZPM
0000000000007GSXB
000000000000YPLCL
000000000000VM5DT
0000000000000000000
000000000000X34T3
***TRAILER***
000000000000Y4ZPM
0000000000007GSXB
000000000000YPLCL
000000000000VM5DT
0000000000000000000
000000000000X34T3
***TRAILER***
Regards,
kk