Summing columns in Easytrieve report
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Application Programming

#1: Summing columns in Easytrieve report Author: rg_nath PostPosted: Mon Oct 12, 2015 4:24 am
    —
Hi,

I am trying to sum the numeric values from input file based on keys and would like to write into Easytrieve report. Below is my sample program details.

Input File:

Code:

**********************
FILE TSTIN           
    CL1   01  03 A   
    CL2   04  03 A   
    CL3   07  03 A   
    CL4   10  03 N 0
    CL5   13  03 N 0
    CL6   16  03 N 0
***********************
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
CT1AAAPPP 10 20 30
CT1AAAPPP 20 30 40
CT1AAAQQQ 10 20 30
CT1AAAQQQ 20 30 50
CT2AAAPPP 30 40 50
CT2BBBPPP 10 20 30
CT2BBBPPP 20 30 40
CT2BBBRRR 40 50 60
CT3BBBRRR 10 20 30
CT3CCCPPP 10 20 30
CT3CCCSSS 50 60 70
CT3CCCSSS 30 40 50
**************************** Bottom of Data ***


The code i have written is:

Code:


 FILE RPT1 PRINTER                                     
*                                                     
 JOB INPUT NULL                                       
*                                                     
    IF EOF TSTIN                                       
      STOP                                             
    END-IF                                             
*                                                     
    GET TSTIN                                         
*                                                     
    DO WHILE NOT EOF TSTIN                             
*                                                     
     PRINT MTBS1                                       
     GET TSTIN                                         
*                                                     
    END-DO                                             
*                                                                   
***********************************************************         
 REPORT MTBS1 PRINTER(RPT1) LINESIZE 132 NOADJUST NODATE NOHEADING -
        TITLESKIP 0                                                 
 SEQUENCE CL1 CL2 CL3                                               
 CONTROL FINAL NOPRINT CL1 NOPRINT CL2 NOPRINT  CL3 NOPRINT         
*                                                                   
    TITLE 1  COL  25 CL1                                             
*                                                                   
    TITLE 2  COL  02 'C1  C2     C3  C4  C5 '                       
*                                                                   
    TITLE 3  COL  02 '--- ---    --- --- ---'                       
*                                                                   
*                                                                   
    LINE 01 COL 02 CL2 -                                             
            COL 06 CL3 -                                             
            COL 10 CL4 -                                             
            COL 14 CL5 -                   
            COL 18 CL6                     
  AFTER-BREAK. PROC                       
   IF LEVEL EQ 03                         
   DISPLAY NEWPAGE                         
   END-IF                                 
  END-PROC                                 


i have got the output below:

Code:

1                        CT1
  C1  C2     C3  C4  C5     
  --- ---    --- --- ---     
  AAA PPP     10  20  30     
              20  30  40     
  AAA QQQ     10  20  30     
              20  30  50     
1                        CT2
  C1  C2     C3  C4  C5     
  --- ---    --- --- ---     
  AAA PPP     30  40  50     
  BBB PPP     10  20  30     
              20  30  40     
  BBB RRR     40  50  60     
1                        CT3
  C1  C2     C3  C4  C5     
  --- ---    --- --- ---
  BBB RRR     10  20  30
  CCC PPP     10  20  30
  CCC SSS     50  60  70
              30  40  50
1                       


But, i would like the report like below:

Code:

1                        CT1
  C1  C2     C3  C4  C5     
  --- ---    --- --- ---   
  AAA PPP     30  50  70   
      QQQ     30  50  80   
                           
  TOTAL       60 100 150   
                           
1                        CT2
  C1  C2     C3  C4  C5     
  --- ---    --- --- ---   
  AAA PPP     30  40  50   
  BBB PPP     30  50  70   
      RRR     40  50  60   
                           
  TOTAL      100 140 180   
                               
1                        CT3   
  C1  C2     C3  C4  C5       
  --- ---    --- --- ---       
  BBB RRR     10  20  30       
  CCC PPP     10  20  30       
      SSS     80 100 120       
                               
  TOTAL      100 140 180       
                               
1                             


For every CL3, i want to sum CL4, CL5 and CL6 and print in report based on CL1 & CL2 keys. Finally i would like to print total values for each control break. i have tried with several options in Easytrieve report section but no luck. Please help me to get report in required format.

Note: This is sample program for your reference and i would like to know the parameters in Easytrive report to get this summation based on keys.

-Nath

#2:  Author: William Collins PostPosted: Mon Oct 12, 2015 7:19 am
    —
You have this:

Code:
 JOB INPUT NULL                                       
*                                                     
    IF EOF TSTIN                                       
      STOP                                             
    END-IF                                             
*                                                     
    GET TSTIN                                         
*                                                     
    DO WHILE NOT EOF TSTIN                             
*                                                     
     PRINT MTBS1                                       
     GET TSTIN                                         
*                                                     
    END-DO


I've suggested this to you before, but, seriously, don't you think this is simpler?:

Code:
 JOB INPUT TSTIN
     PRINT MTBS1


You further make life difficult by using the TITLE statement for your column headings. Have your looked at how to use HEADING?

It looks like you want a SUMMARY report, not a line report with totals (which you aren't printing anyway).

#3:  Author: rg_nath PostPosted: Mon Oct 12, 2015 7:41 am
    —
Hi William,

Thanks for information. Yes, i have to put a simple PRINT statement to read a file. I will use HEADING instead of TITLE as you told along with SUMMARY SUMCTL DTLCOPY at REPORT statement. I hope this will give me exact report.

-Nath.

#4:  Author: William Collins PostPosted: Mon Oct 12, 2015 10:15 am
    —
It won't. To see what I mean by a summary report, look at the CONTROL Reports section of the manual, specifically the SUMFILE option. The file generated by that will contain all the low-level break totals, from which you can produce your report.

The report you want can't contain any detail lines, so work instead off the SUMFILE. You can in the end "dummy out" the existing report in the JCL and still use the features of the REPORT statement to generate the SUMFILE so you don't have to do the SORT and accumulation yourself (which is your other choice).

#5:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 12, 2015 12:04 pm
    —
rg_nath,

It baffles me as to why you always want to re-invent the wheel with your own read logic. You have been advised about the efficient use of automatic input and synchronized File Processing(SFP) more than once and yet you choose the round about method of reading the file on your own. bonk



MVSFORUMS.com -> Application Programming


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group