I have a cobol program that takes in a huge file (with records in the order of millions) and it splits it into multiple files. It also adds header and trailer while doing the same. But this process is time consuming. In order to reduce the time I feel that we can achieve the same using DFSORT. Following is the requirement for the same:
1) Split the file ->I guess we can use STARTREC/ENDREC since this split factor is always consistent
2) Count -> We can achieve using COUNT function in the TRAILER
3) Hash total -> The hash total of a particular numeric field should be printed. We can achieve this using SUM
4) Date -> The current date should be printed.
I am not sure as to how we can get all these together
Example:
Input:
XXXXX 123
XXXAA 345
YYYYY 678
BBBBB 888
If the split factor is 2 then the output should be
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
rarvins,
1.What is the criteria for splitting the file?
2. What is the LRECL and RECFM of input and output files
3. What is the position and format of the numeric field to be summed?
1)The criteria for splitting the files is the number of records. We have a predetermined number. So we can hardcode it directly. Say for example we can take it as 100000
2) The LRECL is 742 and is FB
3) The field that needs to be summed starts @ position 150 and has a PIC S9(7)V99
Thanks a lot Skolusu, I changed the datatype of the field that we are trying to do a sum to PD instead of ZD and gave the length as 150,5 instead of 150,9. The job went fine.
Thanks once again for your timely help.
I just have one question
Will the count field and SUM field always start and end @ a particular column or will it vary. Example Will it always start @ 10th position and have a fixed length?
If not can we make it like that so that I can refer to the trailer with a copybook.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Quote:
I changed the datatype of the field that we are trying to do a sum to PD instead of ZD and gave the length as 150,5 instead of 150,9. The job went fine.
Go back and read your post and check if you mentioned anything about the summing field being a COMP-3 Field. I just went with your definition.
Quote:
Will the count field and SUM field always start and end @ a particular column or will it vary
Yes the count always starts in position 10 on the trailer records for 8 bytes with leading zeroes suppressed
The total value starts from postion 18 for a length of 11 bytes with leading zeroes supressed
If you need the leading zeroes then I can show you a way to do it
Quote:
If not can we make it like that so that I can refer to the trailer with a copybook.
If you want it in a copy book layout , show me the cobol layout and I will show you a way to do it
Quote:
Also, is there a way to retain the decimal in the SUM field. In the output file the decimal point is lost
First and foremost Packed decimal fields do NOT have an implied decimal point. The decimal point depends on how you define the field.
Do you need the total on the trailer record to be in a readable format? if so show me how you want to see it
Thanks for your prompt reply. yes I hadnt mentioned about the COMP-3 field. I went through the positions and modified it accordingly to suit the copybook that i have. Also i changed the mask not to supress the leading zeros.