Page 1 of 1

Counting lines and replacing only header on a file

PostPosted: Wed Feb 18, 2009 4:41 pm
by hrobert09
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.

Re: Counting lines and replacing only header on a file

PostPosted: Thu Feb 19, 2009 3:30 am
by skolusu
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))
/*                           

Re: Counting lines and replacing only header on a file

PostPosted: Thu Feb 19, 2009 8:53 pm
by hrobert09
Thank you very much for your help, the job worked perfectly!