The first group specified on the Detail fill‑in is the primary group, no matter whether it is named. In all of the examples thus far, only a primary group was defined. Secondary groups require a group name to distinguish them from the primary group and from each other. The keyword GROUP is optional.
For example, assume a report is generated listing all customers and their orders. The customer information is specified in the primary group named <<CUSTINF>>. The order information is specified in a secondary group named <<ORDINF>>. The following screen shows the definition of these two groups.
=> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ 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 ======= = = = = = = = = = = == === ============= 000400 <<CUSTINF>> GROUP _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000500 CUSTOMER.CUSTID _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000600 CUSTOMER.NAME _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000700 CUSTOMER.CITY _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000800 CUSTOMER.STATE _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000900 CUSTOMER.ZIP _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 001000 _________________________ _ _ _ _ _ _ _ _ _ _ __ L01 _____________ 001100 <<ORDINF>> GROUP _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 001000 ORDER.ORDID _ _ _ _ _ _ _ _ _ _ __ 008 _____________ 001100 $DATE('MM/DD/YY',; _ _ _ _ _ _ _ _ _ _ 08 +04 _____________ 001200 DATE=ORDDT,TEM='YYMMDD') _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 001300 _________________________ _ _ _ _ _ _ _ _ _ _ __ L01 _____________ ====== ========= B O T T O M === = = = = = = = = = = == === =============
When primary and secondary groups are defined, the program code must PRODUCE the groups individually. A group name is specified on the PRODUCE statement as report.group. If the group name is omitted, the primary group is produced.
FOR EACH CUSTOMER
PRODUCE CUSTRPT.CUSTINF
FOR EACH ORDER
WHERE ORDER.CUSTID EQ CUSTOMER.CUSTID
PRODUCE CUSTRPT.ORDINF
ENDFOR
ENDFOR
The resulting output provides none, one, or several order details, but the customer information always prints. As you can see, customer number A0090 does not have any orders, while customer number A0130 has two orders. Multiple orders for a single customer print with the single line of customer information.
A0090 INTERNATIONAL BANK CORP NEW YORK NY 100059989 A0130 SUN DIAL CITRUS GROWERS LOS ANGELES CA 902130052 1021 11/08/93 1024 01/04/94 A0150 IMPERIAL BANKCORP NEW YORK NY 100190000 1023 12/24/93 B0230 CHEMICAL MUTUAL FORT WORTH TX 761026102 1013 11/05/94 . . .
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|