Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1255 Location: Bamberg, Germany
|
|
|
|
You first should propagate the KEYs to all records. This can be done when sorting in this step using an ID(A) and the SEQNUM(D). Sample:
Code: |
//SORTIN DD *
2000A.....
REC1....
REC2....
2300KEY1
REC3....
REC4....
2000A.....
REC5....
REC6....
2300KEY2
REC7....
REC8....
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(30:+0,TO=ZD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'2000A'),
PUSH=(20:ID=2,SEQ=8)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'2300'),
END=(1,5,CH,EQ,C'2000A'),PUSH=(30:5,4))
SORT FIELDS=(20,10,ZD,D)
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(20,2),PUSH=(30:30,4))
END
/*
|
After that use e.g. another JOINKEYS step to find matching pairs with 'B' indicator and sorting after joining by ID(A) and SEQNUM(A) again. That should work I guess. But for sure there are better solutions available. |
|