Hi,
is it possible to find the count based on a condition (e.g)count the number of '03's in the position 20 of a VB file and put that count in the trailer record.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Yes, you can use IFTHEN to insert a 1-byte field after the RDW with a value of 1 for the given condition, otherwise a value of 0, in each record, and do a TOT on that value in the TRAILER record to get the count. Don't forget to remove the 1 byte value.
If you need more specific help, show an example of the records in your input file and what you expect for output. Also, give the LRECL of the input file and the starting position, length and format of each relevant field.
Indicate whether the starting positions count the RDW in positions 1-4 or not.
Thanks for the reply Frank
The below are the details about the input file
The input file is VB of record length 1004 and the format is
Input
...0000000000000000000001 Header record
...000020128382$$$$$$$$05DATA1
...000020128382$$$$$$$$40DATA1
...000020128383$$$$$$$$05DATA2
...000020128383$$$$$$$$10DATA2
...000020128383$$$$$$$$40DATA2
The required output is VB of record length 1004 and the format is
Output
...0000000000000000000001 Header record
...000020128382$$$$$$$$05DATA1
...000020128382$$$$$$$$40DATA1
...000020128383$$$$$$$$05DATA2
...000020128383$$$$$$$$10DATA2
...000020128383$$$$$$$$40DATA2
999999999999999999999999000000007000000002
$ represents the spaces
999999999999999999999999000000007000000002 is the trailer record with the 25 9's followed by the total number of records(000000007) followed by total number of '05's (000000002).
In addition to the above i need perform sort based on first 25 bytes of the record.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for. It was difficult to tell where your '05' field started so I assumed it started in position 25 (counting the RDW). Change it if appropriate.
Thanks for the sort card Frank.i just made a small change as
SORT FIELDS=(14,25,CH,A). because SORT FIELDS=(5,25,CH,A) made all the '05' records to come at the bottom since we were assigning the '000000001' at position 5 thru 13 in the inrec and sorting based on 5 thru 29.The sort card helped me a lot thanks for your help Frank.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Oops. I didn't notice the output records were in the wrong order when I tested my job. I should have used an OUTREC statement to change the records AFTER sorting. I've edited my job accordingly.