0% found this document useful (0 votes)
95 views

Ch7 Printer File Functions

This chapter introduces the Print File (PRTFIL) and Print Object (PRTOBJ) functions used to produce reports in COOL:2E. The document provides details on defining a simple Print File function to produce a report listing all horses in the database, including the total number of horses and total value. It describes specifying an access path to retrieve horse records in alphabetical name order, adding relevant virtual fields, and modifying the report layout. The goal is to produce a basic report of all horses as preparation for a more advanced subsequent report.

Uploaded by

Maran Ganapathy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Ch7 Printer File Functions

This chapter introduces the Print File (PRTFIL) and Print Object (PRTOBJ) functions used to produce reports in COOL:2E. The document provides details on defining a simple Print File function to produce a report listing all horses in the database, including the total number of horses and total value. It describes specifying an access path to retrieve horse records in alphabetical name order, adding relevant virtual fields, and modifying the report layout. The goal is to produce a basic report of all horses as preparation for a more advanced subsequent report.

Uploaded by

Maran Ganapathy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Chapter

7
The Report Functions

This chapter introduces the two functions used to produce reports. These are:

The Print File (PRTFIL) Function

The Print Object (PRTOBJ) Function

You will use these functions to define the two following reports:

a simple report of all the horses recorded in the


database.

a more complex report showing all the horses in the


database and for each horse, a list of the races in
which the horse competed.

COOL:2E Tutorial TUT 7–1


Introduction to the Print File Function

Introduction to the Print File Function


In this topic you will learn how to define a Print File
function to produce a simple report of all the horses
recorded in the database.

New terms introduced

PRTFIL (Print File) function

CNT (count) function field

CUR (current report format) report context

NXT (next report format) report context

New displays introduced

Edit Report Design

Display Report Formats

Edit Report Format Details

Objectives You will be producing a report that lists all the horses
recorded in your database. In addition, the report will
give the total number of horses recorded and the total
value of all the horses. The following steps are involved:

1. Create a Print Horses function based on the HORSE


file. The function will require the creation of a RSQ
(resequence) access path to retrieve records in
Horse name order.

2. Specify the Total horse value and Total number of


horses function fields on the report design.

3. Modify the layout of the report, as required.

4. Generate and compile the source for the access path


and the report.

5. Test the implemented function.

TUT 7–2 COOL:2E Tutorial


Introduction to the Print File Function

Defining the Starting from the Edit Functions panel for the HORSE
Print File file, specify the Print Horses function. A Print File
Function (PRTFIL) function is defined the same way as other
functions. Type Print Horses for the Function name,
PRTFIL for the Function type, and ? in the access path
field to view a list of existing access paths as shown.

Press Enter. The Edit File Details panel displays as a


result of entering ? for the Access path.

Specifying a Use the Edit File Details panel for the HORSE file to
New Access Path create a new access path that will cause the report to
print horse details in alphabetical order by Horse name,
rather than in Horse code order. To achieve this,
specify a new access path of type RSQ called Horse
name order.

COOL:2E Tutorial TUT 7–3


Introduction to the Print File Function

Type RSQ for the access path type, Horse name


order for the Access path name, and Z to zoom into
the access path as shown.

Press Enter.

Adding Virtual Remember that virtual entries are not automatically


Entries to the added to an access path. As a result, you need to add
Access Path the Dam name, Dam Date of birth, Sire name , and Sire
Date of birth virtual fields explicitly so they will appear
on the report you are designing.

TUT 7–4 COOL:2E Tutorial


Introduction to the Print File Function

Type V against the access path format as shown.

Press Enter to display the Virtualize Access Path panel.

Press Enter twice to validate and confirm the virtual


entries displayed. Notice the message at the bottom of
the Edit Access Path Details panel.

COOL:2E Tutorial TUT 7–5


Introduction to the Print File Function

Edit Access You used the Edit Access Path Details panel earlier in
Path Details this tutorial to specify a RSQ access path. You will use
the same process here to specify a new key order on
the access path format.

Type Z against the access path format as shown.

Press Enter.

Specifying On the Edit Access Path Format Entries panel, specify


Access Path the new key order for the RSQ access path. The initial
Details key order default is the same as for the default
Retrieval index access path.

The New Key Specify an alternative key order. For this type of access
Order path, you can choose any field except a virtual field as
a key field. Use Horse name as the key.

