Hello. It's been a while since my last time at the forums.
We have a requirement to set up a file to load a partitioned table. Let's asume an Input record of 20 bytes length, and FB format.
The file records are as follow:
Positions 1 trhough 10, A Date, in this format: aaaa-mm-dd
Positions 11 through 20, some text
The requirement is to number records in groups by the year and month of the date. Usually, the input records only have three months in date expand, but it could be more or less. The desired output should be a sequential number for each different year-month occurrence. Here is an example of the input records:
Can this be accomplished with a sort step? We have looked at the When=Group option, but that requires beforehand that you know a key in order to differentiate different groups of records, however, the dates could be random, and there could be even months without info. Se we are evaluating if we should write a Cobol program for this or attempt a Sort step
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Good to see you back - for newcomers who want to know about the sig, do a search, it has been discussed before :-)
Can you show the level of DFSORT you have? - please post the ICE201I message from any sort step.
If you've looked at WHEN=GROUP, did you notice KEYBEGIN? If you have that, it is easy.
Without KEYBEGIN, you can append a sequence number, with RESTART=(1,10) and then do the WHEN=GROUP with BEGIN= the value 1 in the appended sequence number position.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
Gabriel posted the original working solution.
When Skolusu posted the optimized solution, Gabriel tried it on his system and found that KEYBEGIN is not available on that system and provided this info. Not such a great sin?