7 97 2 UPRINT Examples

LANSA Technical

7.97.2 UPRINT Examples

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:

Company (#COMP)

Division (#DIV)

Department (#DEPT)

Expenditure (#EXPEND)

Revenue (#REVNU)

01

1

ADM

400

576

"

"

MKT

678

56

"

"

SAL

123

6784

"

2

ADM

46

52

"

"

SAL

978

456

"

3

ACC

456

678

"

"

SAL

123

679

02

1

ACC

843

400

"

"

MKT

23

0

"

"

SAL

876

10

"

2

ACC

0

43

 

 

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:

  • The *NEWPAGE attribute indicates that a new page should be started whenever the company number changes.
  • The *TOTLEVELn attribute indicates the total "level breaks" that are required. In this case totals are required by company, division (within company), and department (within division within company).
  • The *TOTAL attribute indicates the fields that are to be totaled. In this case the expenditure and revenue fields are to be totaled.

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