I have such a file and want to output the whole file(including the 1st record) if the first record matches (1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99').
How to code the SORT control command?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
gcicchet,
There is a slight problem with your approach as the INCLUDE COND gets executedbeforethe STOPAFT. So even if 30AAAAAAAAAAAAAAA99 is the 10 th record or any other record your job will issue a return code of 0 which is wrong. Try your job moving the first record anywhere and check it for yourself.
Use the following DFSORT JCL which will copy the entire file in one pass ONLY if the very first record matches (1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99') or else it would be empty
I assumed that your input is FB recfm and LRECL of 80
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
Hi Skolusu,
I apologise for providing an incorrect solution.
In your example which I cannot test GROUP due an old version of DFSORT,
are you still reading the entire file ?
Would it not be best to copy out 1st record only and test it, it's no point reading the entire file when only the first record needs to be tested. especially if it happens to be a large input file.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
gcicchet wrote:
Would it not be best to copy out 1st record only and test it, it's no point reading the entire file when only the first record needs to be tested. especially if it happens to be a large input file.
Gerry
gcicchet,
Yes I would read the entire file, but it is a good idea to just validate the first record and then copy it. In that case OP needs to use the following control cards