I have coded the below Sort step to validate file for header, trailer, and count. It is working fine for a single header and trailer.
But when there are more than 1 header and trailer in the input then it doesn't work. Meaning it doesn't throw error. Can you please advise me how to modify the below sort card to throw error for multiple header/trailer.
Specifically if I get to read the last record (which is the trailer of the concatenated files) then I can do the verification that I am currently doing on TRL. Any advise will be really appreciated. Thanks
Code:
//STEP0100 EXEC PGM=SORT,PARM='NORC16'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=input.file,DISP=SHR
// DD DSN=input.file,DISP=SHR ** two same files as an input doesn't give error.
//SORTOUT DD SYSOUT=*
//HDR DD SYSOUT=*
//TLR DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(181:SEQNUM,9,ZD)),
IFTHEN=(WHEN=(19,6,CH,EQ,C'TRAILR'),
OVERLAY=(181:181,9,ZD,SUB,+2,M11,LENGTH=9))
OUTFIL FNAMES=HDR,INCLUDE=(19,6,CH,EQ,C'HEADER'),NULLOFL=RC16
OUTFIL FNAMES=TLR,INCLUDE=(19,6,CH,EQ,C'TRAILR',
AND,25,9,CH,EQ,181,9,CH),
NULLOFL=RC16
//*
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
Quote:
Can you please advise me how to modify the below sort card to throw error for multiple header/trailer.
This cannot be done, period. Mainframe systems do NOT "throw error" -- they may ABEND, they may have a non-zero step return code, they may have a user error, but they are not "throwing errors". Since the code NEVER will throw an error, we cannot tell you how to do it.
This is supposedly a forum for mainframe expert users -- you should KNOW by now what the terminology is and use it. If you want to throw errors, go work on a Unix or Windows machine.
Apologies for using incorrect term. What I meant by error was JCL step returning a non-zero return code (RC). I will take care of it from next time. Thanks.
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
Quote:
But when there are more than 1 header and trailer in the input then it doesn't work
You have been on this forum for almost 11 years and have seen none of the posts stating that telling us something "doesn't work" is useless -- HOW did it not work?
Did it generate a SORT error?
Did it generate a non-zero return code for the SORT step (and if so, WHAT RETURN CODE)?
Did it generate an empty output data set?
Did it generate a data set with the correct data but no headers or trailers?
Did it generate a data set with the correct data and headers but no trailers?
Did it generate a data set with the correct data and headers and trailers but they are not correct (and if this is the case, HOW are they not correct)?
etc
etc
etc
There's LOTS of ways something "doesn't work" -- you need to give us at least a little information about what isn't working for us to help you! You should post at a minimum the SORT messages!
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
mohitsaini,
For a single input data set condition, it seems like you are trying to generate RC=16 when there is either no header record, or an incorrect trailer record count, from the control cards shown.
I think you need to define clearly when you want the concatenated input to be considered as invalid - no header records at all OR missing any one header record. Similarly any one trailer record count is incorrect OR none of them are correct, and so on. Well then, it leads to a question of if there is something within the data(detail records) that helps distinguish between the records from multiple data sets involved in the concatenation.
But when there are more than 1 header and trailer in the input then it doesn't work.
Of course it won't work as there is not way your are restarting the sequence number and identifying the next header and trailer and so on....
RahulG31, TS is matching total record count to Trailer count.