Previous Topic: Suppressing Print of Specific Column HeadingsNext Topic: Generating the Bottom Line


Defining Column Headings for Secondary Groups

The Column Heading fill‑in can only define headings for the columns in the primary group. You can specify column headings for secondary group fields as literals on the Detail fill‑in.

For example, assume that a report is generated that prints information from every CUSTOMER row along with every ORDER for the customer. The primary group consists of the customer information. A secondary group consists of the order information. Headings for the secondary group are specified as part of the primary group. The secondary group headings or literals print when the customer information is output.

The Detail fill‑in contains the specifications shown in the following example:

=> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL : RPT DETAIL DEFN. RPT CUSTRPT (001) TEST SYS: DOC DISP          Field Name, Literal,      Sort Break Function Column          Function, or               L A L S I T M M A H W Command Arithmetic Expression      V / V K N O A I V D ID Tab Edit Pattern                                     L D L P D T X N G G TH ‑‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑‑ ‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑ ====== =========== T O P ======= = = = = = = = = = = == === ============= 000200 <<PRIMARY>> GROUP          _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000300 CUSTOMER.NAME              _ _ _ _ _ _ _ _ _ U __ ___ _____________ 000400 CUSTOMER.CITY              _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000500 CUSTOMER.STATE             _ _ 1 2 _ _ _ _ _ _ __ ___ _____________ 000600 CUSTOMER.OPEN$             _ _ _ _ _ _ _ _ _ U __ ___ Z,ZZZ,ZZ9.99 000700 'Ord #'                    _ _ _ _ _ _ _ _ _ _ 05 012 _____________ 000800 'Ord Date'                 _ _ _ _ _ _ _ _ _ _ 08 019 _____________ 000900 '_____'                    _ _ _ _ _ _ _ _ _ _ 05 012 _____________ 001000 '________'                 _ _ _ _ _ _ _ _ _ _ 08 019 _____________ 001200 ________________________   _ _ _ _ _ _ _ _ _ _ __ L02 _____________ 001300 <<ORDER>>                  _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 001400 ORDER.ORDID                _ _ _ _ _ _ _ _ _ _ 05 012 _____________ 001500 $DATE('MM/DD/YY',;         _ _ _ _ _ _ _ _ _ _ 08 019 _____________ 001600 DATE=ORDDT,TEM='YYMMDD')   _ _ _ _ _ _ _ _ _ _ __ ___ _____________ ====== ========= B O T T O M === = = = = = = = = = = == === =============

Notice how the TAB values line up the headings Ord # and Ord Date with the ORDER.ORDID field and $DATE function in the secondary group. The underscores, which also line up with the headings, provide a clear separation between the headings and the data. The TAB value L02 as the last specification in the primary group forces a blank line between the heading and the data from the secondary group.

In the program, the PRODUCE statement prints the primary and secondary groups. The secondary group prints multiple times based on the number of outstanding orders. The following code shows the pertinent segment:

FOR EACH CUSTOMER
   PRODUCE CUSTRPT.PRIMARY
   FOR EACH ORDER 
       PRODUCE CUSTRPT.ORDER
   ENDFOR
ENDFOR

This program sample assumes that every customer has at least one order. Since this might not be a valid assumption, you can specify the secondary group heading information as another secondary group. Then printing the headings for the order details is controlled based on whether there are any orders. To define headings as a secondary group, precede the heading detail with a group label, as shown in the following:

=> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL : RPT DETAIL DEFN. RPT CUSTRPT (001) TEST SYS: DOC DISP          Field Name, Literal,      Sort Break Function Column Function, or               L A L S I T M M A H W Command Arithmetic Expression      V / V K N O A I V D ID Tab Edit Pattern                                     L D L P D T X N G G TH ‑‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑‑ ‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑ ====== =========== T O P ======= = = = = = = = = = = == === ============= 000100 <<PRIMARY>> GROUP          _ _ _ _ _ _ _ _ _ U __ ___ _____________ 000200 CUSTOMER.CUSTID            _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000300 CUSTOMER.CUSTNAME          _ _ _ _ _ _ _ _ _ U __ ___ _____________ 000400 CUSTOMER.CITY              _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000500 CUSTOMER.STATE             _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000600 CUSTOMER.OPEN$             _ _ _ _ _ _ _ _ _ U __ ___ Z,ZZZ,ZZ9.99 000700 <<ORDHEAD>> GROUP          _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000800 'Ord #'                    _ _ _ _ _ _ _ _ _ _ 05 012 _____________ 000900 'Ord Date'                 _ _ _ _ _ _ _ _ _ _ 08 019 _____________ 001000 '_____'                    _ _ _ _ _ _ _ _ _ _ 05 012 _____________ 001100 '________'                 _ _ _ _ _ _ _ _ _ _ 08 019 _____________ 001200                             _ _ _ _ _ _ _ _ _ _ __ L02 _____________ 001300 <<ORDER>> GROUP            _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 001400 ORDER.ORDID                _ _ _ _ _ _ _ _ _ _ 05 012 _____________ 001500 $DATE('MM/DD/YY',;         _ _ _ _ _ _ _ _ _ _ 08 019 _____________ 001600 DATE=ORDDT,TEM='YYMMDD')   _ _ _ _ _ _ _ _ _ _ __ ___ _____________ ====== ========= B O T T O M === = = = = = = = = = = == === =============

The code is modified to include an IF construct to test a flag, FIRST‑FLAG, defined in working data. Based on the value of the flag, the secondary group heading is output as needed:

FOR EACH CUSTOMER
   PRODUCE CUSTRPT.PRIMARY
   SET FIRST‑FLAG = TRUE
   FOR EACH ORDER
       WHERE ORDER.CUSTID EQ CUSTOMER.CUSTID
       IF FIRST‑FLAG
          PRODUCE CUSTRPT.ORDHEAD
          SET FIRST‑FLAG = FALSE
       ENDIF
       PRODUCE CUSTRPT.ORDER
   ENDFOR
ENDFOR

The following screen is a sample of the output:

Id      Name                     City          State         Zip Code A0120 International Bank Corp  New York     NY            100059989 A0130 Sun Dial Citrus Grove    Los Angeles CA            902130052        Ord#            Ord Date        1021            11/08/93        1024            01/04/94 A0150 Imperial Bankcorp        New York     NY            100190000        Ord#            Ord Date        1023            10/24/93 A0230  Chemical Mutual          Fort Worth   TX            761026102        

Ord#            Ord Date        1013            11/05/94