May I please know how to calculate difference between records from an input file? 1st position is the key, 2nd position has '-' followed by numeric value.
I would like to calculate difference between each record within each group and write somewhere in same line in output or just difference alone
Output-1:
Code:
X-6839
X-6838 difference is 1
X-6835 difference is 3
K-4987
K-4980 difference is 7
T-3312
T-3311 difference is 1
T-3310 difference is 1
T-3309 difference is 1
T-3308 difference is 1
Achievable with SYNCSORT FOR Z/OS V1.3.2.2R? Please help. Thanks.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You use WHEN=GROUP, PUSH the amount (which will be that of the first record in the group). When you process each record in the group, you will have current amount and the amount from the first record.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Thanks Gerry, I didn't look closely-enough at the example. It is something of an arbitrary choice, as really I'd think the best way would be to have the minimum and maximum value for a group and take the difference between them. However, I suppose it depends...
So, for each record, a GROUP with no BEGIN/END but instead just RECORDS=2, push the number and the group-identifier. You need a bit of a left/right thing going on. Try to follow this one.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Ramsri,
You come here for Sort solutions, don't provide everything asked, and then go off and do it in Cobol anyway.
You were a trailer record away with your previous (similar) request and seem to have abandoned that, went for Zellers Congruent in Cobol instead of a table of dates in Sort,
How about next time we just ignore your Sort requests and let you go straight for Cobol? Saves us wasting time on it.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Ramsri,
If you answer all the questions, you'll get more out of it. I had the workings of a solution for your Monday/Sunday dates, if you could answer. You were close with your NULLOFL, and I have a different solution, and then it sort of quietly went away. Where you want something "complicated" for Sort, then the answer is going to be "complicated" - these are relative terms. If you are worried about "complications", then why not just go for Cobol to start with?
If you go for Cobol, don't do Zeller's, choose a date for a known day, get the integer of value of that date, the integer value of the day that you want, and do a divide with a remainder. All the "hard" work is done by the function doing the integer of the date.
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Hello,
Quote:
I was just expressing my views and did not hurt anybody....did I?
Possibly only yourself. . .
You continue to demonstrate that you prefer to have things given to you rather than work on the solutions yourself. . . .
Had you actually worked thru several of your earlier projects rather than just grab what was given and use it, i suspect you could now be more self-reliant.
Quote:
Pity to know that this is not (POSSIBLE) easy with Syncsort at least.
No, it is quite possible. Things are usually more difficult when one is trying to learn. They will remain difficult if one is unwilling to invest the time/effort to learn.
Bill, I studied Zeller's congruence from wikipedia and have written COBOL version of it after working it out till I understood it. I did not put it here....sorry. Regarding NULLOFL, I probably never tried to understand how it works
I feel that SYNCSORT lacks many good features when compared to DFSORT and we always end-up doing it in a lengthy way than a simpler solution. This extra effort of coding drives me to COBOL which I am more convenient with but in the background I still practice SORT solutions too.