HP 3000 Manuals

Task 2 - Defining the Function Details [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Self-Paced Training Guide

Task 2 - Defining the Function Details 

Having created the function header, you can now define the function
details.

Menu Path 

To access this screen from the main menu: 

   1.  Select the Logic option.

   2.  Select the Functions option.

   3.  Choose Details.

Screen Description 

This screen is identical in appearance and operation to the process
details screen.  The only difference is that you are creating a function,
not a process.  It uses the same step numbers, actions, and commands as
the process details screen and it behaves in a similar manner.

The function you will create differs according to the data manager you
are using.

Read on if the application you are developing is KSAM based.

Turn to HP ALLBASE/SQL Based Application if you are developing the HP
ALLBASE/SQL based application.

Turn to HP TurboIMAGE/iX Based Application if you are developing the HP
TurboIMAGE/iX based application.

Developing a KSAM Function 

This is the function that you will create:

1 FILE *READ product *KEY=*
2 SHOW *REFRESH

When the user enters data into the product_no field on the screen and
presses Return,

   *   The FILE command searches the product data file for a record that
       has a key that matches the data entered by the user.

   *   If a matching record is found, the SHOW command displays the data
       contained in the file record on the screen.

   *   If no match is found, the SHOW command displays the entered data
       again, and the user can continue to complete the screen.

The screen image shows you what the screen will look like when you have
entered the function.

[]
Completed Function Details Screen To enter the field values: Field Entry Explanation --------------------------------------------------------------------------------------- Function Name product_key_read This will be the default value if you have just created the header for this function. Step Number Accept the default. Action Accept the default. Command FILE You will see the FILE window appear. The window is exactly the same as the one you used when you were defining the process. File Operation *READ This time you want to read a record from the file. You can enter this command as READ without the asterisk. Table 4-0. (cont.) Field Entry Explanation --------------------------------------------------------------------------------------- *NOLOCK Accept the default. File ID[.Record] product This is a reference to the product file using the default record layout. *INDEX= Leave blank. This field allows you to specify which index is used to access the file. Leaving it blank means that the file is accessed using the index specified by the current value in the communication area field *INDEXNO. HP ALLBASE/4GL initializes the value in *INDEXNO to 1 when an application starts, assuming that all file access is to be via the primary key. *KEY= * Specifies the value to be moved to the key field of the file buffer before the file read is performed. The * refers to the internal buffer of the current screen field. As this function is called from the product_no field, the * refers to the contents of the product_no field on the data screen. If you don't specify a key, the file read takes place using the current contents of the key field in the file buffer. To complete this command: 1. Press Commit Data . When you press this key, HP ALLBASE/4GL clears the window and displays the entered command at the first line of the function. You will see that the *KEY= * clause is included in the command line. To enter the next command: Field Entry Explanation --------------------------------------------------------------------------------------- Step Number Accept the default. Action Accept the default. Command SHOW This command redisplays the fields on the screen. To Complete the *REFRESH Notice that you can enter either lowercase Command or uppercase characters for the word REFRESH. The *REFRESH clause specifies that data is moved from the data movement fields to the internal screen buffers before the fields are redisplayed. All the fields on the screen have been created with primary movement fields from the product file. This means that the current contents of the file buffer are displayed by this command. To complete this command: 1. Press Commit Data . HP ALLBASE/4GL displays the new command line and clears the window. This function is now complete. To generate the function, refer to the "Generating A Function" section following the instructions for SQL and TurboIMAGE/iX. Developing an SQL Function For an HP ALLBASE/SQL application, this is the function that you will create: 1 SQL find_prod 2 FILE *NEXT product 3 SHOW *REFRESH 2 4 When the user enters data into the product_no field on the screen and presses Return, * the first step executes the SQL commands in the find_prod SQL logic block. This SQL block contains a SELECT command to retrieve the record matching the product number value entered by the user. You will create this SQL logic block in the next lesson. * The FILE *NEXT command following the SQL command is equivalent to an SQL FETCH command. This command positions the cursor on the first row of the active set, and retrieves the record into the file buffer for the product table. * The remaining commands in the logic block then use this data as required. If the active set for the cursor is empty, the FILE *NEXT command encounters an end-of-file condition. This example demonstrates the standard technique for retrieving SQL data from an application. To retrieve a record you must perform the following steps: 1. Use a SELECT command in an SQL logic block to declare and open a cursor. 2. Use a FILE *NEXT command in a logic block to position the cursor on the first record, and retrieve the record into the file buffer. Both these steps must be in the same process, although they do not need to be in the same logic block. For example, you can use the SELECT command in an SQL logic block called from one function, and the FILE *NEXT command in another function, provided both functions are called from the same process. You cannot use a SELECT command in one process, and the FILE *NEXT command in another process because HP ALLBASE/4GL automatically closes all open HP ALLBASE/SQL cursors at the end of a process. The screen image shows you what the screen will look like when you have entered the function.
[]
Completed SQL Function Details Screen To enter the field values: Field Entry Explanation --------------------------------------------------------------------------------------- Function Name product_key_read This will be the default value if you have just created the header for this function. Step Number Accept the default. Action Accept the default action. Command SQL This displays an open window. To Complete the find_prod The name of the SQL logic block that you Command will define in the next lesson. The find_prod SQL logic block will declare and open a cursor in the product table. To complete this command: 1. Press Commit Data . When you press this key, HP ALLBASE/4GL clears the window and displays the entered command at the first line of the function. To enter the next command: Field Entry Explanation --------------------------------------------------------------------------------------- Step Number Accept the default of 2.. Action Accept the default of A. Command FILE Again you will see the FILE window appear. The window is exactly the same as the one you used when you were defining the process. File Operation *NEXT After placing the SQL cursor in the correct position, you want to retrieve the first record found by the SQL SELECT command. You can enter this command as NEXT without the asterisk. *NOLOCK Accept the default. File ID[.Record] product This is a reference to the product table. To complete this command: 1. Press Commit Data . When you press this key, HP ALLBASE/4GL clears the window and displays the entered command at the second line of the function. To enter the next command: Field Entry Explanation --------------------------------------------------------------------------------------- Step Number Accept the default. Action Accept the default. Command SHOW Table 4-0. (cont.) Field Entry Explanation --------------------------------------------------------------------------------------- To Complete the *REFRESH 2 4 Notice that you can enter either lowercase Command or uppercase characters for the word REFRESH. This command redisplays the fields on the screen. The *REFRESH clause specifies that data is moved from the data movement fields to the internal screen buffers before the fields are redisplayed. All the fields on the screen have been created with primary movement fields from the product file. This means that the current contents of the file buffer are displayed by this command. The 2 4 portion of the SHOW command tells HP ALLBASE/4GL only to refresh fields 2 to 4 of the screen. To complete this command: 1. Press Commit Data . HP ALLBASE/4GL displays the new command line and clears the window. This function is now complete. To generate the function, refer to "Task 3 - Generating the Function" following the instructions for TurboIMAGE/iX. Developing an HP TurboIMAGE/iX Function This is the function that you will create: 1 DM IMAGE *LOCK :D-traindb :R-product 2 FILE *READ product *KEY=* 3 SHOW *REFRESH When the user enters data into the product_no field on the screen and presses Return, * The DM IMAGE *LOCK command places a logical HP TurboIMAGE/iX lock on the product data set. * Then the FILE command searches the product data set for a record that has a key that matches the data entered by the user. * If a matching record is found, the SHOW command displays the data contained in the file record on the screen. If no match is found, the SHOW command displays the entered data again, and the user can continue to complete the screen. The screen image shows you what the screen will look like when you have entered the function.
[]
Completed HP TurboIMAGE/iX Function Detail Screen To enter the field values: Field Entry Explanation --------------------------------------------------------------------------------------- Function Name product_key_read This will be the default value if you have just created the header for this function. Step Number Accept the default. Action Accept the default. Command DM As with the DM commands that you defined in the product_proc process, an open window is displayed. To Complete the IMAGE *LOCK This command places a logical lock on the Command :D-traindb :R-product product data set in the traindb database. Each HP ALLBASE/4GL item reference is prefixed by a colon (:). The logical lock is a normal HP TurboIMAGE/iX lock, where the lock descriptors are stored in a table. All new lock requests are compared with the descriptors currently in the table. If the descriptor already exists in the table, the new lock is denied; otherwise it is granted. The lock does not check to ensure whether any records with the product number specified exist. This lock is maintained until the DM IMAGE *UNLOCK command is executed in the product_proc process. To complete this command: 1. Press Commit Data . When you press this key, HP ALLBASE/4GL clears the window and displays the entered command at the first line of the function. To enter the next command: Field Entry Explanation --------------------------------------------------------------------------------------- Step Number Accept the default. Action Accept the default. Again you will see the FILE window appear. The window is exactly the same as the one you used when you were defining the process. File Operation *READ This time you want to read a record from the file. You can enter this command as READ without the asterisk. *NOLOCK Accept the default. File ID[.Record] product Again, this is a reference to the default record layout on the product file. *INDEX= Leave blank. This field allows you to specify which index is used to access the file. Leaving it blank means that the file is accessed using the index specified by the current value in the communication area field *INDEXNO. HP ALLBASE/4GL initializes the value in *INDEXNO to 1 when an application starts, assuming that all file access is to be via the primary key. *KEY= * This clause specifies the value to be moved to the key field of the file buffer before the file read is performed. The * refers to the contents of the current field (product_no) on the data screen. If you don't specify a key, the file read takes place using the current contents of the key field in the file buffer. To complete this command: 1. Press Commit Data . When you press this key, HP ALLBASE/4GL clears the window and displays the entered command at the second line of the function. You will see that the *KEY= * clause is included in the command line. To enter the next command: Field Entry Explanation --------------------------------------------------------------------------------------- Step Number Accept the default. Action Accept the default. Command SHOW To Complete the *REFRESH Notice that you can enter either lowercase Command or uppercase characters for the word REFRESH. This command redisplays the fields on the screen. The *REFRESH clause specifies that data is moved from the data movement fields to the internal screen buffers before the fields are redisplayed. All the fields on the screen have been created with primary movement fields from the product file. This means that the current contents of the file buffer are displayed by this command. To complete this command: 1. Press Commit Data . HP ALLBASE/4GL displays the new command line and clears the window. This function is now complete. Now you can generate the function. This procedure is the same for all data managers.


MPE/iX 5.0 Documentation