Are there always only two records in the input file, and you want to write the second record if the first record meets the condition, but not write the second record if the first record does not meet the condition?
For example, if the two records are:
The Error is
you want the output to be:
but if the two records are:
you don't want any output?
Or are there more than two records in the input file? And if so, what is it you want to do exactly?
Please show a better example of your input and expected output for the various possible cases and explain what it is you want to do exactly.
Actually A program will abend throwing the error statements. There can be many. But the way it will write is it will not write the error statement in a single way. I till split as I said. First it will say the " The error is" and then the immediate the record will have the error code. So I need to search for the string1 in the SYSOUT so in the search where ever I found the "The Error is" I need to read the immediate the next recor which tells the error code and write the same after reading it to an output fiel. So I posted this.
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
The first OVERLAY creates a sequence number for every record.
The second OVERLAY adds 1 to the sequence number for each record with 'THE ERROR'.
This forces the sequence number for each 'THE ERROR' record to be the same as the sequence number for the record after the 'THE ERROR' record. For example, if the sequence numbers for the first 'THE ERROR' record and the record after it are 5 and 6 after the first OVERLAY, they will be 6 and 6 after the second OVERLAY.
Thus, the SELECT ALLDUPS on the sequence number will select those pairs of records (the 'THE ERROR' record and the record after it) since they have duplicate sequence numbers (e.g. 6 and 6).
The OUTFIL removes the 'THE ERROR' records, so only the record after each 'THE ERROR' record is output.
I can't test this right now, but I would give a try to use LASTDUP rather than ALLDUPS, so you will have no need to code a OMIT card.
I would add a SORT FIELDS=COPY because your records are already sorted.
ICE650I 0 VISIT http://www.ibm.com/storage/dfsort FOR ICETOOL PAPERS, EXAMPLES
ICE632I 0 SOURCE FOR ICETOOL STATEMENTS: TOOLIN
ICE630I 0 MODE IN EFFECT: STOP
SELECT FROM(IN) TO(OUT) ON(134,8,CH) LASTDUP USING(CTL1)
ICE606I 0 DFSORT CALL 0001 FOR SORT FROM IN TO OUT USING CTL1CNTL CO
ICE628I 0 RECORD COUNT: 000000000000002
ICE638I 0 NUMBER OF RECORDS RESULTING FROM CRITERIA: 000000000000000
ICE602I 0 OPERATION RETURN CODE: 00
It's not working for you because you don't have z/OS DFSORT V1R5 PTF UK90007 installed. That PTF has been available since April, 2006 and it's needed to use INREC with SPLICE. When I run your job here with that PTF, the output is:
When I run your job without the PTF, I get no output.
Ask your System Programmer to install that PTF (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
I did NOT remove the SEQNUM from the first OVERLAY. I removed some other unneeded SEQNUM I had in the original job, but I don't really remember where it was at this point.
Are we using any splice in our code?
We are using SELECT, not SPLICE.
Can you please clarify me where are we sorting earlier?
You said no need to sort,COPY is more efficient.
We are NOT sorting - that's the point. SELECT would normally sort on the ON field of 134,8,CH. But since the values we created for 134,8,CH with the INREC statement are sequence numbers that are already in sorted order, we don't need to sort them.