IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort - Count difference between each record's value


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Nov 26, 2012 12:58 pm
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: 1702
Location: Australia

PostPosted: Tue Nov 27, 2012 3:10 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 27, 2012 4:56 am
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
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: 1702
Location: Australia

PostPosted: Wed Nov 28, 2012 7:50 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 28, 2012 12:30 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 28, 2012 3:58 pm
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

Moderator Emeritus


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

PostPosted: Wed Nov 28, 2012 9:28 pm
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
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
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
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

Moderator Emeritus


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

PostPosted: Thu Nov 29, 2012 9:17 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top