View previous topic :: View next topic
|
Author |
Message |
madhiolli
New User
Joined: 03 Apr 2007 Posts: 5 Location: India
|
|
|
|
Hi
I have an input file with record length 59. I need to include a column in the begining of the record which is a serial number.
Example:
Assume i have 3 records in the input file as given below.
AAAAAAA
BBBBBBB
CCCCCC
My output file should be as follows. I assumed the lenght of the serial number to be 4 bytes.
0001AAAAAAA
0002BBBBBBB
0003CCCCCC
Can this be possible using SORT utility? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
The sort manual refers to that as a sequence number, and it can be added during input or output. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
madhiolli,
Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/84)
//SYSIN DD *
OPTION COPY
INREC BUILD=(SEQNUM,4,ZD,1,80)
/*
|
|
|
Back to top |
|
|
madhiolli
New User
Joined: 03 Apr 2007 Posts: 5 Location: India
|
|
|
|
Thanks Frank and William.
Mean while i tried this with OUTREC and INCR option using SORT utility. It works too.
But Frank yours is simplest.
Code: |
OPTION COPY
OUTREC FIELDS=(SEQNUM,04,ZD,START=00000001,INCR=1,
5:1,80)
|
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
My control statement and your control statement are equivalent.
You can use INREC or OUTREC interchangeably in this case.
BUILD= is the same as FIELDS=, although BUILD= is preferred since it can be used for INREC, OUTREC and OUTFIL whereas FIELDS= can only be use for INREC and OUTREC and OUTREC= must be used for OUTFIL.
START=1 and INCR=1 are the defaults, so you don't need to specify START=00000001 and INCR=1, but you can if you want to.
5: is the default in this case, so you don't have to specify it, but you can if you want to. |
|
Back to top |
|
|
|