Assuming that there is always an E record in the group, here is a one pass DFSORT JCl which will give you the desired results removing the group which has E record as the last record. I assumed the file to be 80 bytes with FB RECFM
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(IN) ON(1,5,CH) TO(OUT) WITHALL WITH(01,80) -
KEEPBASE KEEPNODUPS USING(CTL1)
//CTL1CNTL DD *
why not wait for the TS ( Thread started ) to clarify his wishes??
as I said in my previous post ...
the description asks for something, the sample is something else!
until then everything is just pure speculation
Even I faced this problem initially ..
But there is no problem with the logic what is suggested..
I don't know why it is not working..
There is some problem occuring whlie we do the INREC in the ctrl card.
some length issue which I am unable to understand.
So, the SPLICE statement is not producing the result what we are expecting
But when you change length of the input file from 80 to 100 or
add sequence no.at position 51 and letter 'E' at 59
Sorry for misunderstanding. I don't have any duplicate post issue nor I have this kind of requirement . I was just trying out the issue and the solution JCL provided by Skolusu. But since the output was not matching with the required output by gabriel.ryoga. So I thought I will intimate the same to Skolusu. So I have posted my first reply for this thread.
I got this output with your suggestions.
I don't think its matching with the output required as the 00001 key records are out.Let Skolusu explain the output he got. He could have got correctly. There is some small thing gone wrong.
Yes you are correct. Its working.Actually I have changed the input records as below.
Since the code is sorting the records based on the key in ascending order and then the sequence number in descending order. I just made a trail by giving this kind of input. Then it is skipping 00001 key records. I think it should not. Shouldn't it??
This case fails because we are adding the sequence no in the INREC which executes before sorting the data.
For above given input by you
we need to code a step which sort the data according to the key and then splice using the same control card.
The solution I posted DOES produce the correct results eliminating the 0003 records. Trust me when I DO post a solution I post it after testing and getting the desired results. I have no idea as to why you don't get the same results without looking at your DFSMSG.
Probable reasons could be
1. You did not copy the control cards as is
2. You are NOT using DFSORT
3. Or you have a DFSORT version which does NOT support INREC processing with splice
Look at the ICE201I message . If you see a zero then your version does not support INREC processing with splice.
ICE201I 0 RECORD TYPE IS F - DATA STARTS IN POSITION 1
If you have the latest PTF then the message would have an E
ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION 1
Apologies!!!You are correct.I don't have latest PTFs. I just have seen my DFSMSG. You are perfect. I have seen the zero in ICE201I. So I think my shop doesn't have latest PTFs installed. So it is not supporting INREC with SPLICE.