TUT 7–6 COOL:2E Tutorial


Introduction to the Print File Function

In the Key no. column, clear the 1 next to Horse code


and type 1 against Horse name.

Press Enter. Press F3 twice to exit.

Generating and At the Edit File Details panel, request batch generation
Compiling the and compilation for the newly defined access path
New Access Path using the J option.

Type J next to the Horse name order RSQ access path


as shown.

COOL:2E Tutorial TUT 7–7


Introduction to the Print File Function

Press Enter to request generation.

Selecting the Now that you have created the required access path,
Access Path select it for use with the Print Horses function.

Type X to select the Horse name order access path as


shown.

Press Enter.

TUT 7–8 COOL:2E Tutorial


Introduction to the Print File Function

The Report After you select the access path, COOL:2E creates the
Design Print Horses function and returns to the Edit Functions
panel. From here you can display the report layout. To
do so, type S against the function as shown.

Press Enter.

The Default Initially, the report layout will look like the one shown
Report Layout here.

COOL:2E Tutorial TUT 7–9


Introduction to the Print File Function

The default layout is made up of the following formats.

The page header format at the top contains a title (Print


Horses) plus information such as the date and page
number. The header format is repeated on each page
of the printed report. An End of report format is placed
at the end of the report design.

A heading format and corresponding total format is


provided for each Level break. For example, for each
key of the based-on access path there is a heading
and total format. If the access path has a unique key,
the number of level breaks is one less than the number
of keys. In this case, the access path does not have a
unique key. Since there is one key level, one heading
format is provided that, by default, has Horse name as
an output field.

The detail format contains the subfile records from the


based-on access path. It is shown on the Print Horses
report layout between the Horse name heading and
Horse name total formats. All the fields from the access
path are available in this format. The key field (Horse
name) is hidden by default because it already appears
on the heading format.

You can modify the report layout the same way you
modified the device designs of the earlier functions.
The editors for the report layout and the panel design
are very similar. However, a report is by default 132
characters across and extends vertically past the
bottom of the panel. You can press the Roll Up key to
roll the panel by half a panel at a time.

TUT 7–10 COOL:2E Tutorial


Introduction to the Print File Function

Displaying the The report formats are shown on the Display Report
Report Formats Formats panel. To access this panel, press F17 from
the device design (report layout).

• The Top of page format (TOP) enables you to


define fields to be printed at the top of each page
in addition to the Standard report header (HDR).
This format is empty by default.
• The First page format (1PG) can be used to add
title information to the beginning of the report. This
format is empty by default.
• The Level heading format (1HD) contains fields
appropriate to the key level; in this case, Horse
name. By default, this format prints before the first
detail within a level break.
• The Detail line format (RCD) contains the records
from the access path on which the Print File
function is based. By default, this format is printed
for every record read. This format cannot be
dropped, only hidden.
• The Level total format (2TL) contains fields
appropriate to the key level. By default, this format
is printed after the last detail record or subtotal
within a level break.
• The Final total format (ZTL) contains totals of all
previous total levels. By default, this format contains

COOL:2E Tutorial TUT 7–11


Introduction to the Print File Function

only the constant Final totals; you can add your


own function fields to provide totals.

Dropping In this step you will remove the Horse name heading
Formats from a and total formats. To remove a format, you can either
Report Design hide it or drop it completely. If you hide a format it will
still be logically present. In this example, you will drop
both formats completely.

Type ’-’ against the two Horse name formats as shown.

Press Enter. Notice the D in the Hide fmt column for


the two formats you dropped.

TUT 7–12 COOL:2E Tutorial


Introduction to the Print File Function

Adding Function In this step, you will add two function fields to the Final
Fields totals format (ZTL).

Type Z against Final totals format as shown.

Press Enter to display the Edit Report Format Details


screen for the Final totals format.

Press F19 to add a function field to this format using


the Edit Device Function Fields panel.

COOL:2E Tutorial TUT 7–13


Introduction to the Print File Function

Displaying To display existing function fields, type ? for Function


Existing field as shown.
Function Fields

Press Enter

All fields defined in your model are displayed, including


the two function fields you defined for the Edit Race
and Entries function (EDTTRN).

To define two new function fields, press F10.

TUT 7–14 COOL:2E Tutorial


Introduction to the Print File Function

