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 SEQNUM question

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

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Fri Jan 04, 2013 5:42 am    Post subject: Syncsort SEQNUM question
Reply with quote

Hi,

Is there a way, using SYNCSORT, to add sequence numbers to a file, but only increment when a key field changes?

For example, I have this file:
Code:
AAAAA A1
AAAAA A1
BBBBB B1
BBBBB B1
CCCCC C1
CCCCC C1
AAAAA A2
AAAAA A2
AAAAA A2
BBBBB B2
BBBBB B2
CCCCC C2
CCCCC C2
AAAAA A3
...


I'd like to add sequence numbers as such:
Code:
AAAAA A1  1
AAAAA A1  1
BBBBB B1  2
BBBBB B1  2
CCCCC C1  3
CCCCC C1  3
AAAAA A2  4
AAAAA A2  4
AAAAA A2  4
BBBBB B2  5
BBBBB B2  5
CCCCC C2  6
CCCCC C2  6
AAAAA A3  7
...


Thanks in advance for your help,
Mike
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Jan 04, 2013 6:01 am    Post subject: Reply to: Syncsort SEQNUM question
Reply with quote

Yes, have a look at IFTHEN=(WHEN=GROUP with PUSH and ID.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jan 04, 2013 6:11 am    Post subject: Reply to: Syncsort SEQNUM question
Reply with quote

Code:
 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  3 Line(s) not Displayed
 000004 //S1      EXEC PGM=SORT
 000005 //SYSPRINT  DD SYSOUT=*
 000006 //SYSOUT    DD SYSOUT=*
 000007 //SORTIN    DD *
 000008 AAA 111
 000009 AAA 111
 000010 BBB 211
 000011 AAA 112
 000012 AAA 112
 000013 AAA 112
 000014 BBB 212
 000015 BBB 212
 000016 AAA 113
 000017 AAA 113
 000018 AAA 113
 000019 AAA 113
 000020 BBB 213
 000021 BBB 213
 000022 BBB 213
 000023 //SORTOUT   DD SYSOUT=*,
 000024 //             DCB=(RECFM=FB,LRECL=80)
 000025   SORT   FIELDS=COPY
 000026   INREC  IFOUTLEN=80,
 000027          IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))),
 000028          IFTHEN=(WHEN=GROUP,BEGIN(81,8,ZD,EQ,1),PUSH=(9:ID=3))
 000029   OUTFIL BUILD=(1,80)
 000030 //*
 ****** **************************** Bottom of Data ****************************


the result
Code:
 ********************************* TOP OF DATA **********************************
 AAA 111 001
 AAA 111 001
 BBB 211 002
 AAA 112 003
 AAA 112 003
 AAA 112 003
 BBB 212 004
 BBB 212 004
 AAA 113 005
 AAA 113 005
 AAA 113 005
 AAA 113 005
 BBB 213 006
 BBB 213 006
 BBB 213 006
******************************** BOTTOM OF DATA ********************************


should be simple to modify according to Your need
Back to top
View user's profile Send private message
Mikel Terracina

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Fri Jan 04, 2013 10:56 pm    Post subject:
Reply with quote

Thanks Enrico! It works beautifully icon_biggrin.gif
Back to top
View user's profile Send private message
Mikel Terracina

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Sat Jan 05, 2013 12:18 am    Post subject:
Reply with quote

Just out of curiosity, would there be a way to start the sequencing at a number you specify, rather than 1? According to my syncsort manual, it looks like PUSH only starts at 1. Just curious...

Thanks,
Mike
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Sat Jan 05, 2013 1:57 am    Post subject:
Reply with quote

Hi,

you can try something ilke this where the ID starts at 2
Code:
  SORT   FIELDS=COPY                                                 
  INREC  IFOUTLEN=80,                                                 
         IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))),   
         IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(9:ID=3)),       
         IFTHEN=(WHEN=INIT,OVERLAY=(9:9,3,ZD,ADD,+1,EDIT=(TTT)))     


Gerry
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Jan 05, 2013 2:01 am    Post subject: Reply to: Syncsort SEQNUM question
Reply with quote

as far as IBM DFSORT is concerned the CLAUSE
Code:
...SEQNUM,...,START=<start>,INCR=<incr>,...

is supported

should be the same for SYNCSORT
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Sat Jan 05, 2013 2:43 am    Post subject:
Reply with quote

Hi Enrico,

I took the O/P as wanting the ID as starting from a different number and not the SEQNUM.


Gerry
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Jan 05, 2013 2:58 am    Post subject: Reply to: Syncsort SEQNUM question
Reply with quote

icon_redface.gif
Quote:
would there be a way to start the sequencing at a number you specify

I stopped reading after the word sequencing icon_wink.gif
Back to top
View user's profile Send private message
Mikel Terracina

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Sat Jan 05, 2013 3:44 am    Post subject:
Reply with quote

I tried that out and it works great! icon_biggrin.gif
Thanks Gerry!
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 Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts Syncsort - NULL in Integer field chec... nartcr SYNCSORT 4 Thu Oct 06, 2016 6:47 am
No new posts ICETOOL/SYNCSORT - SYSPRINT output nartcr DFSORT/ICETOOL 17 Wed Oct 05, 2016 10:46 pm
No new posts Fault Analyzer - listings question. egrove IBM Tools 4 Thu Aug 11, 2016 5:31 pm


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