Page 1 of 1

Count the no. of records and update the trailer record

PostPosted: Thu Dec 13, 2012 3:18 pm
by Pratap metta
Hi All,
I have a file which contains header records , detail record and trailer record.15th position in the file contains 'A' for header record , 'L' for trailer record and 'M','V' or 'P' for detail records.
Now my requirement is to count the no. of records based up on 'M' ,'V' and 'P'( which is on 15th position) and update these counts on the trailer record.
My trailer record looks some thing like this

OT08LV12122012L8 00003400000000003200000000000000000000000000000200000

total four counts will be there in the triler record the first one from position 19 to 24 is the count of total no. of records i.e (count of 'M' + 'V' + 'P' records) and from position 31 to 36 is the count of 'V' records and from position 37 to 42 is the count of 'P' records and the last one from positon 61 to 66 is the count of 'M' records.

Please help me how can we acheive this using DFSORT or ICETOOL.
Thanks in advance !!!

Re: Count the no. of records and update the trailer record

PostPosted: Thu Dec 13, 2012 8:34 pm
by dick scherrer
Hello and welcome to the forum,

What really needs to be done is to correct the process that creates the file to write the counts when the file is created. It is a complete waste of resources to proceed as you have been told to do . . .

Re: Count the no. of records and update the trailer record

PostPosted: Thu Dec 13, 2012 9:32 pm
by NicC
How does the 15th position of the FILE contain all those values at one time? Did you perhaps mean each record has a record type indicator in column 15?

Re: Count the no. of records and update the trailer record

PostPosted: Thu Dec 13, 2012 9:40 pm
by dick scherrer
15th position in the file contains 'A' for header record , 'L' for trailer record and 'M','V' or 'P' for detail records.

Ahhh - i believe that is what was posted . . . :?

d

Re: Count the no. of records and update the trailer record

PostPosted: Thu Dec 13, 2012 10:07 pm
by skolusu
What is the LRECL and RECFM of the input and output dataset?

Please post the complete sysout of the following job which helps us to determine the level of DFSORT you have.
//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
 //*

Re: Count the no. of records and update the trailer record

PostPosted: Tue Dec 18, 2012 2:42 pm
by Pratap metta
Hi Skolusu/Nicc,
yes each record has different indicator in coloumn 15 ('A' for header record , 'L' for trailer record and 'M','V' or 'P' for detail records).
Now if I add detail records to the file then the corresponding counts in the trailer record should be updated.
Please find the below complete sysout...
H RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
0 C5-K76982 C6-K90026 C7-K58148 C8-K67572 E9-K60824 C9-BASE   E5-K76585
0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 10:06 ON TUE DE
    SORT FIELDS=COPY                                                   
H RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
0 C5-K76982 C6-K90026 C7-K58148 C8-K67572 E9-K60824 C9-BASE   E5-K76585
0 ICEAM1 INVOCATION ENVIRONMENT IN EFFECT - ICEAM1 ENVIRONMENT SELECTED
1 PARMLIB OPTIONS WERE MERGED WITH INSTALLATION MODULE DEFAULTS         
0 BA5009ST.STEP0100.        , INPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
0 MAIN STORAGE = (MAX,6291456,6278238)                                 
0 MAIN STORAGE ABOVE 16MB = (6217182,6200798)                           
0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,
0 OPTIONS: SIZE=6291456,MAXLIM=6291456,MINLIM=450560,EQUALS=N,LIST=Y,ERE
0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=FULL ,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=
0 OPTIONS: RESALL=16384,RESINV=0,SVC=109 ,CHECK=N,WRKREL=Y,OUTREL=Y,CKPT
0 OPTIONS: TMAXLIM=6291456,ARESALL=16384,ARESINV=0,OVERRGN=65536,CINV=Y,
0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITC
0 OPTIONS: HIPRMAX=0      ,DSPSIZE=2500,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAMI
0 OPTIONS: NULLOUT=RC0                                                 
0 OPTIONS: DYNAPCT=10 ,MOWRK=Y                                         
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTOUT         
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTIN           
ICE751I 1 EF-BASE   F0-K66717 E8-K79103               
ICE090I 0 OUTPUT LRECL = 80, BLKSIZE = 80, TYPE = FB   
ICE055I 0 INSERT 0, DELETE 0                           
ICE054I 0 RECORDS - IN: 0, OUT: 0                     
ICE173I 0 NO RECORDS FOR THE SORTOUT DATA SET - RC=0   
ICE052I 0 END OF DFSORT


Code'd

Re: Count the no. of records and update the trailer record

PostPosted: Tue Dec 18, 2012 3:01 pm
by BillyBoyo
Next time please ensure that the message references are included on all the pasted lines.

Re: Count the no. of records and update the trailer record

PostPosted: Wed Dec 19, 2012 1:15 am
by skolusu
Pratap metta,

You did NOT answer my question about LRECL and RECFM. Assuming that your LRECL=80 and RECFM=FB, use the following DFSORT JCL which will give you the desired results.

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
----+----1----+----2----+----3----+----4----+----5----+-
              A                                         
              MA01                                     
              PA02                                     
              MA03                                     
              MA04                                     
              VA01                                     
              VA02                                     
              L                                         
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1000')),       
  IFTHEN=(WHEN=(15,1,CH,EQ,C'M'),OVERLAY=(82:C'1')),   
  IFTHEN=(WHEN=(15,1,CH,EQ,C'P'),OVERLAY=(83:C'1')),   
  IFTHEN=(WHEN=(15,1,CH,EQ,C'V'),OVERLAY=(84:C'1'))     
                                                       
  OUTFIL BUILD=(1,80),                                 
  IFTRAIL=(HD=YES,TRLID=(15,1,CH,EQ,C'L'),             
  TRLUPD=(19:TOT=(81,1,ZD,M11,LENGTH=6),               
          31:TOT=(84,1,ZD,M11,LENGTH=6),               
          37:TOT=(83,1,ZD,M11,LENGTH=6),               
          61:TOT=(82,1,ZD,M11,LENGTH=6)))               
//*                                                     

Re: Count the no. of records and update the trailer record

PostPosted: Wed Dec 19, 2012 1:04 pm
by Pratap metta
Hi skolusu,

It worked exactly as it should have. Thanks a ton for your help.

Pratap Metta