HP 3000 Manuals

Report File Linkages [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Self-Paced Training Guide

Report File Linkages 

If you are developing the HP ALLBASE/SQL based application, you can turn
to Painting the Report.  You do not require any report file linkages
because the prod_opt select list perfoms this file linkage.

Otherwise, read on below.

This report uses a file linkage to read records from the option file
whenever a product record is printed.  After the product details have
been printed, the link is completed by printing all the matching records
from the option file.

Menu Path 

To access the file linkage screen:

   1.  From the main menu, select the Reports option.

   2.  Choose File Linkages.

Screen Description 

This screen allows you to define a link to another file from a particular
line group.  Each time the specified line group is printed the link is
performed.  You can define up to 999 links for a report.

[]
File Linkages Screen To enter the field values: Field Entry Explanation --------------------------------------------------------------------------------------- Report Name prod_opt This is the name of the report that you are creating. Link Number 1 This screen allows you to define the links one at a time so this number becomes the identifier for the linkage. This identifier is also used on the selection criteria screen if you specify selection criteria for a link. Action A This is the standard action code that allows you to add, change, insert, or delete a linkage specification. Link From Line D1 A link is always initiated by a particular Group line group. Any links defined for a line group are initiated before the line is printed. Therefore, the details from the link file record are available for inclusion when the line group is printed. Print Line Group D2 A linkage allows you to print another line group after the Link From line group has been printed. This line group is printed for each record selected from the link file. End of Link Line Leave blank. Once the link is completed and all of the Group relevant records have been accessed and printed, you can print a further link line group. For example, you could use this line to print some additional summary data. This additional line group is printed at the end of the link. Table 11-0. (cont.) Field Entry Explanation --------------------------------------------------------------------------------------- Post-Read Function option_present This function is executed each time a record is read from the link file. This allows you to perform a number of actions. For example, you could manually terminate the link by setting the *ENDLINE switch on, or you could manipulate the data retrieved for use in the report. In this report, the function determines if any options have been found for the current product. Link File[.Record] option This is the name of the file that you want to access for the link. Index Number 2 This is the index number that is used to read the link file. A link file can only be read through a key field. The product_no field is defined as key field number 2 for the option file. Table 11-0. (cont.) Field Entry Explanation --------------------------------------------------------------------------------------- *KEY= F-product_no.product This is the key value that is used to access the link file for the first link read. The link ends when the next record read no longer matches the key value, the end of the file is reached, or the switch * ENDLINE is set on. Must the Record be N This setting takes effect when an Present unsuccessful attempt is made to read the first link record. When this field is set to N, the file record buffer is cleared and the report continues normally. If this field is set to Y, the buffer is cleared, the line group that initiated the link isn't printed, the link terminates, and the report continues. If the file error was not record not found or end of file then the report aborts. Refer to the HP ALLBASE/4GL Developer Reference Manual for further details about specifying critical links. To complete the screen: 1. Press the Commit Data function key to create the file linkage definition. Report File Linkages (Continued) Defining the Functions. You can now define the functions that are called after the link file is read, and before the D2.01 line is printed. To create the required functions: 1. Function - option_present This function is executed each time an attempt is made to link to the option file to determine if any option has been found. Create and generate this function now. 1 IF F-product_no.product = *P03 THEN EXIT 2 IF *IOSTATUS <> "00000" THEN ON 1;EXIT 3 MOVE F-product_no.product *P03 4 EXIT The option_present function operates as described below. Line 1 This step determines if this is the first time an option has been read for this product. *P03 was initialized to spaces in the start_of_report function to set this condition for the first time the function is executed. If the current product number is equal to the scratch-pad field, this function has already been executed and an option for the product has been read. In this case, the function exits immediately. Otherwise, this function tests if the first option has been found. Line 2 This step tests the status of *IOSTATUS. Whenever the link file is read, HP ALLBASE/4GL sets *IOSTATUS to allow you to determine the success or otherwise of the file access. If it is not zero, user switch number 1 is set on and the function exits. The use of this switch will be demonstrated shortly. Line 3 This step moves the current product number into scratch-pad *P03 so the test in step 1 can be performed the next time this function is executed. 2. Function - print_option This function is executed immediately before the D2.01 line (the option details line) is printed. If no option for the product has been found, it prints the E1 line group instead. Create and generate this function now. 1 IF 1 *ON THEN PRINT E1 ; ON *ENDLINE ; OFF 1 2 EXIT Line 1 The option_present function sets the user switch 1 on if the file access for the first record fails. This step tests the switch and performs a number of tasks if it is on. First the E1 line group is printed. This is a single line that states that no options were found for the product and the product or option files may be corrupted. Then the *ENDLINE switch is set on. This terminates the current line group (D2) so the line is not printed on the report. Then user switch 1 is reset to the off state. This is a standard technique to substitute another print line for the current print line. Line 3 The function then exits. You can now create the image of the report.


MPE/iX 5.0 Documentation