DFSORT number records



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

DFSORT number records

Postby JorenWillems » Fri Mar 16, 2012 2:57 pm

Hi

Is it possible to number records in an output file?
My input file looks like this:

Ryan Phillips
John Terry
Frank Lampard
Steven Gerrard


With DFSORT I want someting like this:

1Ryan Phillips
2John Terry
3Frank Lampard
4Steven Gerrard


Is this possible?

Thx
JorenWillems
 
Posts: 9
Joined: Thu Feb 24, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: DFSORT number records

Postby BillyBoyo » Fri Mar 16, 2012 3:20 pm

Yes, if you want sequence number, no if you want shirt numbers :-)

You want just 0-9, or just an example you can apply elsewhere?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: DFSORT number records

Postby JorenWillems » Fri Mar 16, 2012 3:32 pm

I don't want shirt numbers :)
just a sequence of numbers for example
01
02
03
04
05
06
07
08
09
10
11
12
13
14
etc...
JorenWillems
 
Posts: 9
Joined: Thu Feb 24, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: DFSORT number records

Postby BillyBoyo » Fri Mar 16, 2012 3:50 pm

OK, two answers. First, is with a BUILD, putting the sequence number at the start of the record, as you have shown in your example. 2 is the length, ZD is the type, so can be any sensible length and type for a numeric as described in the manual. The 1,17 takes the rest of the data from the input record and places it after the sequence number.

//SEQNUMB EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC BUILD=(SEQNUM,2,ZD,1,17)
//*
//SORTIN   DD *
SOME RECORDS 01 -
SOME RECORDS 02 -
SOME RECORDS 03 -
SOME RECORDS 04 -
SOME RECORDS 05 -
SOME RECORDS 06 -
SOME RECORDS 07 -
SOME RECORDS 07 -
SOME RECORDS 09 -
SOME RECORDS 10 -


Second is with OVERLAY. Same format, but sequence number appears at the end of the record. No movement of the original data.

With a BUILD and at the front, you can do sequence numbers on a variable-length file and still know where they are afterwards without making the records all the same length (negating the "variable" bit of the file description).

With the OVERLAY you can add a sequence number to the back of the record on a fixed-length file, without shifting the data around (so performing better).

//SEQNUMO EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC OVERLAY=(18:SEQNUM,2,ZD)
//SORTIN   DD *
SOME RECORDS 01 -
SOME RECORDS 02 -
SOME RECORDS 03 -
SOME RECORDS 04 -
SOME RECORDS 05 -
SOME RECORDS 06 -
SOME RECORDS 07 -
SOME RECORDS 07 -
SOME RECORDS 09 -
SOME RECORDS 10 -



Output 1:

01SOME RECORDS 01 -
02SOME RECORDS 02 -
03SOME RECORDS 03 -
04SOME RECORDS 04 -
05SOME RECORDS 05 -
06SOME RECORDS 06 -
07SOME RECORDS 07 -
08SOME RECORDS 07 -
09SOME RECORDS 09 -
10SOME RECORDS 10 -
Output 2:

SOME RECORDS 01 -01
SOME RECORDS 02 -02
SOME RECORDS 03 -03
SOME RECORDS 04 -04
SOME RECORDS 05 -05
SOME RECORDS 06 -06
SOME RECORDS 07 -07
SOME RECORDS 07 -08
SOME RECORDS 09 -09
SOME RECORDS 10 -10
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post