IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SyncSort/SyncTooL to extract records based on Key


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hariharan BK

New User


Joined: 11 Sep 2011
Posts: 14
Location: India

PostPosted: Tue Jun 04, 2013 5:09 pm
Reply with quote

Yes. this is the requirement Arun.
Yes they are sorted.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Jun 04, 2013 5:30 pm
Reply with quote

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
View user's profile Send private message
Hariharan BK

New User


Joined: 11 Sep 2011
Posts: 14
Location: India

PostPosted: Tue Jun 04, 2013 6:42 pm
Reply with quote

no Naveen. They differ. they are dynamic....
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Jun 05, 2013 11:49 am
Reply with quote

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
View user's profile Send private message
Hariharan BK

New User


Joined: 11 Sep 2011
Posts: 14
Location: India

PostPosted: Wed Jun 05, 2013 4:05 pm
Reply with quote

Great.. Thanks much Arun. Let me give a try on this.

Thanks All.. icon_biggrin.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Jun 06, 2013 6:36 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top