i am sorry to say that i put my requirement wrongly. actually i got the requirement cleary after doing the above JCL. My requirement is:
Suppose a file conntais the records like this:
in this case, for the key from 1 to 16, first 4 records are duplicates and the next 3 records are duplicates. for the first key, 0000000100000002, after insert "I' there is one delete D. so insert is balanced by Delete. so i don't want these records in the O/P file.
for the next key,0000000300000004, there is an Insert I, Delete D and again Insert I, so i want to keep the last record of this key i.e. Insert.
to summarize, we can say i want to keep the last record if a key is having odd number of record. Please help me to achieve this.
You don't need two passes to do this. You can do it in one pass with a DFSORT/ICETOOL job like the following:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,16,CH) LAST USING(CTL1)
//CTL1CNTL DD *
OUT would have: