4.2 Using a Field Reference File

Now you can add fields to the customer information window using an AS/400 file as a Field Reference File. You use the Define Reference Fields function to do this.

You use a file on the AS/400 that contains the fields required for the Customer Information window. The following information is part of the window.

Creating Records on the AS/400

First lets create some sample records on the AS/400.

Follow these steps:

  1. Move to an AS/400 session and sign on. You will use the file named CUSTOML3 in the ADTSLAB library.
  2. Add records to this file by issuing the following DFU command: UPDDTA ADTSLAB/CUSTOML3
  3. Select F9 for insert mode. After entering your data select F11.
  4. For each record, supply values for each field.
  5. Press F3 to end the data entry. Click on the GUI Designer window.

Defining Server Information

You must tell the GUI Designer which AS/400 server you want to connect to before you can use the database reference information.

If you are connecting to a TCP/IP server, you must first define the TCP/IP server.

Follow these steps:

  1. Select Server from the menu bar.
  2. Select Define TCP/IP servers. The Define TCP/IP Server List window appears.
  3. Click Add. The Add TCP/IP Server window appears.
  4. Enter your HostName.
  5. Click OK. The server list is updated with your HostName.
  6. Click Close.

Now define your AS/400 information.

Follow these steps:

  1. Select Server from the menu bar.
  2. Select Define AS/400 information. The Define AS/400 Information notebook appears.
  3. Click Add. The Add Server Alias Name window appears.
  4. Enter your AS/400 Server alias name.
  5. Select the correct remote location name from the combination box. Make sure the TCP/IP radio button is selected.
  6. Click OK to leave the Add Server Alias Name window.
  7. Go to the Files page.
  8. Click Add to add a new file definition. The Add File Alias Name window appears.
  9. In the File alias Entry field, type the name of the file you specified on the file specification (CUSTOML3).
  10. In the Remote file Entry field, type the actual file name (ADTSLAB/CUSTOML3).
  11. From the Server Alias drop-down combination box, select the server alias name you defined in a previous step.
  12. Click OK to add this file definition.
  13. Click OK to save and close the notebook.
  14. Now the GUI Designer knows which AS/400 has the database information you need to add the AS/400 reference fields to the Customer Information window.

Adding DB2/400 Reference Fields

For reference fields, a file called CUSTOML3 is used. It is located in the library ADTSLAB on your AS/400 server.

Follow these steps:

  1. Select Server from the menu bar on the VisualAge RPG window.
  2. Select the Define reference fields menu choice. The Define Reference Fields - VisualAge RPG window appears.
  3. Expand the server tree of the AS/400 your database is located on, by clicking on the '+' sign right beside its name in the File hierarchy list. If this is the first time you are connecting to your server, the Sign-on to Server window appears asking you for your AS/400 user ID and password.
  4. Enter your user ID and password.
  5. Click OK to logon to the AS/400. After this action is successfully performed, your initial library list displays.
  6. Find the library ADTSLAB in this list and expand it by clicking on the '+' sign that is beside it. If it is not part of your library list,just enter the name ADTSLAB in the field just after the server name, for example, ADTSLAB.
  7. Click on the '+' sign beside CUSTOML3. The list of format names for this file appears.
  8. Double-click on the only available format name, CUSTOM01. All fields for this record format are shown in the Fields list.
  9. Double-click on the first field, CUSTNO. The Database Field Description - VisualAge for RPG window appears with detailed information about this field.
  10. Click OK to close this window.

Creating Entry Field Parts

You can now create the necessary Entry field parts for the Customer Information window by using some of the fields defined in CUSTOM01 as a reference.

Follow these steps:

  1. Move the Customer Information and Define Reference Field - VisualAge for RPG windows so that you can see both of them.
  2. Move the mouse pointer over the CUSTNO entry in the Fields list.
  3. Select the entry with the left mouse button then click on the Customer Information window. An Entry field and a Static text part is created.
  4. Double-click on the Entry field part. The Properties notebook appears.
  5. Move to the Reference tab of the notebook. This action displays the information that identifies the AS/400 field that is referenced from this part.
  6. Move to the Style tab of the notebook and then select the Read only option to prevent the customer number from being changed.
  7. Move to the Data tab of the notebook and verify the attributes are being adopted from the referenced field.
  8. Click OK to save and close the notebook.
  9. Create the other Static text and Entry field parts for the Customer Information window in the same way by using the following AS/400 fields as a reference:
  10. You may need to enlarge the Customer Information window to place all the parts.

    The part created from the ZIP location field CZIPLO is not an Entry field part, but a Combination box part. This is because the VALUE DDS keyword was specified for this field. You can check this by looking at the details of the field. Double-click on CZIPLO in the Fields list of the Define Reference Fields - VisualAge for RPG window.

  11. Click Close to close the Define Reference Fields - VisualAge for RPG window.
  12. Make sure the Customer Number static text field part displays completely in the window. Click on this part to select it and drag the handles to increase the length of this part so that the word Number displays.

    The Customer Information window should now look like the following:

Click on to indicate that you've done all the steps.