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

Copy record key on other records


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

New User


Joined: 31 Mar 2015
Posts: 18
Location: Italy

PostPosted: Thu Apr 02, 2015 10:16 pm
Reply with quote

Hi,

I've a dataset with 2 record types (record type "1" and "2"). Record type is located on first column and record type 2 all refer to the previsous record type 1, like to it follows:
Code:
1 key001 field1
2        data-a
2        data-b
2        data-c
2        data-d
1 key002 field1
2        data-a
2        data-b
1 key003 field1
2        data-a
2        data-b
2        data-c
2        data-d


And the desired output is:
Code:
1 key001 field1
2 key001 data-a
2 key001 data-b
2 key001 data-c
2 key001 data-d
1 key002 field1
2 key002 data-a
2 key002 data-b
1 key003 field1
2 key003 data-a
2 key003 data-b
2 key003 data-c
2 key003 data-d


Do you know if and how it can be done with DFSORT or ICETOOL?
I hope the question is not too easy for the expert forum.

Thanks a lot, regards.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Apr 02, 2015 10:42 pm
Reply with quote

Use the below card in SORT and don't forget to read the SORT manual for future :-)
Code:
//SYSIN DD *                                         
 OPTION COPY                                         
 OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,CH,NE,C' '),   
 PUSH=(3:3,6))                                       
 OUTFIL BUILD=(1,16)                                 
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 02, 2015 10:57 pm
Reply with quote

That should do it.

Can be touched-up a little:

Code:
//SYSIN DD *                                         
 OPTION COPY                                         
 INREC IFTHEN=(WHEN=GROUP,
                      BEGIN=(3,6,CH,NE,C' '),   
                      PUSH=(3:3,6))


It identifies the start of a group as a non-blank key, then copies the key to position three (which is the start of the key) on every record, including the first, of the group.

I didn't know what the OUTFIL was for, so I removed it :-)
Back to top
View user's profile Send private message
tdfs

New User


Joined: 31 Mar 2015
Posts: 18
Location: Italy

PostPosted: Fri Apr 03, 2015 1:38 pm
Reply with quote

Can I just reply with a "WOW!!!" ?

Guys, this is simply amazing!
Thank you so much!
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(F1 & F2) and writ... JCL & VSAM 4
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top