Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Mon Nov 26, 2012 9:08 am    Post subject: Syncsort - Count difference between each record's value

Hi,

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.

 Code: X-6839 X-6838 X-6835 K-4987 K-4980 T-3312 T-3311 T-3310 T-3309 T-3308

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

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Mon Nov 26, 2012 12:58 pm    Post subject: Reply to: Syncsort - Count difference between each record's 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.
gcicchet

Senior Member

Joined: 28 Jul 2006
Posts: 1703
Location: Australia

Posted: Tue Nov 27, 2012 3:10 am    Post subject:

Hi Bill,

my understanding is you need to push the value from the previous record to the current record in the group to obtain the difference.

eg.

 Code: X-6839 X-6838 6839   difference is 1 X-6835 6838   difference is 3

Gerry
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Tue Nov 27, 2012 4:56 am    Post subject: Reply to: Syncsort - Count difference between each record's 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.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

 Posted: Wed Nov 28, 2012 7:20 am    Post subject: Reply to: Syncsort - Count difference between each record's Pity to know that this is not (POSSIBLE) easy with Syncsort at least. Going the COBOL way Thanks for all the suggestions.
gcicchet

Senior Member

Joined: 28 Jul 2006
Posts: 1703
Location: Australia

Posted: Wed Nov 28, 2012 7:50 am    Post subject:

Hi,

try this
 Code: //STEP0100 EXEC PGM=SORT                                          //SYSOUT   DD SYSOUT=*                                            //SORTIN   DD *                                                  X-6839                                                            X-6838                                                            X-6835                                                            K-4987                                                            K-4980                                                            L-1234                                                            T-3312                                                            T-3311                                                            T-3310                                                            T-3309                                                            T-3308                                                            //OUT01    DD DSN=&&OUT01,DISP=(,PASS,DELETE),UNIT=SYSDA,        //            SPACE=(TRK,(20,5),RLSE)                            //OUT02    DD DSN=&&OUT02,DISP=(,PASS,DELETE),UNIT=SYSDA,        //            SPACE=(TRK,(20,5),RLSE)                            //SYSIN    DD *                                                          SORT FIELDS=COPY                                                      INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,1))),            IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,+1),                                      PUSH=(21:ID=8,SEQ=8))                                    OUTFIL FNAMES=OUT01,BUILD=(1,28,29,8,ZD,SUB,+1,EDIT=(TTTTTTTT),80:X)   OUTFIL FNAMES=OUT02,BUILD=(1,80)                                    //*                                                                    //STEP0200 EXEC PGM=SORT                                              //SYSOUT   DD SYSOUT=*                                                //SORTJNF1 DD DSN=&&OUT01,DISP=SHR                                    //SORTJNF2 DD DSN=&&OUT02,DISP=SHR                                    //SORTOUT  DD SYSOUT=*                                                //SYSIN    DD *                                                          OPTION COPY                                                            JOINKEYS FILE=F1,FIELDS=(21,16,A),SORTED                              JOINKEYS FILE=F2,FIELDS=(21,16,A),SORTED                              JOIN UNPAIRED,F1                                            REFORMAT FIELDS=(F1:1,6,29,8,F2:1,6)                        OUTREC IFTHEN=(WHEN=(7,8,ZD,EQ,+0),                                  BUILD=(1,6,80:X)),                                         IFTHEN=(WHEN=(7,8,ZD,GT,+0),                                  BUILD=(1,6,10:17,4,ZD,SUB,3,4,ZD,EDIT=(IIII)))

Gerry
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Wed Nov 28, 2012 12:30 pm    Post subject: Reply to: Syncsort - Count difference between each record's 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.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

 Posted: Wed Nov 28, 2012 3:33 pm    Post subject: Reply to: Syncsort - Count difference between each record's Gerry, I will try it and come back.....thanks. Bill, I was just expressing my views and did not hurt anybody....did I? Thanks.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Wed Nov 28, 2012 3:58 pm    Post subject: Reply to: Syncsort - Count difference between each record's 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.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Wed Nov 28, 2012 9:28 pm    Post subject:

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.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

 Posted: Thu Nov 29, 2012 9:29 am    Post subject: Reply to: Syncsort - Count difference between each record's Hi Gerry, tried the solution given by you and got expected results...thank you very much.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

 Posted: Thu Nov 29, 2012 9:34 am    Post subject: 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 Thank for all your time and effort.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

 Posted: Thu Nov 29, 2012 9:37 am    Post subject: 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.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Thu Nov 29, 2012 9:17 pm    Post subject:

Hello,

Then maybe you should find employment in an organizaton that uses DFSORT.

 Quote: I feel that SYNCSORT lacks many good features when compared to DFSORT
I suspect that (from your perspective) DFSORT has the "feature" of always having someone who will do your work for you . . .

 Quote: we always end-up doing it in a lengthy way than a simpler solution.
Nearly everything can be done with either product with about the same amount of effort.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Get value from 2nd record and PUSH it... ashokakash JCL & VSAM 1 Wed Oct 17, 2018 11:41 am Process only last key record in a fil... Naveen.katkuri24 DFSORT/ICETOOL 8 Tue Oct 09, 2018 9:39 am SYNCSORT keep MIN/MAX record Cloink SYNCSORT 16 Mon Sep 17, 2018 3:00 pm Merge two files and sum up the count ... preeti6 JCL & VSAM 6 Thu Sep 06, 2018 10:57 am Sort card to find duplicates, without... anand1204 DFSORT/ICETOOL 15 Fri Aug 31, 2018 12:13 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us