MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Summing columns in Easytrieve report

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
rg_nath
Beginner


Joined: 03 Jul 2015
Posts: 23
Topics: 7

PostPosted: Mon Oct 12, 2015 4:24 am    Post subject: Summing columns in Easytrieve report Reply with quote

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
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon Oct 12, 2015 7:19 am    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message
rg_nath
Beginner


Joined: 03 Jul 2015
Posts: 23
Topics: 7

PostPosted: Mon Oct 12, 2015 7:41 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon Oct 12, 2015 10:15 am    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Mon Oct 12, 2015 12:04 pm    Post subject: Reply with quote

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
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group