The example described in 4.4.1 Using the DEF_LINE Command can be altered to place the company number into the report heading and start a new page on change of company number like this:

     GROUP_BY    NAME(#ACCOUNT) FIELDS(#COMP #DIV 
            #DEPT #EXPEND #REVNU)
DEF_HEAD    NAME(#HEADING) FIELDS(#COMP)
            TRIGGER_BY(#COMP)
DEF_LINE    NAME(#DETAILS) FIELDS(#DIV #DEPT
            #EXPEND #REVNU)
 
SELECT      FIELDS(#ACCOUNT) FROM_FILE(ACCOUNTS)
PRINT       LINE(#DETAILS)
ENDSELECT
ENDPRINT

This would now produce a 2 page report that looked something like this:
 
       Company 01                               
       Division    Department   Expenditure   Revenue            
            1                ADM               400              576             
            1                MKT                678                56             
            1                SAL                 123             6784             
            2                ADM                 46                52             
            2                SAL                 978              456             
            3                ACC                456               678             
            3                SAL                 123              679             
 
       Company 02                                                
       Division    Department   Expenditure   Revenue            
            1               ACC                 843            400             
            1               MKT                  23                0             
            1               SAL                 876              10             
            2               ACC                    0              43            

Note how the DEF_HEAD command indicated that field #COMP was to be printed in the report heading area and the heading was to be "triggered" by change of #COMP (i.e.: a new page started when the company number changes).

In fact, the TRIGGER_BY parameter may be strictly incorrect in this situation. If company 01 had more records that would fit on 1 page the report would look something like this:
 
  Company 01                                                 Page 1
    Division    Department   Expenditure   Revenue            
         1               ADM               400               576             
         1               MKT               678                 56             
         1                SAL               123              6784             
         2               ADM                46                  52             
         2                SAL               978                456             
         3                ACC              456                 678             
         3                SAL               123                 679             
 
                                                                        Page 2
    Division    Department   Expenditure   Revenue           
         4              ADM                400              576             
         4              MKT                 678                56             
         4               SAL                 123            6784             
         5              ADM                  46                52             
         5               SAL                 978              456             
         5               ACC                456              678             
         5               SAL                 123              679             
 
   Company 02                                                 Page 3
    Division    Department   Expenditure   Revenue            
         1                ACC                843             400             
         1                MKT                 23                 0             
         1                SAL                876               10             
         2                ACC                   0               43             
 

Note how the company number is not printed on page 2. This is because the DEF_HEAD line is only to be "triggered" by change of company number. Between page 1 and 2 the company number did not change, so the DEF_HEAD command details are not printed. If however, the DEF_HEAD command was specified as:

     DEF_HEAD    NAME(#HEADING) FIELDS(#COMP) 
            TRIGGER_BY(#COMP *OVERFLOW)

which indicates that the DEF_HEAD command should be triggered by change of company number or page overflow, then "Company 01" would also print on the start of page 2.

  • No labels