Defining New The first new function field, Total horse value, will
Function Fields provide a total of all the Horse value fields on the detail
format. A function field of type SUM is used for this
purpose. Recall that you used a function field of this
type previously to calculate theTotal Number of finishers
in a race.

The second new function field, Total number of horses,


will calculate the total number of horses recorded. It will
count the number of occurrences of Horse code field
on the detail format. A function field of type CNT can be
used for this purpose.

There are two ways to define a function field:

• as a REF field based on the field you wish to sum


or count
• as a new field with input parameter(s) specified
separately.
You will use the REF field method to define the Total
horse value function field. However, you cannot use this
method for the Total number of horses function field
since the CNT field must be numeric and the field you
are counting is alphanumeric (CDE).

Define the Total horse value and Total number of


horses function fields as shown.

COOL:2E Tutorial TUT 7–15


Introduction to the Print File Function

Press Enter

Specifying When you pressed Enter, the two new function fields
Function were created. Press Roll Up twice to view the two new
Parameters function fields.

The Total horse value function field is now fully defined.


However, you must still specify the field used to arrive
at the Total number of horses function. Type P next to
this function field as shown to specify its parameters.

Press Enter.

The Default As mentioned previously, the function field itself is the


Parameters output parameter. In this step, you need to specify an
input parameter, which is the field to be counted. In this
case, the Horse code field is the input parameter.

You can specify function parameters in two different


ways. These can either be individual fields or an
access path from which you select individual fields. In
this example, you will specify the parameter as an
individual field.

TUT 7–16 COOL:2E Tutorial


Introduction to the Print File Function

Type the parameter details as shown.

Press Enter.

The parameter usage defaults to input. You can check


this for yourself by typing Z against Horse code on the
Edit Function Parameters panel.

Press F3 to exit.

COOL:2E Tutorial TUT 7–17


Introduction to the Print File Function

Selecting the You have finished defining the two new function fields.
Function Fields You must now select them to appear on the Final totals
format.

Type X against Total Horse value.

Press Enter.

Confirming the The Edit Action - Function Details window will prompt
Function Details you to confirm details of the function parameters. This
panel shows the contexts from which the values of the
parameters will be taken: NXT (next report format) and
CUR (current report format).

The values for the Horse value parameter are taken


from the CUR context. This context corresponds to the
format upon which the processing of the function field
takes place (the Detail line format). The NXT context
corresponds to the format that follows the Detail line. In
this case, the NXT context is the Final totals format.

TUT 7–18 COOL:2E Tutorial


Introduction to the Print File Function

Press Enter to confirm the parameters. Press F13 to


return to the report device design.

Adding the Total The Total horse value function field is now present on
Number of the Final totals format. To add the other function field
Horses Function position the cursor (❚) on the Final totals format as
Field shown.

Press F19 to add the Total number of horses function


field.

COOL:2E Tutorial TUT 7–19


Introduction to the Print File Function

Type Total Number of horses in the Field name field


as shown.

Press Enter.

Confirming the COOL:2E automatically provides defaults for the


Parameters parameters and contexts. In this case you need only
accept them.

Press Enter to accept the parameters and return to the


report device design.

TUT 7–20 COOL:2E Tutorial


Introduction to the Print File Function

Exercise Both function fields are now present on the Edit Report
Format Details panel of the Final totals format. Check
this yourself by pressing F17 from the report device
design and typing Z against the Final totals format on
the Display Report Formats panel. Press F13 to return
to the report device design.

The Report The report layout should now look like the one below,
Design with with the function fields displayed on the Final totals
Function Fields format. The words Final totals are a constant and can
be removed.

Completing the In this step, to make the report easier to read, you will
Report specify a blank line between records and hide the
Horse code, Dam code, and Sire code fields. In
addition, you will change the Horse name field from
hidden to output. By default, the Horse name field is
hidden because it was originally present on the Horse
name header format. Since the Horse name header
format has been dropped, it now makes sense to have
the Horse name appear on the Detail line format.

Place the cursor (❚) on the Horse code field as shown.

Press F5.

COOL:2E Tutorial TUT 7–21


Introduction to the Print File Function

Type the options as shown; namely, type Y for Blank


line between records, type O against Horse name, and
type H against Horse code, Dam Horse code, and Sire
Horse code to hide these fields on the report.

Press Enter. Note the changes in the Ovr column as a


result of your entries. Press F3 to return to the device
design.

