Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Syncsort - Count difference between each record's value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

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

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 icon_exclaim.gif

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.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Nov 26, 2012 12:58 pm    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

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.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Nov 27, 2012 3:10 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Nov 27, 2012 4:56 am    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

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.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Nov 28, 2012 7:20 am    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

icon_rolleyes.gif Pity to know that this is not (POSSIBLE) easy with Syncsort at least. Going the COBOL way icon_lol.gif

Thanks for all the suggestions.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Wed Nov 28, 2012 7:50 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 28, 2012 12:30 pm    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

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.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Nov 28, 2012 3:33 pm    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

Gerry, I will try it and come back.....thanks.

Bill, I was just expressing my views and did not hurt anybody....did I?

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 28, 2012 3:58 pm    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Nov 28, 2012 9:28 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 29, 2012 9:29 am    Post subject: Reply to: Syncsort - Count difference between each record's
Reply with quote

Hi Gerry, tried the solution given by you and got expected results...thank you very much.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 29, 2012 9:34 am    Post subject:
Reply with quote

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 icon_redface.gif

Thank for all your time and effort.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 29, 2012 9:37 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Nov 29, 2012 9:17 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us