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

Special numbering of records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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: 3156
Location: Tucson AZ

PostPosted: Fri Mar 26, 2010 7:20 pm
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top