Page 1 of 1

Need help on writing SUM totals from input

PostPosted: Wed Jun 16, 2010 10:25 pm
by jawaharsmg
Hi,

I have this input as listed below

       C       D       E        F          G      H

----+----1----+----2----+----3----+----4----+----5----+----6
CORPBOND~0001415~0000004~000.282%~0001409~-0000002~000.424%~
EQUITY  ~0000092~0000008~008.695%~0000081~-0000003~011.956%~
GENERAL ~0000002~0000002~100.000%~0000000~-0000000~100.000%~
GOVTBOND~0000196~0000001~000.510%~0000190~-0000005~003.061%~
LTDPART ~0000001~0000001~100.000%~0000000~-0000000~100.000%~
MONEYMKT~0000040~0000014~035.000%~0000038~+0000012~005.000%~
MORTGAGE~0000795~0000143~017.987%~0000652~-0000000~017.987%~
MUNIBOND~0000129~0000090~069.767%~0000062~+0000023~051.937%~
MUTUALFD~0000090~0000000~000.000%~0000082~-0000008~008.888%~
OPTION  ~0000113~0000000~000.000%~0000113~-0000000~000.000%~
RECEIPT ~0000002~0000000~000.000%~0000002~-0000000~000.000%~
UNITS   ~0000009~0000009~100.000%~0000004~+0000004~055.555%~

       C       D       E        F          G      H

I need to include a trailer line with a consolidated total of each column like this

TOTALS     2884      272      9.43%    2633      21    8.70%


The percentage calculation under column E is D/C %

The percentage calculation under column H is (D-G)/C %

Re: Need help on writing SUM totals from input

PostPosted: Wed Jun 16, 2010 10:37 pm
by Frank Yaeger
For output, do you just want the TOTALS record, or do you want the input records and the TOTALS record?

What is the RECFM and LRECL of your input file?

For C, D, F and G, you just want the total - right?

Re: Need help on writing SUM totals from input

PostPosted: Wed Jun 16, 2010 10:41 pm
by jawaharsmg
Frank,

For output, I want the input records as well with the totals trailing.

File structure is FB, LRECL 60

For C, D, F and G, I want the totals and for E & H the percentages out of the computed totals.

Hope this clarifies.

Regards
Jawahar

Re: Need help on writing SUM totals from input

PostPosted: Thu Jun 17, 2010 1:30 am
by Frank Yaeger
Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed you have the DFSORT PTF that supports the ICETOOL MERGE operator. If not, change the MERGE operator to a SORT operator and change the MERGE statement to a SORT statement.

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/60)
//TOT DD DSN=&&TOT,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//***>>>
//***>>> USE MOD FOR //OUT
//***>>>
//OUT DD DISP=MOD,DSN=...   MOD output file (FB/60)
//TOOLIN DD *
MERGE FROM(IN) TO(TOT) USING(CTL1)
COPY FROM(IN) TO(OUT)
COPY FROM(TOT) TO(OUT)
//CTL1CNTL DD *
  INREC OVERLAY=(62:43,8,SFF,TO=ZD,LENGTH=7)
  MERGE FIELDS=(61,1,CH,A)
  OPTION ZDPRINT,EQUALS
  SUM FORMAT=ZD,FIELDS=(10,7,18,7,35,7,62,7)
  OUTREC BUILD=(C'TOTALS',
    10:10,7,ZD,EDIT=(IIIIIIT),
    18:18,7,ZD,EDIT=(IIIIIIT),
    26:((18,7,ZD,MUL,+100000),DIV,10,7,ZD),EDIT=(IIT.TTT),C'%',
    35:35,7,ZD,EDIT=(IIIIIIT),
    43:62,7,ZD,EDIT=(SIIIIIIT),SIGNS=(,-),
    52:(((18,7,ZD,SUB,62,7,ZD),MUL,+100000),DIV,10,7,ZD),
      EDIT=(IIT.TTT),C'%',60:X)
