HP 3000 Manuals

HP ALLBASE/4GL Report Environment [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Reference Manual Vol. 1

HP ALLBASE/4GL Report Environment 

This subsection provides an overview of the HP ALLBASE/4GL reporting
environment.  Refer to the descriptions of the reports menu screens for a
more detailed explanation of the requirements for completing the reports
screens.

Primary Report File 

The HP ALLBASE/4GL report generator reports on one file referred to as
the primary report file.  The primary report file can be one of the
following:

   *   Indexed KSAM data file.

   *   Serial data file.

   *   HP ALLBASE/SQL table or view.

   *   Select list.

   *   HP TurboIMAGE/iX data set.

The report generator reads records from the primary report file and
prints them in the report in the format you specify.

You can specify selection and sorting criteria to select and sort records
from the primary report file.

The report generator allows you to specify file linkages to read records
from KSAM files or HP TurboIMAGE/iX data sets, other than the primary
report file, during report generation.

Report Output 

HP ALLBASE/4GL can direct the report output to the user's terminal, a
slave printer attached to the terminal, or an MPE/iX formal file
designator.  If the report is directed to a formal file designator, the
stationery type and number of copies specified in HP ALLBASE/4GL can be
overridden with a file equation.

By writing the report to a file designator, it is possible for the
end-user site to customize the output destination for a report, or even
alter the destination for different runs of the same report.

By default, HP ALLBASE/4GL directs the report to device class LP.

Record Selection 

HP ALLBASE/4GL allows you to specify selection criteria for selecting
records for reporting for up to 99 fields on the primary report file.
For each selection field, you can specify a range of acceptable values.
You can express the starting and ending values of the range in terms of
any of the following:

   *   Number or literal.

   *   Numeric or alphanumeric constant.

   *   Variable or calculated item.

   *   Screen field reference.

   *   Scratch-pad field reference.

   *   File record field reference.

   *   Work area field reference.

   *   Communication area field.

You can also use a validation table or validation range for record
selection.

If you specify selection criteria for more than one field in the file
record, the report generator only reports records that satisfy all the
selection criteria.

You can also use an after selection function to implement more complex
record selection if required.

Report Sorting and Control Breaks 

The HP ALLBASE/4GL report generator operates on a line group basis.  It
prints detail line groups of a report in the sequence determined by the
sorting fields specified for the report.  The report generator prints
line groups other than detail lines (for example, total line groups) at
control breaks in the report sequence.  A control break occurs when the
value of a sort field differs from the value of the same field in the
previous record.

Report Sorting.     

You can specify up to eight fields on the primary file record as sort
fields.  The report generator uses the contents of these fields to sort
the records into the required sequence for printing.

You can specify that the sorting order for each field is either ascending
or descending.  The sequence of definition of the sort fields defines the
sort levels.  Level 1 is the highest sort level and level 8 is the lowest
sort level.  The sort levels determine the priority of the sort fields
and the sequence of the sorted output.  For example, consider three sort
fields as follows:

  Level    Field 

    1      Company

    2      Department

    3      Employee

In this case, the report generator sorts the values of the Employee field
within the values of the Department field and then sorts the results
within the Company field.  The end result is a report that lists
departments within each company, and lists the employees in each
department.

You can also specify that no sorting is required.  However you may still
need to specify the sort fields to allow the report generator to print
total line groups at control breaks.

Appendix A lists the HP ALLBASE/4GL collating sequence.

Control Breaks.     

A control break occurs when the value of a sort field changes from one
record to the next.  The level of the sort field causing the control
break determines the level of the control break.

You can define total line groups and subheading line groups for each
control break level.  At a control break, the report generator prints the
corresponding total line group for the old value of the sort field and a
subheading line group for the new value of the sort field.  The report
generator only prints these line groups if you have defined them.

At each control break, the report generator prints the total line group
corresponding to the level of the control break.  For example, if the
control break is on sort level 3 then the report generator prints a T3
line group.

A control break on one sort level automatically initiates control breaks
on all lower sort levels if they exist.  For example, a control break on
level 3 initiates control breaks on levels 4 to 8.

Report Line Types 

The HP ALLBASE/4GL report generator uses a number of different types of
lines.  The line type determines how and when the line is printed.  HP
ALLBASE/4GL treats all lines the same way when you define them.  This
means that a page heading can appear exactly the same as a detail line or
a bottom of page line.

You can define a number of line groups within most line types, and each
group can consist of one or more lines.  This allows you to split a
report line group over several physical lines on the printed report.  For
example, you could use several physical lines to print a banner heading
on each page of a report.  You can also use multiple physical printed
lines in the body of a report if each file record contains more
information than can be accommodated on one physical line.

When the report generator prints a line group, it normally prints all the
lines for the line group.  (You can suppress printing of some or all
lines for a line group by setting the switches *BYPASS or *ENDLINE on.
Refer to Report Processing Logic.)

Each line group is identified by a line type code and a group number.  A
suffix on the line group code identifies the lines within each line
group.  For example, D2.05 refers to line number 5 for line group D2.

The various report line types and groups are:

  Line      Group        Number    Description 
  Type     Numbers      of Lines 

   P          1         1 to 99    Top of page headings

   C          1          1 to 3    Column headings

   B          1          1 to 9    Bottom of page lines

   D          1         1 to 99    Detail lines

   D        2 to 9      1 to 99    Link detail lines

   E        1 to 9      1 to 99    Extra lines

   H        1 to 8      1 to 99    Subheading lines

   T        1 to 8      1 to 99    Subtotal lines

   TF         1         1 to 99    Final total lines

All report line types except type C column heading lines can contain the
following data types:

   *   Literals.

   *   Application titles.

   *   Master titles.

   *   Numeric or alphanumeric constants.

   *   Variables or calculated items.

   *   Screen field references.

   *   Scratch-pad field references.

   *   File record field references.

   *   Work area field references.

   *   Communication area fields.

Type C lines are treated as literals for their entire length.

Each line group is printed when it is required.  The report generator
prints a type D1 line group for every record that is selected from the
primary report file, and prints subheading and subtotal line groups at
every corresponding control break.

The link detail line groups D2 to D9 are available to print the details
read from link files.  The report generator prints these line groups when
they are specified on the file linkages screen.

The PRINT Command 

You can print any line group from a function within a report with the
PRINT command.  When you print a line group with the PRINT command, HP
ALLBASE/4GL treats the line group as a detail line group regardless of
its type.  The PRINT command prints the line group on the next available
space on the report page using the spacing defined for the line group.
For example, the command PRINT P1 does not necessarily start a new page
to print the line group.  The report generator only starts a new page if
you specified a page skip for the line group P1 on the report line header
screen.

File Linkages 

File linkages allow you to access files other than the primary report
file while the report is being printed.  You can specify up to 999 file
linkages per report.  The report generator executes file linkages on a
line group basis.

You can link to a secondary file from any report.  However, the secondary
file must be either a KSAM data file or an HP TurboIMAGE/iX data set.
You cannot link to a secondary HP ALLBASE/SQL table or select list, or a
serial data file.

You can define a file linkage for any print line group.  The link is
initiated by the line group, not a line within the group.  If you define
a file linkage, the report generator searches the link file for a
specific record immediately before printing the line group that initiates
the link.  This allows you to look up and retrieve data from other files
and include that data in the initiating report line group.  The data read
from the link file is available to all lines in the initiating line group
and to any other line group in the report.

You can use a file linkage to print records from the link file.  You can
specify a link print line group and an end-of-link print line group for
each file linkage.  If you specify these line groups, the report
generator prints the link print line group for each successful read of
the link file.  The report generator prints the end-of-link print line
group when any of the following conditions occur:

   *   The end of the link file is reached.

   *   The value in the key field in the record just read does not match
       the value specified for accessing the link file.

   *   A post-read function sets the switch *ENDLINE on.  This switch
       indicates that no more records are to be read from the link file.

You can specify links from a print line group to more than one link file.
If you do specify more than one link, the order of specification
determines the order of processing the links.

You can also specify that the link is critical.  That is, you can specify
that the report generator must find the specified record in the link file
on the first file read.  If the file read fails because the specified
record does not exist or the end of the link file is reached, the report
generator sets the switch *ENDLINE on and does not print the initiating
line group.  If the file read fails for any other reason, HP ALLBASE/4GL
aborts the report.

If you don't specify that a link is critical, and the first file read
fails, HP ALLBASE/4GL clears the file record buffer to spaces so the
report can proceed.

You can also specify selection criteria to be applied to printing of
records from link files.  You must specify the selection criteria
individually for each linkage, even if you have specified a number of
linkages to the same file and you want to apply the same criteria to each
linkage.

Switches and Communication Area Fields 

HP ALLBASE/4GL uses a number of switches and communication area fields
during report generation.

Switches.   

The switches used during report generation are:

   *   *BYPASS The status of this switch indicates whether the current
       physical line in a line group should be printed.  If *BYPASS is
       on, the report generator does not print the current physical line.
       However, the report generator still executes the after-print
       function for the line if one is defined.

   *   *ENDLINE The status of this switch indicates whether processing of
       a line group should continue.  If *ENDLINE is on, The report
       generator stops printing lines within the line group.

Communication Area Fields.     

The communication area fields used during report generation are:

   *   *COUNT(1) to *COUNT(5) Five numeric fields optionally used to
       count the number of times a given line group is printed.

   *   *CROSS(1) to *CROSS(5) Five numeric fields optionally used to
       accumulate across-the-page totals for a physical print line on the
       report page.  These fields are cleared after each physical line is
       printed.

   *   *TOTALS(1) to *TOTALS(16) Sixteen numeric fields used for
       accumulating totals for numeric fields.

   *   *REPORT An alphanumeric field that contains the name of the report
       being executed.

Report Functions 

HP ALLBASE/4GL allows you to execute functions at the following times
while a report is being executed:

   *   At the start of the report.

   *   After each record from the primary report file or link file has
       been tested against each set of selection criteria defined for the
       record.

   *   After each record has been read from a link file.

   *   Before each physical line is printed.

   *   After each physical line is printed.

   *   At the end of the report.

The start-of-report and end-of-report functions can execute any logic
commands except REPORT. The other functions in a report can execute any
logic commands except SCREEN and REPORT. If any function contains a
PROCEED command, HP ALLBASE/4GL terminates the report immediately and
executes the process.

Functions within a report can test or change the status of any of the
report generator switches.  The functions can also read or alter the
values in any of the communication area fields used by the report
generator.

Totalling Facilities 

The report generator uses the 16 communication area fields *TOTALS(1) to
*TOTALS(16) to accumulate totals during report generation.  These fields
are numeric fields and can be used for accumulating totals for any
numeric fields, including other *TOTALS fields, line counter fields
*COUNT(n) and cross add fields *CROSS(n).  You can print the values in
the *TOTALS fields in any report line type except type C print lines.

Totalling Matrix.     

If you define sort levels for a report on the report sorting screen, the
report generator constructs an internal totalling matrix when it executes
the report.  The totalling matrix has 16 columns, with each column
corresponding to one of the totalling fields.  The number of rows in the
matrix is the number of sort levels (n) for the report, plus one
additional row corresponding to final totals for type TF report lines.
The matrix can have a maximum of nine rows.

The report totalling matrix can be represented as follows:

---------------------------------------------------------------------------------
|          |                                                                    |
|          |                            Total Field                             |
|          |                                                                    |
---------------------------------------------------------------------------------
|          |        |        |        |                                |        |
|   Sort   |   1    |   2    |   3    |              ...               |   16   |
|  Level   |        |        |        |                                |        |
|          |        |        |        |                                |        |
---------------------------------------------------------------------------------
|          |        |        |        |                                |        |
|    TF    |        |        |        |                                |        |
|          |        |        |        |                                |        |
---------------------------------------------------------------------------------
|          |        |        |        |                                |        |
|    1     |        |        |        |                                |        |
|          |        |        |        |                                |        |
---------------------------------------------------------------------------------
|          |        |        |        |                                |        |
|    2     |        |        |        |                                |        |
|          |        |        |        |                                |        |
---------------------------------------------------------------------------------
|          |        |        |        |                                |        |
|    .     |        |        |        |                                |        |
|    .     |        |        |        |                                |        |
|    .     |        |        |        |                                |        |
|          |        |        |        |                                |        |
---------------------------------------------------------------------------------
|          |        |        |        |                                |        |
|    n     |        |        |        |                                |        |
|          |        |        |        |                                |        |
---------------------------------------------------------------------------------

During report generation, you can use a function to read the value in any
of the *TOTALS fields.  The values in the *TOTALS fields are:

   *   The values in the row corresponding to the sort level initiating
       the control break if the report generator is printing a type T
       line group.

   *   The values in row number n of the totalling matrix if the report
       generator is not printing a type T line group.

For example, when the report generator is printing a T3 line group, the
*TOTALS fields contain the values from row number 3 of the matrix.

Accumulating Totals.     

While HP ALLBASE/4GL is executing a report, the report generator
accumulates the values of fields requiring totalling into row number n of
the matrix.  When a control break for level n occurs, the report
generator accumulates the level n totals into all higher levels of the
matrix.

At each control break, the report generator processes the totals for the
sort level initiating the control break and all lower sort levels.  If
you have defined any print line groups for this control break, the report
generator prints the line groups.  After the report generator has
processed the control break, it sets the totals for that level and all
lower levels to zero even if no line groups are printed.

Report Calculations.     

You can use functions within reports to modify values in the totals
fields or perform other calculations.  A typical use for these
calculations would be determining percentages or ratios for printing in
the report.

If you use a function that is not associated with a total (type T) print
line type to change the contents of any of the *TOTALS fields, the change
is reflected through all levels of the totalling matrix.

At a control break, the report generator accumulates the totals in the
current row of the totalling matrix into the higher rows before it
processes the current type T line group.  The report generator then
processes the current type T line group, and finally clears the current
level and all lower levels in the totalling matrix.

This means that the effect of changes to the values in the *TOTALS fields
that occur while the type T line group is being processed are restricted
to the current line group.  They do not have any effect on other levels
of the totalling matrix.

As a result, you can use a function associated with a type T line group
to change the contents of the *TOTALS fields without changing other
levels in the totalling matrix.

Since changes to *TOTALS fields that are initiated by processing of a
type T line group don't have any effect outside the line group, you
cannot use a *TOTALS field to accumulate totals for fields on a type T
line group.  The *TOTALS field receives the value for the current line
group, and is cleared immediately after the line group is printed.  If
you do need to accumulate totals for fields on type T lines, you can use
a before print function to accumulate the total into a variable or
scratch-pad field.



MPE/iX 5.0 Documentation