Example 1: The following RDML program asked the user to input an order number and then prints details of the order and its associated order lines.
GROUP_BY NAME(#ORDERDET) FIELDS(#ORDNUM #CUSTNUM #DATEDUE #ORDLIN #PRODUCT #QUANTITY #PRICE)
L1: REQUEST FIELDS(#ORDNUM)
FETCH FIELDS(#ORDERDET) FROM_FILE(ORDHDR) WITH_KEY(#ORDNUM) NOT_FOUND(L1) ISSUE_MSG(*YES)
SELECT FIELDS(#ORDERDET) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM)
UPRINT FIELDS(#ORDERDET)
ENDSELECT
ENDPRINT
Example 2: If a file called ACCOUNT contains the following fields and data:
|
and if the file is keyed by #COMP, #DIV and #DEPT, then the following RDML program will produce a paginated report with subtotals from this file:
GROUP_BY NAME(#ACCOUNTS) FIELDS((#COMP *TOTLEVEL1 *NEWPAGE) (#DIV *TOTLEVEL2) (#DEPT *TOTLEVEL3) (#EXPEND *TOTAL) (#REVNU *TOTAL))
SELECT FIELDS(#ACCOUNTS) FROM_FILE(ACCOUNT)
UPRINT FIELDS(#ACCOUNTS)
ENDSELECT
ENDPRINT
The following points about the field attributes should be noted:
Refer to Field Attributes and their use for more details.
Note also that LANSA does not sort the data. The data is printed in the same order as it is presented to the UPRINT command. It is the responsibility of the programmer to ensure that the new page and total level attributes "make sense" with regard to the order in which the information is printed.
Note this RDML program could also have been coded as:
SELECT FIELDS(#COMP #DIV #DEPT #EXPEND #REVNU) FROM_FILE(ACCOUNT)
UPRINT FIELDS((#COMP *TOTLEVEL1 *NEWPAGE) (#DIV *TOTLEVEL2) (#DEPT *TOTLEVEL3) (#EXPEND *TOTAL) (#REVNU *TOTAL))
ENDSELECT
ENDPRINT