Posted: Thu May 26, 2016 2:38 pm Post subject: Cumulative sum and Select Records
Hi,
My file has number count at position 66 with length 8 sorted in ascending order. File has more than 1000 records.
My requirement is to count this field and when the count reaches 50,000 i should stop. While counting 50,000 i should write the input file records to output file.
Thanks for your response I am using the method which was suggested by you to another person. Below are the details.
Input file name is 120 LRECL and RECFM is FB, sorted in ascending order. (Original production file is of 101 LRECL to accommodate the cumulate sum of each record I am adding 19 bytes towards the end)
I have a 9 digit numeric number starting at position 46 as mentioned below. I need to add the cumulative of these numbers and when total reaches > 5000 (example) I want to write all the input files to output file and stop processing.
To achieve this I am doing is using the method suggested by you to add cumulative towards the end of the file and then in another sort step I am putting the condition for the newly added cumulative column to select records which totals upto less than 5000.
INCLUDE COND=(22,4,LT,5000),FORMAT=ZD
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
FILENAME11111111111111111111111111111111111 ;000000131;00000003333;AAAAA
FILENAME22222222222222222222222222222222222 ;000000242;00000004444;BBBBB
FILENAME33333333333333333333333333333333333 ;000002333;00000005555;CCCCC
FILENAME44444444444444444444444444444444444 ;000003454;00000006667;DDDDD
FILENAME55555555555555555555555555555555555 ;000004565;00000007774;EEEEE
**************************** Bottom of Data ****************************
it is adding the cumulative at the end which I was expecting.
Please advise if I use the original file with position 46 and different numeric values why it is not writing all the cumulative records, in test files when I use 111111111, 222222222,333333333,444444444 values at position 1 it is working fine.
Even at position if I change the value from 111111111,222222222,333333333,444444444 to original values like below Command ===>,
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu May 26, 2016 7:05 pm Post subject:
dhansr,
I appreciate you spending time in searching and trying to tailor it to your needs. Good Job. You just missed one slight clue from my old trick. You got the right idea however you have a control break on the position 1 for a length of 1 and in your case position 1 for every record is value F. So the Sections and trailer3 is generating a single record with total count.
You need to have a control break on every record as you need a running total. So in order to do that you simply add a sequence number at the end and have a control break on it.
Maybe some more research is the best way to go? Consult the manuals, starting with the Getting Started and then moving on to the Application Programming Guide.
Whilst going through, follow the examples and try some of your own.
If, after that, you haven't grasped it fully, explain the issue that you have.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri May 27, 2016 10:58 am Post subject:
dhansr wrote:
When you have some time please advise what is the function of SEQNUM & SECTIONS.
Thanks again for your quick response, outstanding !!!
Dhansr,
As william pointed out, you will remember the code and make any future changes quite easily if you understood what it is doing rather than me explaining.
Steps to understand the job
Run the job multiple times to understand what it is doing. run it against your sample data of 5-10 records
Now you will see the original record (lack of NODETAIL) and another record with summary total at position 102. Since I removed the BUILD=(120X) you will also see the Sequence number that we added at the end.
By running control cards one at a time you can actually see how DFSORT process the control cards.
Just once you understand the job then it is quite easy to change or apply similar logic to other requirements that might come up. _________________ Kolusu
www.linkedin.com/in/kolusu
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum