increment 1 column of a flat file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

increment 1 column of a flat file

Postby Lightning Lad » Mon Apr 12, 2010 7:31 pm

I have a flat file(PS) with the following content

Adam1000
Adam1000
Adam1000
Adam1000
Adam1000
...
...
Adam1000.......9000 times

I want to increment 1000 by 1 for all records making all the rows unique.

Adam1000
Adam1001
Adam1002
Adam1003
Adam1004
...
Is there any way to do all this in a single shot
Please advise...
Lightning Lad
 
Posts: 5
Joined: Thu Jan 21, 2010 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: increment 1 column of a flat file

Postby Robert Sample » Mon Apr 12, 2010 8:13 pm

I want to increment 1000 by 1 for all records making all the rows unique.
This cannot be done -- flat files do not have rows. Ever. They have records, and you started off saying so -- but then you switched to rows. Furthermore, your title indicates you want to increment one column of the flat file. This means you are changing one -- and only one -- byte, since (unlike data bases) a column in a flat file is a single byte.

So are you wanting your records to be
ADAM1000
ADAM1001
.
.
.
ADAM1009
ADAM1000
ADAM1001
...

or something else? You certainly cannot make 9000 records unique by just changing one column of the flat file!

And what have you tired yourself so far? What SORT product are you running at your site? What tools do you have available to help you with this task?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: increment 1 column of a flat file

Postby skolusu » Mon Apr 12, 2010 9:56 pm

Lightning Lad,

Assuming your input is FB recfm and lrecl of 80 , the following DFSORT JCL will give you the desired results

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
ADAM1000                                                         
ADAM1000                                                         
ADAM1000                                                         
ADAM1000                                                         
ADAM1000                                                         
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFOUTLEN=80,                                             
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,4,ZD,START=0,INCR=1)),     
  IFTHEN=(WHEN=INIT,OVERLAY=(05:5,4,ZD,ADD,81,4,ZD,M11,LENGTH=4))
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: increment 1 column of a flat file

Postby Frank Yaeger » Mon Apr 12, 2010 10:34 pm

LL,

Kolusu's job will increment by 1 starting at whatever is originally in 5-8 (so it would work with ADAM1000 or ADAM2000 or ...).

If you just always want to start from 1000 and increment by 1, this DFSORT job will do it:

//S1 EXEC PGM=SORT                               
//SYSOUT DD SYSOUT=*                             
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=... output file                           
//SYSIN DD *                                     
    OPTION COPY                                 
    INREC OVERLAY=(5:SEQNUM,4,ZD,START=1000)   
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post