TUT 7–22 COOL:2E Tutorial


Introduction to the Print File Function

The Modified The report device design should now look like the one
Report Device shown below. Since you have hidden some fields on
Design the Detail format, the design no longer exceeds the 132
character size limit.

The Completed Update the report device design by moving fields and
Report Layout changing labels and label spacings until the design
meets your needs. Here’s an example.

Note that to produce this design you will need to drop


the Top of Page format (TOP) and the First Page

COOL:2E Tutorial TUT 7–23


Introduction to the Print File Function

Saving the Save the changes by accepting the defaults and


Report Device pressing Enter.
Design

Generating and You have now finished specifying the Print Horses
Compiling the function. Type J next to this function on the Edit
Function Functions panel and press Enter to request batch
generation of the Print File and program that will
implement the function.

Finally, compile the generated source for the function


and the access path. Press F17 to access the Display
Services Menu and select the Submit model create
request (YSBMMDLCRT) option. Be sure to note the
implementation name (member) of the Print Horses
function so you can call it in the next step.

Running Your When the Print Horses function has successfully


Program compiled, try it out by calling the program from a
command line. For example,

call myaspfr ’’

Following is an example of the resulting report showing


data you entered earlier using the Edit Horse program.

Your company name here Print Horses

Horse M/F Value D of B

Bonfire M 5000.00 2/01/83


Dam:
Sire:

Faithful Dobbin F 3500.00 5/31/86


Dam:
Sire:

Pegasus M 3000.00 6/23/92


Dam: Faithful Dobbin 5/31/86
Sire: Bonfire 2/01/88

Final totals

Total number of horses : 3


Total horse value . . . : 11500.00

** END OF REPORT **

Use the OS/400 Work with Spooled Files (WRKSPLF)


command to view or print your report.

COOL:2E Tutorial TUT 7–25


Introduction to the Print Object Function

Introduction to the Print Object Function


You will learn how to embed a Print Object function into
the existing Print File function to produce a more
detailed report.

New terms introduced

PRTOBJ (Print Object) function

QRY (Query) access path

New displays introduced

Edit Device Structure

Objectives At this point, you have created a function to print a list


of all the horses stored in the database. A more useful
report might also list the races for which each horse
has been entered. To produce such a report, you need
to combine records from the RACE ENTRY file with the
existing Print Horses function. You can achieve this
using a Print Object function. Use the following steps to
do this.

1. Specify a Print Object function based on the RACE


ENTRY file.

2. Define a Query access path to be used with the


RACE ENTRY file.

3. Combine the Print Object function with the Print File


function and specify the parameters to be passed
between them.

4. Generate and compile the new Print Horses function.

5. Test the program.

TUT 7–26 COOL:2E Tutorial


Introduction to the Print Object Function

Defining the To define a Print Object function, start from the Edit
Print Object Database Relations panel and go to the Edit Functions
Function panel on the RACE ENTRY file.

Type F against RACE ENTRY as shown.

Press Enter.

COOL:2E Tutorial TUT 7–27


Introduction to the Print Object Function

Adding a Print Specify the Print Object function by typing Print Race
Race Entries Entries for the function name, PRTOBJ for the function
Function type, and ? to display the available access paths as
shown.

Press Enter to display the Edit File Details panel.

Specifying a The Edit File Details panel shows the existing access
Query Access paths for the RACE ENTRY file. You will create a new
Path access path for the Print Race Entries function.

To produce the desired report, the records in the RACE


ENTRY file need to be processed in order by Horse
name. To do this, you need to create an access path
keyed on the Horse name field; however, Horse name
is a virtual field on the RACE ENTRY file. In order to
use a virtual field as a key, you need to create a query
(QRY) access path. In addition, since virtual entries are
not automatically included on an access path, you need
to add them explicitly.

TUT 7–28 COOL:2E Tutorial


Introduction to the Print Object Function

Specify a QRY access path named Entries by Horse


name and type V against it as shown.

Press Enter to view the virtual entries that are available


for inclusion on the access path; namely, Horse name
and Jockey name.

Press Enter twice to validate and confirm the inclusion


of the two virtual entries and return to the Edit File
Details panel. Note the message at the bottom of the
panel indicating that the access path has been updated
with all virtuals.

COOL:2E Tutorial TUT 7–29


Introduction to the Print Object Function

Type Z against the Entries by Horse name access path


