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

Including serial number using SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
madhiolli

New User


Joined: 03 Apr 2007
Posts: 5
Location: India

PostPosted: Thu Jun 28, 2007 1:16 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Jun 28, 2007 1:41 am
Reply with quote

The sort manual refers to that as a sequence number, and it can be added during input or output.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jun 28, 2007 2:31 am
Reply with quote

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
View user's profile Send private message
madhiolli

New User


Joined: 03 Apr 2007
Posts: 5
Location: India

PostPosted: Thu Jun 28, 2007 7:18 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jun 28, 2007 9:25 pm
Reply with quote

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
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 How to split large record length file... DFSORT/ICETOOL 8
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top