Page 1 of 1

Adding number to records

PostPosted: Wed Oct 26, 2011 1:02 am
by Puffe
Hello,

In my file I want to add a sequence number to all records but I want them to start with no 1 and grouped by the key.
The file i fixed blocked and recordlength is 10.
The key is the first five digits.

File consists of
12222ABCDE
12233ABDDE
12233JONES
12233ROSIE
13331HELLO
13331RONAN

The result should be
12222ABCDE0001
12233ABCDE0001
12233JONES0002
12233ROSIE0003
13331HELLO0001
13331RONAN0002

Anyone know how I accomplish this ?

Regards,

Mikael

Re: Adding number to records

PostPosted: Wed Oct 26, 2011 1:15 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
12222ABCDE
12233ABDDE
12233JONES
12233ROSIE
13331HELLO
13331RONAN
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(11:SEQ=4))
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Re: Adding number to records

PostPosted: Wed Oct 26, 2011 1:19 am
by Puffe
Thanks !

I'll try it when I get to work tomorrow