to begin the process of specifying Horse name as the
key as shown.

Displaying the Press Enter to display the Edit Access Path Details
Access Path panel. Next, type Z against the displayed format and
Format Entries press Enter to access the Edit Access Path Format
Entries panel.

On the Edit Access Path Format Entries panel, the key


order defaults to that of the RTV access path. Note that

TUT 7–30 COOL:2E Tutorial


Introduction to the Print Object Function

all fields, including virtual fields, are available as key


fields.

Specifying an Specify Horse name and Race date as the alternate


Alternative Key keys of the access path. You can assume that each
horse runs in no more than one race per day; as a
result, Race time is not required as a key.

Define the keys by changing entries in the Key no.


column as shown; namely, blank the Key no. field for
Course code, Race time, and Entry number, and type 1
for Horse name.

Press Enter. Press F3 twice to exit to the Edit File


Details panel.

COOL:2E Tutorial TUT 7–31


Introduction to the Print Object Function

Compiling the The access path you have just defined must be
QRY Access generated and compiled before running the application.
Path You have the option to add it to the job list now. To do
so, type J next to the QRY access path.

Press Enter.

Selecting the Now that you have defined the QRY access path, you
Access Path for need to select it for the Print Race Entries function. To
the Function do so, type X next to the QRY access path as shown.

TUT 7–32 COOL:2E Tutorial


Introduction to the Print Object Function

Press Enter.

Displaying the Now that you have created the PRTOBJ function,
Report Device check the device design to see whether the default
Design options meet requirements. To access the device
design, type S next to the Print Race Entries PRTOBJ
function from the Edit Functions panel as shown.

Press Enter.

COOL:2E Tutorial TUT 7–33


Introduction to the Print Object Function

The Default Initially, the report device design should look like the
Report Device one shown below.
Design

The default layout is obtained in a similar way to the


previous Print File function. The access path has a
non-unique key. A heading and total format are
provided for each key of the access path. All the fields
from the access path format are output on the detail
line records, except for the key fields, which are hidden.

A PRTOBJ function is an internal function. It does not


represent a complete report and must be embedded
within an existing Print File function. The embedding
Print File defines the standard header format, page
size, and additional details for the combined report.

Exercise - Update the report layout using the same techniques as


Updating the those in the device design updates you completed
Report Layout earlier in this tutorial. Perform the following steps.

1. Display the report formats (F17) and drop the


following formats: Race date header, Final totals,
Horse name total, and Race date total.

2. On the Detail line format, change the usage of the


Race date field from hidden to output.

TUT 7–34 COOL:2E Tutorial


Introduction to the Print Object Function

3. Hide all fields that are not required and adjust labels
and label spacings until the design resembles the
one shown below.

Press F3 twice to exit.

Exiting the Save your design by accepting the defaults on the Exit
Device Design Function Definition panel

Press Enter to return to the Edit Functions panel.

COOL:2E Tutorial TUT 7–35


Introduction to the Print Object Function

Combining the You have just finished defining the two report functions.
Report Functions Press F3 to exit the Edit Functions panel for the RACE
ENTRY file and return to the Edit Database Relations
panel.

Go to the Edit Functions panel for the HORSE file. To


do this, type Horse* on the selection line and press
Enter. Then type F next to any HORSE relation and
press Enter.

The next step is to combine the two functions so that


the records from the Print Object function (each race
entry) will be printed after each detail record in the Print
File function (after the horse to which it applies). To do
this, you will use the Edit Device Structure panel.

Type T against the Print Horses function as shown.

Press Enter.

TUT 7–36 COOL:2E Tutorial


Introduction to the Print Object Function

Embedding the The Edit Device Structure panel represents the layout
Print Race of the report in terms of the formats from which it is
Entries Function constructed. This display is only available for functions
of type PRTFIL or PRTOBJ. It has facilities for
embedding PRTOBJ functions within the report and
moving and copying them.

Many Print Object functions can be embedded within


the same Print File function. A Print Object function can
contain other embedded Print Object functions. This
makes it possible to construct complex reports. In this
tutorial, you will be embedding one Print Object function
in the previously defined Print File function.

COOL:2E Tutorial TUT 7–37


Introduction to the Print Object Function

Insert a Print Object function after the Details format by


typing IA (Insert After) in the Subfile selector, as shown
below.

Press Enter.

