Adding seq number to changing acct num and record count



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Adding seq number to changing acct num and record count

Postby maijiri » Mon Jun 03, 2013 6:44 pm

I’m a novice when it comes to sync sort. I tried searching for an answer to my question, but it has been to no avail. I’m trying to group/add the same sequence number based on an account number. I got that part working, but I also need to limit the number per group to 7. I need the sequence number to increment at the account number change and when the number of records equals 7. Thanks in advance!

Here is what I have so far.

Input file…

000000000000001
000000000000002
000000000000003
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000005
000000000000006
000000000000007
000000000000008

SORT FIELDS=(132,15,CH,A)
OUTREC IFTHEN=(WHEN=INIT,RECORDS=7,OVERLAY=(3301:SEQNUM,8,ZD,
RESTART=(132,15))),
IFTHEN=(WHEN=GROUP,BEGIN=(3301,8,ZD,EQ,1),PUSH=(3290:ID=8))
OUTFIL BUILD=(1,3300)


Current output:

00000001
00000002
00000003
00000004
00000004
00000004
00000004
00000004
00000004
00000004
00000004
00000004
00000004
00000005
00000006
00000007
00000008


Desired output:

00000001
00000002
00000003
00000004
00000004
00000004
00000004
00000004
00000004
00000005
00000005
00000005
00000005
00000006
00000007
00000008
00000009
maijiri
 
Posts: 5
Joined: Mon Jun 03, 2013 4:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding seq number to changing acct num and record count

 

Re: Adding seq number to changing acct num and record count

Postby NicC » Mon Jun 03, 2013 6:52 pm

Your problem is that you cannot read or you are confused - you say you use Syncsort yet you post in the DFSort part of the forum. I will move to Syncsort.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Adding seq number to changing acct num and record count

Postby maijiri » Mon Jun 03, 2013 7:19 pm

Thanks...sorry about that NicC.
maijiri
 
Posts: 5
Joined: Mon Jun 03, 2013 4:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding seq number to changing acct num and record count

Postby bodatrinadh » Mon Jun 03, 2013 10:26 pm

Try this code...
 
//STEP00 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
000000000000001
000000000000002
000000000000003
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000004
000000000000005
000000000000006
000000000000007
000000000000008
//SORTOUT   DD DSN=&&OUT01,DISP=(,PASS,DELETE),UNIT=SYSDA,
// SPACE=(TRK,(20,5),RLSE)
//SYSIN    DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,15))),
        IFTHEN=(WHEN=GROUP,BEGIN=(81,2,ZD,EQ,+8),
                           END=(81,2,ZD,EQ,+1),PUSH=(83:ID=2))
  SORT FIELDS=(1,15,CH,D,81,2,ZD,D)
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(81,2,ZD,LT,+7,&,83,2,FS,EQ,NUM),
                           END=(81,2,ZD,EQ,+8),PUSH=(01:1,15))
//*                             
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN DD DSN=&&OUT01,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
  SORT FIELDS=(1,15,CH,A)
  OUTREC BUILD=(8,8,72X)


Thanks
-3nadh
User avatar
bodatrinadh
 
Posts: 67
Joined: Thu Jan 12, 2012 9:05 pm
Has thanked: 0 time
Been thanked: 4 times

Re: Adding seq number to changing acct num and record count

Postby maijiri » Mon Jun 03, 2013 11:37 pm

Unfortunately, that didn't work the way I hoped. An example would be if account number 12345 has 22 records, then there should be 4 sets of sequence numbers. 1-7=seq1, 8-14=seq2, 15-21=seq3 and seq4 would only be one record. Your thoughts?
maijiri
 
Posts: 5
Joined: Mon Jun 03, 2013 4:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding seq number to changing acct num and record count

Postby BillyBoyo » Tue Jun 04, 2013 2:32 am

Please don't send Private Messages unless you want to pay a consultancy free.

I don't know how you have RECORDS=7 in WHEN=INIT.

Having got the sequence number, with a RESTART, you need to define a GROUP by testing the sequence number after MOD by seven being equal to one and apply your final sequence number from that GROUP.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Adding seq number to changing acct num and record count

Postby maijiri » Tue Jun 04, 2013 2:42 am

My apologies. First time posting a thread on this site. Thanks for the suggestion. I will research and see if I can get that that to work.
maijiri
 
Posts: 5
Joined: Mon Jun 03, 2013 4:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding seq number to changing acct num and record count

Postby BillyBoyo » Tue Jun 04, 2013 3:39 am

OK. If you can't get all of it, post the problem here. If you get all of it, post the solution, please, as it may help someone with a similar requirement in the future.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Adding seq number to changing acct num and record count

Postby bodatrinadh » Tue Jun 04, 2013 6:13 am

An example would be if account number 12345 has 22 records, then there should be 4 sets of sequence numbers. 1-7=seq1, 8-14=seq2, 15-21=seq3 and seq4 would only be one record. Your thoughts?


And what is the expected output?
Thanks
-3nadh
User avatar
bodatrinadh
 
Posts: 67
Joined: Thu Jan 12, 2012 9:05 pm
Has thanked: 0 time
Been thanked: 4 times

Re: Adding seq number to changing acct num and record count

Postby maijiri » Wed Jun 05, 2013 3:28 am

Unfortunately, I am at my wits end and having difficulty understanding the logic with DIV and MOD operators.

To recap, I need to process a file each day that can have varing numbers of records per account. I need to take that file, group by account number and add a unique sequence number to each group of records. This part I have gotten to work so far.

The second piece of the puzzle is I cannot have more than 7 records per each group. That being the case, I need to regroup and resequence the output. An example would be if acct# 12345 has 200 records, My first sequencing would only give me #1 for all 200 records. The second sequencing would give me sequence numbers 1-29 = 28 groups of 7 and 1 group of 4 (remainding accounts). Here is the code I have so far:

SORT FIELDS=(132,15,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(3301:SEQNUM,8,ZD,
RESTART=(132,15))),
IFTHEN=(WHEN=GROUP,BEGIN=(3301,8,ZD,EQ,1),PUSH=(3290:ID=8))
OUTFIL BUILD=(1,3300)

Any insight anyone can provide on how to solve this would be truly appreciated. Thanks again!!!

Sincerely,

The Novice :o)
maijiri
 
Posts: 5
Joined: Mon Jun 03, 2013 4:08 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post