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
Adding seq number to changing acct num and record count
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: Adding seq number to changing acct num and record count
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
Regards
Nic
Re: Adding seq number to changing acct num and record count
Thanks...sorry about that NicC.
- bodatrinadh
- Posts: 67
- Joined: Thu Jan 12, 2012 9:05 pm
- Skillset: Mainframe Testing, SyncSort,JCL,SAS.
- Referer: ibmmainframes.com
Re: Adding seq number to changing acct num and record count
Try this code...
Code: Select all
//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
-3nadh
Re: Adding seq number to changing acct num and record count
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?
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Adding seq number to changing acct num and record count
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.
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.
Re: Adding seq number to changing acct num and record count
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.
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Adding seq number to changing acct num and record count
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.
- bodatrinadh
- Posts: 67
- Joined: Thu Jan 12, 2012 9:05 pm
- Skillset: Mainframe Testing, SyncSort,JCL,SAS.
- Referer: ibmmainframes.com
Re: Adding seq number to changing acct num and record count
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
-3nadh
Re: Adding seq number to changing acct num and record count
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
)
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

-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 6011
-
by Robert Sample
View the latest post
Fri Aug 26, 2022 8:42 am
-
-
Finding gaps in history table (slowly changing dimension 2)
by Ron Klop » Wed Jan 27, 2021 2:15 pm » in DB2 - 4
- 2253
-
by enrico-sorichetti
View the latest post
Fri Jan 29, 2021 1:35 am
-
-
- 1
- 1259
-
by willy jensen
View the latest post
Sat Sep 04, 2021 12:51 am
-
-
Sending o/p file's content to spool withot adding extra step
by Misha786 » Tue Jan 12, 2021 6:51 pm » in JCL - 4
- 2032
-
by sergeyken
View the latest post
Tue Jan 12, 2021 11:28 pm
-
-
-
Copy partial record after a string in a record using SORT.
by Esmayeelhusen » Thu May 04, 2023 3:03 pm » in DFSORT/ICETOOL/ICEGENER - 16
- 4266
-
by Esmayeelhusen
View the latest post
Mon May 22, 2023 3:50 pm
-