Counting lines and replacing only header on a file



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

Counting lines and replacing only header on a file

Postby hrobert09 » Wed Feb 18, 2009 4:41 pm

Hi,
I would like to know, if there is a way of storing the number of records of a file in the same file (in a copy of it, I mean).

for example:
input file (FB):
line 1..........xxxxxx
line 2...................
line 3...................
line 300.................

output file (FB):
line 1..........000300
line 2...................
line 3...................
line 300.................

The number should be on the fisrt record at position 67, the length and format are 6,CH.

What I achieved so far, is to have a file with just one record with the number of lines, but I don't understand, how can I use it in another call to ICETOOLS fo replacing the number on the first record of the output file.
I'm reading the info of z/OS DFSORT V1R5 PTF UK90013, especially the part of DATASORT, but I can't find the way, and in any case, I don't know if we have that PTF installed.

What I did for obtaining a file with the number of records is:
//P050      EXEC  PGM=ICEMAN                                           
//SYSOUT    DD    SYSOUT=*                                             
//SORTIN    DD    DSN=input file,DISP=(SHR)
//SORTOUT   DD    DSN=output file,         
//                DISP=(,CATLG,DELETE),                               
//                SPACE=(00006,(005000,005000),RLSE,,),AVGREC=U,       
//                UNIT=(SYSALLDA,01),                                 
//                VOL=(),                                             
//                DATACLAS=,STORCLAS=,MGMTCLAS=,                       
//                DCB=(RECFM=FB,LRECL=00006,BLKSIZE=0)                 
//SYSIN     DD *                                                       
 OPTION COPY                                                           
 OUTFIL REMOVECC,NODETAIL,                                             
 TRAILER1=(COUNT=(M11,LENGTH=6))                                       
/*                                                                     


Is this useful or can be done the entire task with a unique step?
I would kindly appreciate your help.
Thanks in advance.
hrobert09
 
Posts: 2
Joined: Wed Feb 18, 2009 4:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Counting lines and replacing only header on a file

 

Re: Counting lines and replacing only header on a file

Postby skolusu » Thu Feb 19, 2009 3:30 am

hrobert09,

If you want the count of records on the first record then you need to do 2 passes of the data. First count the number of records and then overlay the count on to first record. The following DFSORT JCl will give you the desired results. I assumed that your input file is FB recfm and 80 bytes in LRECL. If your input has different length then change only step0200 to reflect your file length. Do NOT make any changes to step0100

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=your input file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)   
//SYSIN    DD *                                               
  OPTION COPY                                                 
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                       
  TRAILER1=('FCOUNT,C''',COUNT=(M11,LENGTH=6),C'''')           
/*                                       
//STEP0200 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                             
//SYMNAMES DD DSN=&&T1,DISP=SHR
//SORTIN   DD DSN=your input file,DISP=SHR         
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                   
  OPTION COPY                                     
  INREC IFOUTLEN=80,                               
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),     
  IFTHEN=(WHEN=(81,8,ZD,EQ,1),OVERLAY=(67:FCOUNT))
/*                           
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Counting lines and replacing only header on a file

Postby hrobert09 » Thu Feb 19, 2009 8:53 pm

Thank you very much for your help, the job worked perfectly!
hrobert09
 
Posts: 2
Joined: Wed Feb 18, 2009 4:16 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post