View previous topic :: View next topic
|
Author |
Message |
rajella
New User
Joined: 22 Jan 2017 Posts: 2 Location: USA
|
|
|
|
Hi,
Can someone help me in this or give me some useful hint to do this please. I am new to mainframe and to this forum as well.
I need to interchange only the specific records from the input file while copying it output file.
Say for example in the below input records, if the second field is same in the records (account number is same) and if the third filed has 016 and 015, then I need to interchange that record while copying to output file. All other records should be in the same order as input file.
Input Records:
HDR 01222017 INPUT
DTL ACTNO1 010 ABCDEFG
DTL ACTNO2 333 OPURSTV
DTL ACTNO2 211 PQRYUVS
DTL ACTNO3 O16 LSRYUVS
DTL ACTNO3 015 RSTUVSW
DTL ACTNO4 016 JKWMNTQ
DTL ACTNO5 015 IUNBVST
TRL 000009
Expected Records in the output file
HDR 01222017 INPUT
HDR 01222017 INPUT
DTL ACTNO1 010 ABCDEFG
DTL ACTNO2 333 OPURSTV
DTL ACTNO2 211 PQRYUVS
DTL ACTNO3 015 RSTUVSW
DTL ACTNO3 O16 LSRYUVS
DTL ACTNO4 016 JKWMNTQ
DTL ACTNO5 015 IUNBVST
Thanks
Prabakaran |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Always better to start new topic
Please show us what you have tried ?
Also what sort product do you use? |
|
Back to top |
|
|
rajella
New User
Joined: 22 Jan 2017 Posts: 2 Location: USA
|
|
|
|
I know only the following options in sort utility.
SORT FIELDS = ()
SORT FIELDS=COPY
INCLUDE COND=()
SORT FIELDS=COPY
OUTFILE FILES=01,INCLUDE=( )
SORT FIELDS=COPY
SUM FIELDS=NONE,XSUM
SORT FIELDS = ()
SUM FIELDS = NONE
SORT FIELDS=COPY
INREC FIELDS= ()
JOINKEYS =()
Since by using the following we can’t do this, I didn’t tried anything on this. If you can give me some hints or keywords in the sort utility to do this, I will try this from there. Now I am not sure where to start on this.
Please help. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You will need to use INREC with IFTHEN=(WHEN=GROUP with BEGIN=(logicalexpression), RECORDS=2, identify the first record and to PUSH the entire record to a temporary extension to the current record.
Then you need OUTFIL with IFTHEN=(WHEN=((logicalexpression) to identify the second record, and to BUILD with the slash-operator (/) so that you output the second record as the first, followed by the first as the second. You will also need OMIT= on the OUTFIL to get rid of the, by then, redundant first record. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Just curious - Will you always have the '016' and '015' records as the first 2 records in the ACTNO group, if at all they are present, or no?.
Also is there a chance of only one of these being present in the group and not the other? |
|
Back to top |
|
|
|