HP 3000 Manuals

Screen Field Logic [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Self-Paced Training Guide

Screen Field Logic 

You can now modify the product_key_read function attached to the Product 
Number field on the screen and window.  Previously, this function
retrieved a record and refreshed the product_scrn screen.  Now you will
add extra logic to set a variable, and to perform error testing.

Function - product_key_read 

This function is called as an after function on the product_no field on
the product_scrn screen.  It reads the product file to retrieve a record
matching the product number entered by the user.

If you are developing the KSAM based application read on below to modify
the function.

If you are developing the HP ALLBASE/SQL based application, refer to
"Modifying HP ALLBASE/SQL Based Functions".

If you are developing the HP TurboIMAGE/iX based application, refer to
"HP TurboIMAGE/iX Based Functions".

Modifying KSAM Based Functions 

Using the logic block modification methods you learned when modifying the
product_proc process, you can now modify the product_key_read function.

To modify a function: 

   1.  Call up the original function with the function details screen

   2.  Modify the function

   3.  Generate the function.

If you receive any generate errors, check that the storage items you
defined previously are correctly named.  This is the most likely source
of error.  The following lines show what the function will look like
after modification.  Use the notes that follow to guide you through the
modification.

 1 FILE *READ product *KEY=* ; ENTER 5
 2 SHOW *REFRESH
 3 MOVE C-record V-product_status
 4 EXIT 
 5 IF *IOSTATUS <> N-record_not_found
     THEN MESSAGE file_error ; SERIES 6 8 ; EXIT 
 6 FILE *BUFFER product
 7 CLEAR *MAP S-description S-lead_time
 8 MOVE C-no_record V-product_status
 9 IF V-mode <> C-add THEN MESSAGE no_product ELSE
     MESSAGE add_prod; TIE 2
 10 EXIT 

The following notes describe the operation of the function.

Line 1                This step reads the product file for a record with
                      a key equal to the value in the current screen
                      field.  If an error occurs during the file access,
                      control passes to step 5.

Line 2                A record has been found, so the product screen data
                      fields are refreshed with the contents of the
                      product file record.

Line 3                A product record has been found so the
                      product_status variable is set to reflect this.
                      Other parts of the application use this variable to
                      determine if the current product exists.

Line 4                The function exits.

Line 5                This test is performed if the file read operation
                      in step 1 fails.  If the error is not the standard
                      record_not_found, then a number of actions occur.
                      First the file_error message is displayed.  Then
                      the SERIES command is executed.

                      The SERIES command performs steps 6 to 8 and then
                      returns to the next step.  This is the EXIT command
                      that follows the SERIES command.

Line 6                This command clears the product file record buffer.

Line 7                This command clears the screen fields from the
                      product Description field to the product Lead Time 
                      field.

Line 8                A product record has not been found so the
                      product_status variable is set to reflect this.

Line 9                This step displays a message that depends on the
                      current update mode.  If the current mode is add,
                      this step displays the message add_prod.  Then the
                      TIE command specifies that field number 2 is the
                      next field to be processed.

                      If the user has not selected add mode, and a
                      product record has not been found, this step
                      displays the message prod_not_exist.

Line 10               The function exits at this point.

Now you will create the functions that actually manipulate the product 
file data.  Turn to File Manipulation Functions.

Modifying HP ALLBASE/SQL Based Functions 

Using the logic block modification methods you learned when modifying the
product_proc process, you can now modify the product_key_read function.

To modify a function: 

   1.  Call up the original function with the function details screen.

   2.  Modify the function.

   3.  Generate the function.

If you receive any generate errors, check that the storage items you
defined previously are correctly named.  This is the most likely source
of error.

 1 SQL find_prod
 2 FILE *NEXT product ; ENTER 6
 3 SHOW *REFRESH S-product_no S-lead_time
 4 MOVE C-record V-product_status
 5 EXIT 
 6 IF *IOSTATUS <> N-end_of_file
     THEN MESSAGE file_error ; SERIES 7 9 ; EXIT 
 7 FILE *BUFFER product
 8 CLEAR *MAP S-description S-lead_time
 9 MOVE C-no_record V-product_status
10 IF V-mode <> C-add THEN MESSAGE no_product
     ELSE MESSAGE add_prod; TIE 2
11 EXIT 

The following notes describe the operation of the function.

Line 1                This step calls the SQL logic block find_prod,
                      which declares and opens a cursor on the product 
                      table.

Line 2                This step retrieves the first record of the active
                      set for the cursor.  If an error occurs during the
                      table access, control passes to step 6.

Line 3                A record has been found, so the product_scrn screen
                      data fields are refreshed with the contents of the
                      product file record.

Line 4                A product record has been found so the
                      product_status variable is set to reflect this.
                      Other parts of the application use this variable to
                      determine if the current product exists.

Line 5                The function exits.

Line 6                This test is performed if the FILE *NEXT operation
                      in step 2 fails.  If the error is not the standard
                      end_of_file, then a number of actions occur.  First
                      the file_error message is displayed.  Then the
                      SERIES command is executed.

                      The SERIES command performs steps 7 to 9 and then
                      returns to the next step.  This is the EXIT command
                      that follows the SERIES command.

Line 7                This command clears the product file record buffer.

Line 8                This command clears the screen fields from the
                      Description field to the Lead Time field.

Line 9                A product record has not been found so the
                      product_status variable is set to reflect this.

Line 10               This step displays a message that depends on the
                      current update mode.  If the current mode is add,
                      this step displays the message add_prod.  Then the
                      TIE command specifies that field number 2 is the
                      next field to be processed.

                      If the user has not selected add mode, and a
                      product record has not been found, this step
                      displays the message no product.

Line 11               The function exits at this point.

The find_prod SQL logic should look like this:

SELECT :product FROM sqlgrp.product
  WHERE product_no = :S-product_no.product_scrn
  FOR UPDATE OF description, supplier_no, lead_time;

The FOR UPDATE OF clause in this SELECT command specifies the columns of
the table that are being updated.  This is required so that it is
possible to update and delete records.

Now you will create the functions that actually manipulate the product 
file data.  Turn to File Manipulation Functions.

Modifying HP TurboIMAGE/iX Based Functions 

Using the logic block modification methods you learned when modifying the
product_proc process, you can now modify the product_key_read function.

To modify a function: 

   1.  Call up the original function with the function details screen.

   2.  Modify the function.

   3.  Generate the function.

If you receive any generate errors, check that the storage items you
defined previously are correctly named.  This is the most likely source
of error.

 1 DM IMAGE *LOCK :D-traindb :R-product
 2 FILE *READ product *KEY=* ; ENTER 6
 3 SHOW *REFRESH S-product_no S-lead_time
 4 MOVE C-record V-product_status
 5 EXIT 
 6 IF *IOSTATUS <> N-record_not_found
     THEN MESSAGE file_error ; SERIES 7 9 ; EXIT 
 7 FILE *BUFFER product
 8 CLEAR *MAP S-description S-lead_time
 9 MOVE C-no_record V-product_status
10 IF V-mode <> C-add THEN MESSAGE no_product
     ELSE MESSAGE add_prod; TIE 2
11 EXIT 

The following notes describe the operation of the function.

Line 1                This step locks all records in the product data
                      set.

Line 2                This step reads the product file for a record with
                      a key equal to the value in the current screen
                      field.  If an error occurs during the file access,
                      control passes to step 6.

Line 3                A record has been found, so the product screen data
                      fields are refreshed with the contents of the
                      product file record.

Line 4                A product record has been found so the
                      product_status variable is set to reflect this.
                      Other parts of the application use this variable to
                      determine if the current product exists.

Line 5                The function exits.

Line 6                This test is performed if the file read operation
                      in step 2 fails.  If the error is not the standard
                      record_not_found, then a number of actions occur.
                      First the file_error message is displayed.  Then
                      the SERIES command is executed.

                      The SERIES command performs steps 7 to 9 and then
                      returns to the next step.  This is the EXIT command
                      that follows the SERIES command.

Line 7                This command clears the product file record buffer.

Line 8                This command clears the screen fields from the
                      product Description field to the product Lead Time 
                      field.

Line 9                A product record has not been found so the
                      product_status variable is set to reflect this.

Line 10               This step displays a message that depends on the
                      current update mode.  If the current mode is add,
                      this step displays the message add_prod.  Then the
                      TIE command specifies that field number 2 is the
                      next field to be processed.

                      If the user has not selected add mode, and a
                      product record has not been found, this step
                      displays the message prod_not_exist.

Line 11               The function exits at this point.

Now you will create the functions that actually manipulate the product 
file data.



MPE/iX 5.0 Documentation