I need to sort a file on account number but the account number exists on the header record but not the detail records. Can I utilize dfsort or icetool to copy the account number to detail records? I should be able to..... but have been trying for a couple of hours to no avail. The rest of the record should remain the same as input.
I will simplify the example. The record group is in col 1 and the account # is in col 2. The record is 200 bytes long with fb format. The before and after records are as follows:
Before:
a001 header
a
a
b009 header
b
c002 header
c
c
d005 header
d
Thus, I need for the account number to 'drop down' to the next record until a new account number is encountered. There is also a code for header and detail records. Header records can be a 0,1 or 9 while detail records can be a 3, 4, 5, or D. I left that out of the example but it exists if needed. Is this task difficult? Thank you in advance for any help you can provide.
Thank you. The header record code should not be significant but is available if the data can't be appended otherwise. The header record will always be the first record in a 'new group' as noted by a change in column 1.
With my example think of the header record as the product information regarding a sell. Detail record 1 could be the associated commission. Detail record 2 could be a regulatory fee. That information is insignificant and I think the record type code (header or trailer) is also insignificant.
If I can append the account number on all records I will sort the file on account number, record group and sequence number that I will be adding with an 'overlay seqno step'. Thank you for any help you can provide.
jim kuhn
I have considered the i/p in this fashion
Code:
H001
A
A
A
H002
B
B
B
All header records will start with H in first position.
detail records may start with any character other than H
The following DFSORT/ICETOOL JCL, drops down the content in the header record from 2nd position to 4th position, to the detail records untill it encounters next header record.
It would have helped if you'd shown your input as it actually looks. I created the following input file with RECFM=FB and LRECL=200 based on your description:
Code:
0001 header
3 detail a
4 detail a
1009 header
5 detail b
0006 header m
9002 header
D detail c
5 detail c
0005 header
3 detail d
OUT would have:
Code:
0001 header
3001 detail a
4001 detail a
1009 header
5009 detail b
0006 header m
9002 header
D002 detail c
5002 detail c
0005 header
3005 detail d
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Krisprems,
I used KEEPNODUPS for completeness in case there is a header without detail records. In my example, I had
0006 header m
for that case and it would not appear in the output file without KEEPNODUPS. If the input file doesn't contain any headers without detail records, then KEEPNODUPS is not needed.