Page 1 of 1

increment 1 column of a flat file

PostPosted: Mon Apr 12, 2010 7:31 pm
by Lightning Lad
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...

Re: increment 1 column of a flat file

PostPosted: Mon Apr 12, 2010 8:13 pm
by Robert Sample
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?

Re: increment 1 column of a flat file

PostPosted: Mon Apr 12, 2010 9:56 pm
by skolusu
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))
//*

Re: increment 1 column of a flat file

PostPosted: Mon Apr 12, 2010 10:34 pm
by Frank Yaeger
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)   
/*