Selecting the The Display Print Functions panel is now shown. This
PRTOBJ panel displays a list of all the Print Object functions that
Function are available for inclusion in the Print File function. In
this case there is just one, Print Race Entries. Type X
to select the Print Race Entries function as shown.

TUT 7–38 COOL:2E Tutorial


Introduction to the Print Object Function

Press Enter.

The Modified The modified device structure is shown below. The


Device Structure backslash character (\) indicates that the Print Race
Entries function is attached to the preceding Details
format and will be printed after each detail record.

Press F3 to exit.

Saving the Save the modified device structure by selecting option


Device Structure 2 from the Exit Device Structure panel.

COOL:2E Tutorial TUT 7–39


Introduction to the Print Object Function

Press Enter to return to the Edit Functions panel.

Displaying the Examine the effect of the new device structure on the
Report Device layout of the Print Horses report device design. Type S
Design next to the Print Horses function on the Edit Functions
panel as shown.

Press Enter.

TUT 7–40 COOL:2E Tutorial


Introduction to the Print Object Function

The New Report The modified report device design is shown with the
Device Design fields resulting from the embedded Print Object
function.

View the Rest of You can display the rest of the report device design by
the Report pressing Page Down (or Roll Up depending upon your
Device Design keyboard).

COOL:2E Tutorial TUT 7–41


Introduction to the Print Object Function

✍ Note: If your report device design does not look like that
shown above, adjust it until it looks similar. Do not
be concerned with exceeding the panel limits. For
reports, COOL:2E allows 132 characters per line.

Modifying the You are restricted in the placement of the fields from
Combined the Print Object function. Place the cursor on any
Report Device PRTOBJ field and press F10. All the PRTOBJ fields are
Design moved in a single block. In other words, you cannot
manipulate the PRTOBJ fields individually from this
panel. You are only allowed to alter the indentation of
the whole PRTOBJ function relative to the left-hand
margin of the PRTFIL function in which it is embedded.
It is possible to specify individual formats of the
PRTOBJ. You can specify an absolute indentation that
is fixed relative to the left-hand margin of the report,
regardless of any adjustments made to the indentation
of the PRTOBJ as a whole.

In the current report design, the PRTOBJ fields are


displayed after all the detail line records. This implies
that all the horses will be printed followed by all the
race entries. The advantage of the report as shown in
the above panel is that it enables you to easily
distinguish between the different formats. However, to
meet the original requirements, you need to change the
report functions to print one horse at a time followed by
the corresponding race entries. You will do this in the
next step.

TUT 7–42 COOL:2E Tutorial


Introduction to the Print Object Function

Press F3 twice to exit the Device Design Editor. Save


your design by accepting the default options.

Press Enter.

Specifying You have now combined the two report functions and
Parameters have a suitable report design. However, the function is
not yet fully defined. If you generate and compile the
program now, it would print all the race entries in the
RACE ENTRY file after every horse. You need to pass
a restrictor parameter from the Print Horses function to
the Print Race Entries function so that only the race
entries that apply to each horse are printed after each
horse’s details.

There are two places where you can specify the


parameters of the Print Race Entries function.

• From the Edit Functions panel of the RACE ENTRY


file by typing P against Print Race Entries.
• From the action diagram of the Print Horses
function.

COOL:2E Tutorial TUT 7–43


Introduction to the Print Object Function

In this example, you will use the second method. Go to


the Action Diagram Editor for the Print Horses function.
To do so, type F next to the Print Horses function on
the Edit Functions panel as shown.

Press Enter.

Editing the Display the user points of the action diagram by


Action Diagram pressing F5. To specify the parameters of the Print
Race Entries function, locate the point in the action
diagram at which the function is called. Since the
function was attached to the Detail format, you will
zoom into the Print details user point.

TUT 7–44 COOL:2E Tutorial


Introduction to the Print Object Function

Type Z against the Print details user point as shown.

Press Enter.

The Print Details You embedded the PRTOBJ function after the detail
Construct line format. To reach the equivalent point in the action
diagram, type Z against the hidden construct,
...PRTOBJ calls after print of detail format, as shown.

Press Enter.

COOL:2E Tutorial TUT 7–45


Introduction to the Print Object Function

Editing the Print You have now reached the point in the action diagram
Race Entries where the PRTOBJ is embedded. Type Z against the
Function hidden construct, ...Embedded PRTOBJ : Print Race
Entries, as shown.

