Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
Please look at other topics posted in the forum and post yours the same way. For jcl, data, and code, use copy/paste and the "Code" tag. Then Preview to make sure your post looks as you want it. Then submit.
As Expat mentioned, not all of our members are permitted to download attachments.
Hi,
Currently our sort control card working fine, if the input file to the SORT contains data for one day.
The control card is not working fine , if the input file to sort contains the data for two days.
The first character in the input file
“0” indicates header record
“2” Indicates data
“9” Indicates Trailer record.
SortIn file:
Code:
***************************** Top of Data ************
020090705
2508200907032860000269TN 1200011010330060010 +0000000
9000000020+000000000410672.24-000000000618875.17-0
020090706
2083200907062860000096 1200014060030060010 +0000000
9000000001+000000000000455.90-000000000000025.16+0
**************************** Bottom of Data **********
Control card:
Code:
***************************** Top of Data **
SORT FIELDS=(01,01,BI,A,
02,03,BI,A,
04,08,BI,A,
26,05,BI,A,
13,10,BI,A,
23,03,BI,A,
31,06,BI,A)
**************************** Bottom of Data
Current output of above sort card:
Code:
***************************** Top of Data **********
020090705
020090706
2508200907032860000269TN 1200011010330060010 +00000
2083200907062860000096 1200014060030060010 +00000
9000000020+000000000410672.24-000000000618875.17
9000000001+000000000000455.90-000000000000025.16
**************************** Bottom of Data ********
Our output file requirement is that, It shoud have record in the order of
Header record
Data record
Trailer record
Header record
Data record
Trailer record
Can anyone help me with this issue..
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Well, your input example isn't very good because it only has one '2' record for each group, but ...
The GROUP clause puts puts an id in positions 81-89 for each "group" of records. A group of records starts with a '0' in position 1. So after the INREC statement is processed, the first group of records (0, 2, 9) will have an 00000001 id, the second group of records will have a 00000002 id, etc.
Now we sort on the group id in 81-89 to keep the groups in order and then we sort on your other fields to sort the '2' records in the correct order within each group. Then we remove the group id.