View previous topic :: View next topic
Author
Message
Hariharan BK New User Joined: 11 Sep 2011Posts: 14 Location: India
Yes. this is the requirement Arun.
Yes they are sorted.
Back to top
xknight Active User Joined: 22 Jan 2008Posts: 117 Location: Liberty city
Hello Hari
In the given input, does the set of records has predictable count in between the header/trailer or will it be dynamic count.
For an instance,
the below set always have 4 records between the header & trailer.
Code:
0001 GTFLFL411720130601 ***
0001 GTFLFL411734235 R1 06620758890 <---
0001 GTFLFL411734235 R1 06620758890 <---
0001 GTFLFL411734235 R1 06620758890 <---
0001 GTFLFL411734235 R1 06620758890 <---
0001 GTFLFL411720130601 ***
Back to top
Hariharan BK New User Joined: 11 Sep 2011Posts: 14 Location: India
no Naveen. They differ. they are dynamic....
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hariharan BK,
The below syncsort will give what you are trying. I have modified the input a bit just for clarity. I assumed no two "groups" will have the same value at pos 5,4. The first step will extract the unique group ids for which there is a match on 29,11. The next step is to extract all the records within each "group".
Code:
//STEP01 EXEC PGM=SORT
//SORTJNF1 DD DISP=SHR,DSN=Input key-file (FB/80)
//SORTJNF2 DD DISP=SHR,DSN=Input data-file (VB/6800)
//*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(01,11,A)
JOINKEYS FILE=F2,FIELDS=(29,11,A)
REFORMAT FIELDS=(F2:5,4)
SORT FIELDS=(1,4,CH,A)
DUPKEYS FIELDS=NONE
/*
//*
//STEP02 EXEC PGM=SORT
//SORTJNF1 DD DSN=&&T1,DISP=(SHR,PASS)
//SORTJNF2 DD DISP=SHR,DSN=Input data-file (VB/6800)
//*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=Output data-file (VB/6800)
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(01,04,A)
JOINKEYS FILE=F2,FIELDS=(05,04,A)
REFORMAT FIELDS=(F2:1,4,5)
SORT FIELDS=COPY
/*
//*
Input key-file FB/80
Code:
----+----1---
06620758890
06620758892
Input data-file VB/6800
Code:
----+----1----+----2----+----3----+--
0000 GTFLFL411720130601
0000 GTFLFL411734235 R1 06620758880
0000 GTFLFL411734235 R1 06620758880
0000 GTFLFL411734235 R1 06620758880
0001 GTFLFL411720130601 <---
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411720130601 <---
0001D GTFLFL <---
0001D GTFLFL <---
0001D GTFLFL <---
0001D GTFLFL <---
0002 GTFLFL900020130601
0002 GTFLFL900034235 R1 06002138891
0002 GTFLFL900034235 R1 06002138891
0002 GTFLFL900034235 R1 06002138891
0003 GTFLFL411720130601 <---
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411720130601 <---
0004D GTFLFL <---
Output data-file VB/6800
Code:
----+----1----+----2----+----3----+--
0001 GTFLFL411720130601 <---
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411734235 R1 06620758890
0001 GTFLFL411720130601 <---
0001D GTFLFL <---
0001D GTFLFL <---
0001D GTFLFL <---
0001D GTFLFL <---
0003 GTFLFL411720130601 <---
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411734235 R1 06620758892
0003 GTFLFL411720130601 <---
Back to top
Hariharan BK New User Joined: 11 Sep 2011Posts: 14 Location: India
Great.. Thanks much Arun. Let me give a try on this.
Thanks All..
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hariharan BK,
You're welcome!. Try and come back if you are stuck up somewhere.
btw Will you have more than 1 header record in a group? Or will it be always one header?
Back to top
Please enable JavaScript!