Page 1 of 1

Calculate Sum of a particluar Field and Total no of Counts

PostPosted: Tue May 22, 2012 5:28 pm
by shirazi2589
Hello Everybody,

I have an input file having the following records
H20120518PAYROLL GENERAL DEDUCTIONS INTERFACE (FOR FLEET)               
   DR 000D987654320120518AUTDED      7500                               
   DR 0000004142820120518AUTDED      7500                               
   DR 0000016455620120518AUTDED      7500                               
   DR 0000028910520120518AUTDED      7500                               
   DT 0000029233620120518AUTDED         0                 2012
   DT 0000029317420120518AUTDED         0                 2012
   DR 0000030188520120518AUTDED      7500                               
   DR 0000033678920120518AUTDED      7500                               
   DR 0000052472620120518AUTDED      7500                               
   DR 0000054812820120518AUTDED      7500                               
   DT 0000055116820120518AUTDED         0                 2012
   DT 0000057157320120518AUTDED         0                 2012
   DR 0000057167020120518AUTDED      7500                               
   DR 0000471907920120518AUTDED      7500                               
   DT 0000770401020120518AUTDED         0                 2012
   T  GENL DEDUCT INTERFACE       (*****)         

I want the same output file same as input file but i want to have a sum General Deductions( values are 7500, 0 ) as shown above in place of (******)
NB : (*****) are not present in the input file, i had included here so as to show where i want my sum.

Also in the trailer record (to the right of sum we've obtained' we also want the total no of records.
eg :
T  GENL DEDUCT INTERFACE              (******)      Count = 152


H: HEader Record
T: Trailer Record

Can i have a sort card to achieve the above functionality

Re: Calculate Sum of a particluar Field and Total no of Coun

PostPosted: Tue May 22, 2012 7:51 pm
by dick scherrer
Hello,

What have you tried so far? Where are you stuck?

We try to help people with queations and/or problems, but we try to NOT actually do the work for them.

Suggest you look into generating a TRAILER for the total. This is in the Syncsort manual as well as there are several topics in the Syncsort part of our forum.

Re: Calculate Sum of a particluar Field and Total no of Coun

PostPosted: Wed May 23, 2012 10:48 am
by shirazi2589
Hi dick scherrer,
I wrote the following Sort Card to obtain the above mentioned requirement.
Here is the sort card i wrote

//SYSIN    DD *                                                         
  SORT FIELDS=(7,11,ZD,A)                                               
  OUTFILE REMOVECC,                                                     
  HEADER1=('H',DATENS=(4MD),'PAYROLL GENERAL DEDUCTIONS INTERFACE',     
          ' (FOR FLEET)'),                                             
  TRAILER1=(4:'T',7:'GENL DEDUCT INTERFACE',                           
            32:TOT=(32,10,ZD,TO=ZD,LENGTH=10),75:'COUNT =',             
            82:COUNT=(M10,LENGTH=10))                                   
/*


The ouput file is getting created and works fine. But there is a small glitch mentioned below
Below is the output file format :
TERFACE    0000562500                                 COUNT =        89


The sum field i.e 0000562500 is getting created thats good. but i want the leading zeros to be removed.
I tried using the EDIT field, with M10 format but it gives me syntax error.
the error i got was
OUTFIL STATEMENT : SYNTAX ERROR
SYNCSMF CALLED BY SYNCSORT; RC=0000

when i tried using the below sort card
//SYSIN    DD *                                                         
  SORT FIELDS=(7,11,ZD,A)                                               
  OUTFILE REMOVECC,                                                     
  HEADER1=('H',DATENS=(4MD),'PAYROLL GENERAL DEDUCTIONS INTERFACE',     
          ' (FOR FLEET)'),                                             
  TRAILER1=(4:'T',7:'GENL DEDUCT INTERFACE',                           
            32:TOT=(32,10,ZD,TO=ZD,M10,LENGTH=10),75:'COUNT =',         
            82:COUNT=(M10,LENGTH=10))                                   
/*           


What do i do to remove the leading zeros?

Re: Calculate Sum of a particluar Field and Total no of Coun

PostPosted: Wed May 23, 2012 1:58 pm
by bodatrinadh
Hi shirazi2589,

You can try this code...

//STEP1    EXEC PGM=SORT                                           
//SYSPRINT DD SYSOUT=*                                             
//SYSOUT DD SYSOUT=*                                               
//SORTOUT DD SYSOUT=*                                             
//SORTIN   DD *                                                   
H20120518PAYROLL GENERAL DEDUCTIONS INTERFACE (FOR FLEET)         
   DR 000D987654320120518AUTDED      7500                         
   DR 0000004142820120518AUTDED      7500                         
   DR 0000016455620120518AUTDED      7500                         
   DR 0000028910520120518AUTDED      7500                         
   DT 0000029233620120518AUTDED         0                 2012     
   DT 0000029317420120518AUTDED         0                 2012     
   DR 0000030188520120518AUTDED      7500                         
   DR 0000033678920120518AUTDED      7500                         
   DR 0000052472620120518AUTDED      7500                         
   DR 0000054812820120518AUTDED      7500                         
   DT 0000055116820120518AUTDED         0                 2012     
   DT 0000057157320120518AUTDED         0                 2012     
   DR 0000057167020120518AUTDED      7500                         
   DR 0000471907920120518AUTDED      7500                         
   DT 0000770401020120518AUTDED         0                 2012         
   T  GENL DEDUCT INTERFACE       (*****)                               
//SYSIN    DD *                                                         
  OMIT COND=(4,1,CH,EQ,C'T',OR,1,1,CH,EQ,C'H')                         
  INREC OVERLAY=(32:32,10,UFF,TO=ZD)                                   
  SORT FIELDS=COPY                                                     
  OUTFILE REMOVECC,OUTREC=(01,31,32:32,10,ZD,M10,42,38,10X),           
  HEADER1=('H',DATENS=(4MD),'PAYROLL GENERAL DEDUCTIONS INTERFACE',     
           ' (FOR FLEET)'),                                           
  TRAILER1=(4:'T',7:'GENL DEDUCT INTERFACE',TOT=(32,10,ZD),             
           'COUNT=',COUNT=(M10,LENGTH=10))   


Your output :-

H20120523PAYROLL GENERAL DEDUCTIONS INTERFACE (FOR FLEET)         
   DR 000D987654320120518AUTDED      7500                         
   DR 0000004142820120518AUTDED      7500                         
   DR 0000016455620120518AUTDED      7500                         
   DR 0000028910520120518AUTDED      7500                         
   DT 0000029233620120518AUTDED         0                 2012   
   DT 0000029317420120518AUTDED         0                 2012   
   DR 0000030188520120518AUTDED      7500                         
   DR 0000033678920120518AUTDED      7500                         
   DR 0000052472620120518AUTDED      7500                         
   DR 0000054812820120518AUTDED      7500                         
   DT 0000055116820120518AUTDED         0                 2012   
   DT 0000057157320120518AUTDED         0                 2012   
   DR 0000057167020120518AUTDED      7500                         
   DR 0000471907920120518AUTDED      7500                         
   DT 0000770401020120518AUTDED         0                 2012   
   T  GENL DEDUCT INTERFACE          75000 COUNT=        15       


Note:- Above code is tested on SYNCSORT FOR Z/OS 1.4.0.1R version.