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

Copy Group of Records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Sun Jan 13, 2019 9:17 am
Reply with quote

Input File 1 [VB 1504 Bytes]

HEADER REC
2000A.....
REC1....
REC2....
2300....
REC3....
REC4....
.
.
RECN......
2000A
REC1....
REC2....
2300....
REC3....
REC4....
.
.
RECN...



FILE2 [10 Bytes FB]
1234567891
9876544211

I want to copy record where 10 BYtes key in File 2 match with 10 Bytes key present in record starting with 2300. Key position [15:10]

If key matches copy record starting from 2000A till next 2000A record.

Any suggestions ....
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Sun Jan 13, 2019 1:27 pm
Reply with quote

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.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts VB to VB copy - Full length reached SYNCSORT 8
Search our Forums:

Back to Top