If you have DFSORT, post your queries in the DFSORT forum.
One way to achieve this is, use WHEN=GROUP and KEYBEGIN, to add group IDs, then in the output write the last record using OUTFIL TRAILER1. This record will have the number of groups - 7 as per your example.
This can be tweaked to arrive at the result - 6. Good luck
The TS wanna get the ready-to-use code, to copy-paste it into his project.
The task is equivalent to an exercise for a first year student.
Nowadays too many people don't want to read and understand the manuals. I'm not sure if they can read, at all?
To be honest, I'm a bit lost by the whole question.
There is no real explanation as to what is required, and there is no example of the expected output.
Just some advice, please learn quickly to explain what you need, in detail, giving examples of input / output where possible. You might understand exactly what it is that you need, but as I have said above. It took me two or three reads to finally work it out.
You also need to show what YOU have tried yourself, and the results given and the results expected. From your example above what did you expect out of the exercise.
You will almost certainly always be asked to provide what you have tried yourself.
Another important thing to remember is that there are such things called code tags - learn about them, and use them !!! After 33 posts I'm sure that you must have used them before, if at least not seen them used.
As sergeyken intimates, it seems that you want the ready to run code rather than make any effort yourself. Unfortunately a lot of us supposedly experts have a pretty accurate idea of when this is the case.
So, just some friendly advice >>> keep us happy, and ultimately ....... you happy.
So many quick conclusions by the time I respond. Happy to see someone out there to help.
The output I expect out of the exercise is 6 which I gave in the first post and Arun seems to have understood it correct and have responded with what options of the Sort to use. Since I have very less experience working with the DFSORT, I requested him to elaborate the solution and not to post the code.
Finally, I understood what I have to do and will post the code as soon as I complete. Thanks again for all your support.
I do not understand why is subtracted value shifting to 16th position, and also why is key part is cleared down. I understand OVERLAY only edits targeted column not entire record
Your input field is just 4 bytes, but the result from arithmetic operation, in this case is 15 bytes with leading spaces by default, unless you use an EDIT. So the result is consistent with what you have provided in your control statements.
Please go through the DFSORT application programming guide for more details.
DFSORT Application Programming Guide wrote:
An arithmetic expression produces a signed, 31-digit zoned decimal (ZD) result to be edited as specified.
If an Mn, EDIT, or EDxy parameter is not specified, the result is edited using the M0 edit mask.
The default number of digits (d) used for editing is 15 if every term in the expression is one of the following:
v a 1-4 byte BI or FI field
v a 1-8 byte PD field
v a 1-15 byte ZD, FS, CSF, UFF or SFF field
v a decimal constant with 1-15 significant digits.