You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

All the following examples of report production use a file called ACCOUNTS that contains the following records. It is assumed that the file is ordered (i.e.: keyed) by company, division and department.

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

Note that although all the examples deal with one file only, for the sake of simplicity, there is no restriction on the number of files that can be accessed by or printed by an RDML program.

The simplest type of report that can be produced is a straight listing from all or part of a file.

To list all of the ACCOUNTS file, all that is required is:

     DEF_LINE    NAME(#ACCOUNT) FIELDS(#COMP #DIV #DEPT 
            #EXPEND #REVNU)
SELECT      FIELDS(#ACCOUNT) FROM_FILE(ACCOUNTS)
PRINT       LINE(#ACCOUNT)
ENDSELECT
ENDPRINT

This would produce a report that looked something like this:

CompanyDivisionDepartmentExpenditureRevenue
011ADM400576
011MKT67856
011SAL1236784
012ADM4652
012SAL978456
013ACC456678
013SAL123679
021ACC843400
021MKT230
021SAL87610
022ACC043

Of course, this example can be changed in various ways to only print part of the file - such as only the records for a selected company:

     DEF_LINE    NAME(#ACCOUNT) FIELDS(#COMP #DIV #DEPT 
            #EXPEND #REVNU)
REQUEST     FIELDS(#COMP)
SELECT      FIELDS(#ACCOUNT) FROM_FILE(ACCOUNTS)
            WITH_KEY(#COMP)
PRINT       LINE(#ACCOUNT)
ENDSELECT
ENDPRINT

Or, only records where the difference between expenditure and revenue is less than a specified amount:
DEF_LINE    NAME(#ACCOUNT) FIELDS(#COMP #DIV 
            #DEPT #EXPEND #REVNU)
DEFINE      FIELD(#MAXLOSS) REFFLD(#REVNU) 
            LABEL('Allowable loss')
REQUEST     FIELDS(#MAXLOSS)
SELECT      FIELDS(#ACCOUNT) FROM_FILE(ACCOUNTS) 
            WHERE('(#REVNU - #EXPEND) *LT #MAXLOSS')
PRINT       LINE(#ACCOUNT)
ENDSELECT
ENDPRINT
 
This final example uses the *ONCHANGE field attribute to only print the company number when it changes, rather than on every line:
DEF_LINE    NAME(#ACCOUNT) FIELDS((#COMP *ONCHANGE) 
            #DIV #DEPT #EXPEND #REVNU)
SELECT      FIELDS(#ACCOUNT) FROM_FILE(ACCOUNTS)
PRINT       LINE(#ACCOUNT)
ENDSELECT
ENDPRINT
 
This would produce a report that looks something like this:
 
     Company    Division    Department   Expenditure   Revenue 
       01          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  
       02          1           ACC              843       400  
                   1           MKT               23         0  
                   1           SAL              876        10  
                   2           ACC                0        43  
 

  • No labels