Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Move field from Header to Detail records in each group

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
thisak

New User


Joined: 09 Jun 2006
Posts: 14

PostPosted: Thu Sep 12, 2013 3:48 pm    Post subject: Move field from Header to Detail records in each group
Reply with quote

I have input file with records in below structure -
HDR <ACCT. NO.1>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TRL <count>
HDR <ACCT. NO.2>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TRL <count>
HDR <ACCT. NO.3>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TTT <TXN Details>
TRL <count>

I want above records to be transformed into

TTT <ACCT.No.1> <TXN Details>
TTT <ACCT.No.1> <TXN Details>
TTT <ACCT.No.1> <TXN Details>
TTT <ACCT.No.2> <TXN Details>
TTT <ACCT.No.2> <TXN Details>
TTT <ACCT.No.2> <TXN Details>
TTT <ACCT.No.2> <TXN Details>
..
..
TTT <ACCT.No.3> <TXN Details>
TTT <ACCT.No.3> <TXN Details>

Can anyone suggest me the way to go forward with sample code?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Sep 12, 2013 5:01 pm    Post subject: Reply to: Move field from Header to Detail records in each g
Reply with quote

Use OMIT to get rid of TRL

Use IFTHEN=(WHEN=GROUP to identify the HDR and PUSH the values from the HDR to each detail record.

Use OUTFIL OMIT to get rid of the by now redundant header, and BUILD to create your desired output.
Back to top
View user's profile Send private message
thisak

New User


Joined: 09 Jun 2006
Posts: 14

PostPosted: Fri Sep 13, 2013 9:29 am    Post subject: Reply to: Move field from Header to Detail records in each g
Reply with quote

By your reply, I can understand that my case can achievable.
But I want to know what each of those keywords does?
If any sample code is there, then this would be great.

Thank you very much.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Sep 13, 2013 10:22 am    Post subject:
Reply with quote

This is what Bill has suggested. Bill..Please correct me if I'm wrong.

Try the below code. You can modify it as per your exact data length and offsets.

Code:
//STEP01   EXEC PGM=SORT                                           
//SORTIN   DD *                                                   
HDR <ACCT. NO.1>                                                   
TTT <TXN DETAILS>                                                 
TTT <TXN DETAILS>                                                 
TTT <TXN DETAILS>                                                 
TRL <COUNT>                                                       
HDR <ACCT. NO.2>                                                   
TTT <TXN DETAILS>                                                 
TTT <TXN DETAILS>                                                 
TTT <TXN DETAILS>                                                 
TTT <TXN DETAILS>                                                 
TRL <COUNT>                                                       
//SORTOUT  DD SYSOUT=*                                             
//SYSOUT   DD SYSOUT=*                                             
//SYSIN    DD *                                                   
 OPTION COPY                                                       
 INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:5,12))
 OUTFIL INCLUDE=(1,3,CH,EQ,C'TTT'),BUILD=(1,4,5:81,12,17:4,14)     
/*                                                                 

Output:
Code:
TTT <ACCT. NO.1> <TXN DETAILS>
TTT <ACCT. NO.1> <TXN DETAILS>
TTT <ACCT. NO.1> <TXN DETAILS>
TTT <ACCT. NO.2> <TXN DETAILS>
TTT <ACCT. NO.2> <TXN DETAILS>
TTT <ACCT. NO.2> <TXN DETAILS>
TTT <ACCT. NO.2> <TXN DETAILS>
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Sep 13, 2013 11:40 am    Post subject: Reply to: Move field from Header to Detail records in each g
Reply with quote

I would add the OMIT COND= for the "TRL" and the OUTFIL OMIT= for the "HDR".

If there is data you don't want, it is always good to OMIT COND= (or INCLUDE the data that you do want) so that fewer records are processed - plus, it is clearer what is being processed.

With OMIT= for the header on the OUTFIL, it is then easier to understand the whole process:

We don't want trailers, at all, they are nothing to us. First line of code.
We process informaiton from the headers onto thte data.
Now we don't want the headers.

thisak.

Note that you should read the 81:as "a temporary data position at the end of my record". If your records area variable, then it needs to be at the start of the record.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Sep 13, 2013 12:28 pm    Post subject:
Reply with quote

Thanks Bill.

Thisak,
First try to understand what this code is doing and then modify it as per your requirements.

Code:
//SYSIN    DD *                                                   
 OPTION COPY                                                       
 OMIT   COND=(1,3,CH,EQ,C'TRL')                                   
 INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:5,12))
 OUTFIL OMIT=(1,3,CH,EQ,C'HDR'),BUILD=(1,4,5:81,12,17:4,14)       
/*                                                                 
Back to top
View user's profile Send private message
thisak

New User


Joined: 09 Jun 2006
Posts: 14

PostPosted: Tue Sep 17, 2013 2:05 pm    Post subject: Reply to: Move field from Header to Detail records in each g
Reply with quote

Thank you very much - Bill & Mistah

Mistah, Thanks again for explaining that with code.
I'll try this and surely reply with the outcome.

Thanks,
Thisak
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 17 Tue Dec 06, 2016 8:04 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us