Press Enter.

The Action You can type ? in the Subfile selector of the Action
Diagram Editor Diagram Editor to display a list of allowed values.
Subfile Selector
Values Type ? as shown.

TUT 7–46 COOL:2E Tutorial


Introduction to the Print Object Function

Press Enter.

Editing the Since you are in the process of specifying a restrictor


Function parameter, you should select FF, Edit action
parameters.

Type X as shown to select the FF value.

Press Enter.

COOL:2E Tutorial TUT 7–47


Introduction to the Print Object Function

Displaying the The Edit Action - Function Details window is now


Function displayed.
Parameters

To edit the function parameters, press F9. The Edit


Function Parameters panel lets you edit parameters for
the Print Race Entries function.

Editing the To define the Horse name field as a restrictor


Function parameter, type Z in the Subfile selector to specify
Parameters additional details, and type *Field, Horse name, and
FLD as shown.

TUT 7–48 COOL:2E Tutorial


Introduction to the Print Object Function

Press Enter.

Specifying a On the Edit Functions Parameter Details panel you will


Restrictor specify the usage and role of the Horse name
Parameter parameter. In this case, the parameter defaults to Input
(I). You will specify that the parameter has a restrictor
role by typing R in the Subfile selector. This will cause
the Print Race Entries program to process only those
records on the RACE ENTRY file for the horse
identified by the Horse name parameter.

Type R against the Horse name parameter as shown.

Press Enter.

COOL:2E confirms that the parameter is a restrictor


parameter by showing RST in the Role column.

COOL:2E Tutorial TUT 7–49


Introduction to the Print Object Function

Press F3 twice to exit and return to the Edit Action -


Function Details window.

Confirming The final step is to confirm the values for the


Parameter parameters you specified. Note that the default context
Details for the Horse name parameter is CUR (current). Since
the Detail line is being processed at this point in the
action diagram, the CUR context corresponds to the
Detail line format.

✍ Note: If you had used the Edit Functions panel rather


than the Action Diagram Editor to define
parameters, you would still need to access the
Action Diagram Editor to confirm the parameter
values.

TUT 7–50 COOL:2E Tutorial


Introduction to the Print Object Function

Press Enter to accept the parameter details.

Exit Action Exit the action diagram and save the design you have
Diagram just completed. To exit the action diagram quickly, press
F13.

Generating and You have now finished defining the Print Horses
Compiling the function. Accept the default values on the Exit Function
Functions Definition panel and change the N on the Submit
generation option to Y. This will save the function and
add it to the joblist for generation. Then select the
Submit model create request (YSBMMDLCRT) option
from the Display Services menu (F17) to submit the
generation and compilation for the function and the
Query access path.

Testing the Once the program has compiled, call it from any
Program command line. Various messages relating to the
execution of the Query access path (via the OS/400
Open Query File (OPNQRYF)) command are displayed
while the report is produced. A sample report listing
data entered with the Edit Horse and Edit Race and
Entries programs follows.

COOL:2E Tutorial TUT 7–51


Introduction to the Print Object Function

Your company name here Print Horses

Horse M/F Value D of B

Bonfire M 5000.00 2/01/88


Dam:
Sire:

Race Entries for Bonfire

Course Date Time Entry Jockey Finishing H’cap


number position

CAMDEN 5/01/95 1:11:00 2 M Brown 3 0


GOLDEN 6/12/95 1:30:00 3 M Brown 3 0

Faithful Dobbin F 3500.00 5/31/86


Dam:
Sire:

Race Entries for Faithful Dobbin

Course Date Time Entry Jockey Finishing H’cap


number position

CAMDEN 5/01/95 1:05:00 1 A Miles 2 0


GOLDEN 6/12/95 1:00:00 2 M Brown 1 0

Pegasus M 3000.00 6/23/92


Dam: Faithful Dobbin 5/31/86
Sire: Bonfire 2/01/88

Race Entries for Pegasus

Course Date Time Entry Jockey Finishing H’cap


number position

CAMDEN 5/01/95 1:00:00 3 M Brown 1 0


GOLDEN 6/12/95 1:02:00 1 M Brown 2 0

Final totals
Total number of horses : 3
Total horse value . . . : 11500.00

* * END OF REPORT * *

TUT 7–52 COOL:2E Tutorial

You might also like