Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
When posting you must use the Code tags and the Preview button so that you can present your data in the best way.
"Guessing" from what you have provided, I think something like this:
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(41:SEQNUM,1,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(41,1,CH,EQ,C'2'),
RECORDS=1,
PUSH=(42:1,40)),
IFTHEN=(WHEN=GROUP,BEGIN=(41,1,CH,EQ,C'1'),
RECORDS=2,
PUSH=(1:1,40)),
IFTHEN=(WHEN=(41,1,CH,EQ,C'2'),
OVERLAY=(5:46,1,9:50,1,21:62,1,25:66,1))
OUTFIL INCLUDE=(41,1,CH,EQ,C'2'),BUILD=(1,40)
//SORTIN DD *
A B C D E F G H I J K L M N O P Q...
3 5 X X
|
Which produces this:
Code: |
A B 3 D 5 F G H I J X K X M N O P Q...
|
It will be important for you to understand the Control Cards, so I have made the understanding "easier" by using 40-byte records.
Start by commenting-out the OUTFIL, you'll see this:
Code: |
A B C D E F G H I J K L M N O P Q... 1
A B 3 D 5 F G H I J X K X M N O P Q... 2 3 5 X X
|
The "1" as the last non-blank on the first record is the sequence number added in the WHEN=INIT. Each record will receive a sequence number, you can see the "2" in the same position on the second record.
The first WHEN=GROUP operates on the 2nd record, and only that record. It's purpose is to take the data from the 2nd record, and copy it starting at position 42. Reason being, we're just about to overwrite it.
The second WHEN=GROUP operates on both records, triggered by identifying the first record. It puts the data from 1 for a length of 40, to column 1: in the record. For the first record, this simply copies the data over itself. The important part is the second record, where the data from the first record is put at column 1:, overwriting the original content (which is why we first saved it at position 42).
The second record thus contains all the data, separated by the sequence number "2".
The final IFTHEN identifies the second record by the sequence number, and OVERLAYs the required data belonging to the second record to the required positions in the data from the first record.
The purpose of the OUTFIL is to only include the second record (the first being now redundant) and to cut the record down to the correct size with the required data, using BUILD (in this example a length of 40).
Experiment by continuing to leave the OUTFIL commented, and removing first one, then the other, of the WHEN=GROUPs, so you get the idea of how it is working and why it has to be like that.
Then, and only then, "correct" the code for 80-byte records (just add 40 to everything, pretty-much) and test, and hand it over to the next stage of your development.
What you learn from the process will help you develop your own solutions and understand other solutions which you may be able to apply to your future requirements.
Read-up on the functions used in the DFSORT manuals. Experiment. Read again, and repeat until you understand. If still unclear, ask, someone will be here to answer. |
|