Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Special numbering of records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Fri Mar 26, 2010 6:10 pm    Post subject: Special numbering of records
Reply with quote

Hi,

I have the following request:

I have an array of NAMEs (about 70-80 different NAMEs), each NAME can be represented an unknown number of times. I need to add a sequence number to each row containing the same NAME, but the seqnum must only be incremented each 5th row. When a new NAME is encountered, the seqnum must be reset. The output should be a single file with the NAME and the seqnum. Example:

Code:

NAME1  1
NAME1  1
NAME1  1
NAME1  1
NAME1  1
NAME1  2
NAME1  2
NAME1  2
NAME1  2
NAME1  2
NAME1  3
NAME1  3
NAME2  1
NAME2  1
NAME2  1
NAME2  1
NAME2  1
NAME2  2
NAME3  1
NAME3  1
NAME4  1
NAME4  1
NAME4  1
NAME4  1
NAME4  1
NAME4  2
NAME4  2
NAME4  2


How can I do this using ICETOOL?
Back to top
View user's profile Send private message

Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Fri Mar 26, 2010 7:10 pm    Post subject:
Reply with quote

Nevermind - I solved it myself now ;-)

If anyone want to know how, just say so - I'll be happy to post the solution here.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Mar 26, 2010 7:20 pm    Post subject:
Reply with quote

Claes Norreen wrote:
Nevermind - I solved it myself now ;-)

If anyone want to know how, just say so - I'll be happy to post the solution here.
Please do, thank you......
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Fri Mar 26, 2010 7:27 pm    Post subject:
Reply with quote

The trick is to use START and INCR of the SEQNUM keyword, and then cut the last digit:
Code:

  SORT FIELDS=(1,5,CH,A)                                       
  OUTREC OVERLAY=(7:SEQNUM,15,ZD,START=10,INCR=2,RESTART=(1,5))
  OUTFIL FNAMES=OUT,OVERLAY=(21:X)                     
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Mar 30, 2010 12:33 pm    Post subject:
Reply with quote

Hi,

Can you please explain how the above sort works - like what does START,INCR and RESTART works here.

Thanks.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Tue Mar 30, 2010 1:56 pm    Post subject:
Reply with quote

Hi,

Given the input I posted, the SEQNUM,15,ZD adds a 15 digit sequence number it in position 7. The sequence number starts at 10 (START) and is incremented by 2 (INCR) for each record. However when the key (in position 1 to 5) breaks (RESTART), the sequence number is reset (to 10, which is the starting number in this case). After the OUTREC OVERLAY, this is how it looks:
Code:

----+----1----+----2----+
NAME1 000000000000010
NAME1 000000000000012
NAME1 000000000000014
NAME1 000000000000016
NAME1 000000000000018
NAME1 000000000000020
NAME1 000000000000022
NAME1 000000000000024
NAME1 000000000000026
NAME1 000000000000028
NAME1 000000000000030
NAME1 000000000000032
NAME2 000000000000010
NAME2 000000000000012
NAME2 000000000000014
NAME2 000000000000016
NAME2 000000000000018
NAME2 000000000000020
NAME3 000000000000010
NAME3 000000000000012
NAME4 000000000000010
NAME4 000000000000012
NAME4 000000000000014
NAME4 000000000000016
NAME4 000000000000018
NAME4 000000000000020
NAME4 000000000000022
NAME4 000000000000024


The OUTFIL OVERLAY then clears position 21, that is, cuts the last digit of the sequence number, and you're done. :-)

/Claes
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Mar 30, 2010 11:15 pm    Post subject:
Reply with quote

Hi Claes,

Thanks for detailed explaination.

This is awesome. icon_smile.gif
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts MXG - Processing Compressed DB2 SMF r... vasanthz All Other Mainframe Topics 2 Thu May 10, 2018 12:47 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm
No new posts Group changes and numbering the groups Auryn DB2 2 Tue Mar 20, 2018 7:12 pm
No new posts Copy set of records based on condition krish.deepu SYNCSORT 2 Thu Mar 08, 2018 11:39 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us