I would like to use DFSORT to reformat a header and trailer. I have been
palying around with OUTREC IFTHEN statements and OUTFIL TRAILER1
statements for almost two days now but I can't get the thing do what I
want and I can't find a post that covers it either.
I normally only use DFSORT for basic sorting but from looking at
the Application Programmers guide I should be able to reformat my
headers and trailers. I'm hoping someone who is a lot slicker with these
commands can give me some pointers or examples I can expand.
Here is an example of a small infile and outfile of what I'd like to
achieve:
Col: 05-10 record type
Col: 11-14 amount
INFILE:
0 BLAHBLAH-INFO FROM ORIGINAL HEADER-
XXXXTYPE A0002
XXXXTYPE C0003
XXXXTYPE A0006
XXXXTYPE A0005
XXXXTYPE B0008
XXXXTYPE B0002
XXXXTYPE A0009
XXXXTYPE C0002
XXXXTYPE A0006
XXXXTYPE B0004
XXXXTYPE A0003
XXXXTYPE B0008
XXXXTYPE C0004
9 OLD TRAILER STUFF NOT REQUIRED
New File:
Header with new date, new text and part of the old header. Detail recs
unchanged.
New trailer fields explained:
9 - Trailer ID
0000000013 - Number of total detail recs
0000000062 - Sum of all amount fields
0000000006 - Number of 'TYPE A' recs
0000000031 - Sum of all amount fields for 'TYPE A'
0000000004 - Number of 'TYPE B' recs
0000000022 - Sum of all amount fields for 'TYPE B'
0000000003 - Number of 'TYPE C' recs
0000000009 - Sum of all amount fields for 'TYPE C'
And finally, the input file is 50 wide and the output is 81 wide
Yvonne,
Do you care for the original order of the detail records? Is it ok to sort detail records by record type? What is the field def. for amount field?
Also could you have multiple sets like the one you have shown above?
Unfortunately I need to leave the detail records unchanged and in their original order.
The amount field is an unsigned integer, no decimal places, just a basic 4 digit number.
Yes, there could be many more sets like the one above, and many more permutations similar to the one above, the file could also have no ‘TYPE B’ recs for example. What I have shown is a very small representative sample I was using in my as yet unsuccessful tests.