'Renumber' a sequence number on a file



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

'Renumber' a sequence number on a file

Postby Barry Balsa » Mon Mar 12, 2012 2:42 pm

Hi

I would like to be able to use DFSORT to overlay a sequence number on every record in a file but so that the sequence only increments every 100 records. There are no obvious key fields that can be used to denote each 100th record however there is already a sequence number on the file that follows this rule - so effectively I just need to 'renumber' the file.

The example below shows what I require however I have modified it to show the sequence number changing every 5 records to keep the example simple.

E.g input file

4529123       00000047
3212321       00000047
3920192       00000047
1293940       00000047
2093029       00000047
1929303       00000052
1939482       00000052
1928392       00000052
1288333       00000052
AB2123L       00000052
S1S4444       00000023
3939191       00000023
41AS020       00000023
3020202       00000023
3983929       00000023


The desired output based on the above input file would be:

4529123       00000001
3212321       00000001
3920192       00000001
1293940       00000001
2093029       00000001
1929303       00000002
1939482       00000002
1928392       00000002
1288333       00000002
AB2123L       00000002
S1S4444       00000003
3939191       00000003
41AS020       00000003
3020202       00000003
3983929       00000003


Ideally I would like to be able to specify a starting value for the sequence number but it is not essential.


Many Thanks
Baz
Barry Balsa
 
Posts: 1
Joined: Mon Mar 05, 2012 10:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: 'Renumber' a sequence number on a file

Postby Frank Yaeger » Mon Mar 12, 2012 11:21 pm

Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(15,8),PUSH=(15:ID=8))
/*
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