/*


For your input example, OUT will have:

CORPBOND~0001415~0000004~000.282%~0001409~-0000002~000.424%~     
EQUITY  ~0000092~0000008~008.695%~0000081~-0000003~011.956%~     
GENERAL ~0000002~0000002~100.000%~0000000~-0000000~100.000%~     
GOVTBOND~0000196~0000001~000.510%~0000190~-0000005~003.061%~     
LTDPART ~0000001~0000001~100.000%~0000000~-0000000~100.000%~     
MONEYMKT~0000040~0000014~035.000%~0000038~+0000012~005.000%~     
MORTGAGE~0000795~0000143~017.987%~0000652~-0000000~017.987%~     
MUNIBOND~0000129~0000090~069.767%~0000062~+0000023~051.937%~     
MUTUALFD~0000090~0000000~000.000%~0000082~-0000008~008.888%~     
OPTION  ~0000113~0000000~000.000%~0000113~-0000000~000.000%~     
RECEIPT ~0000002~0000000~000.000%~0000002~-0000000~000.000%~     
UNITS   ~0000009~0000009~100.000%~0000004~+0000004~055.555%~     
TOTALS      2884     272   9.431%    2633       21   8.703%     

Re: Need help on writing SUM totals from input

PostPosted: Thu Jun 17, 2010 2:20 am
by jawaharsmg
Hi Frank,

I am seeing these error message while submitting this jcl step

"TOOLIN" INTERFACE BEING USED

MERGE FROM(IN) TO(TOT) USING(CTL1)
STATEMENT DOES NOT BEGIN WITH A VALID OPERATOR
OPERATION COMPLETED WITH RETURN CODE 12

PROCESSING MODE CHANGED FROM "STOP" TO "SCAN" DUE TO OPERATION FAILURE

COPY FROM(IN) TO(OUT)
STATEMENT VALID; NOT PROCESSED DUE TO "SCAN" PROCESSING MODE

COPY FROM(TOT) TO(OUT)
STATEMENT VALID; NOT PROCESSED DUE TO "SCAN" PROCESSING MODE

this is the JCL I am running

//S12   EXEC  PGM=ICETOOL                                       
//TOOLMSG DD SYSOUT=*                                           
//DFSMSG  DD SYSOUT=*                                           
//IN DD DISP=SHR,DSN=TSTT.NVS.PMSDDV20.MATCH.MSD.LIST.CURR.EXTD 
//TOT DD DSN=&&TOT,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//***>>>                                                         
//***>>> USE MOD FOR //OUT                                       
//***>>>                                                         
//OUT DD DISP=MOD,DSN=TSTT.NVS.PMSDDV20.MATCH.MSD.LIST.CURR.EXT1
//TOOLIN DD *                                                   
 MERGE FROM(IN) TO(TOT) USING(CTL1)                             
 COPY FROM(IN) TO(OUT)                                           
 COPY FROM(TOT) TO(OUT)                                         
//CTL1CNTL DD *                                                 
 INREC OVERLAY=(62:43,8,SFF,TO=ZD,LENGTH=7)                     
 MERGE FIELDS=(61,1,CH,A)                                       
 OPTION ZDPRINT,EQUALS                                           
 SUM FORMAT=ZD,FIELDS=(10,7,18,7,35,7,62,7)                     
 OUTREC BUILD=(C'TOTALS',                                       
    10:10,7,ZD,EDIT=(IIIIIIT),                                   
    18:18,7,ZD,EDIT=(IIIIIIT),                                   
    26:((18,7,ZD,MUL,+100000),DIV,10,7,ZD),EDIT=(IIT.TTT),C'%', 
    35:35,7,ZD,EDIT=(IIIIIIT),                                   
    43:62,7,ZD,EDIT=(SIIIIIIT),SIGNS=(,-),                       
    52:(((18,7,ZD,SUB,62,7,ZD),MUL,+100000),DIV,10,7,ZD),       
      EDIT=(IIT.TTT),C'%',60:X)                                 
/*


Please help.

Re: Need help on writing SUM totals from input

PostPosted: Thu Jun 17, 2010 3:07 am
by Frank Yaeger
Since you posted in the DFSORT Forum, I assumed you were using DFSORT. The job works fine with DFSORT's ICETOOL (ICE messages). However, the messages you received (WER messages) indicate you're using Syncsort's SYNCTOOL, not DFSORT's ICETOOL.

I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.

Please post Syncsort questions in the appropriate Forum.

Re: Need help on writing SUM totals from input

PostPosted: Thu Jun 17, 2010 3:33 am
by dick scherrer
Hello,

Not tested, but you might try changing the control statements so they do not begin in col 1. . .

Re: Need help on writing SUM totals from input

PostPosted: Thu Jun 17, 2010 7:12 am
by dick scherrer
Hello,

Suggest you try the alternative Frank provided (coding SORT rather than MERGE) if you have not done so already . . .