View previous topic :: View next topic
Author
Message
thisak New User Joined: 09 Jun 2006Posts: 14
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
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
thisak New User Joined: 09 Jun 2006Posts: 14
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
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
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
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
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
thisak New User Joined: 09 Jun 2006Posts: 14
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
Please enable JavaScript!