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.
- Customer Number
- Customer Name
- Contact Person
- Phone Number
- Customer Address consisting of
Address, ZIP code, and City
- ZIP location
Creating Records on the AS/400
First lets create some sample records on the AS/400.
Follow these steps:
- Move to an AS/400 session and sign
on. You will use the file named CUSTOML3 in the ADTSLAB library.
- Add records to this file by
issuing the following DFU command: UPDDTA ADTSLAB/CUSTOML3
- Select F9 for
insert mode. After entering your data select F11.
- For each record, supply values for
each field.
- 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:
- Select Server
from the menu bar.
- Select Define TCP/IP
servers. The Define TCP/IP Server List window appears.
- Click Add. The
Add TCP/IP Server window appears.
- Enter your HostName.
- Click OK. The
server list is updated with your HostName.
- Click Close.
Now define your AS/400
information.
Follow these steps:
- Select Server
from the menu bar.
- Select Define AS/400
information. The Define AS/400 Information notebook appears.
- Click Add. The
Add Server Alias Name window appears.
- Enter your AS/400 Server alias
name.
- Select the correct remote location
name from the combination box. Make sure the TCP/IP radio button is
selected.
- Click OK to leave
the Add Server Alias Name window.
- Go to the Files
page.
- Click Add to add
a new file definition. The Add File Alias Name window appears.
- In the File alias
Entry field, type the name of the file you specified on the file specification (CUSTOML3).
- In the Remote file
Entry field, type the actual file name (ADTSLAB/CUSTOML3).
- From the Server Alias
drop-down combination box, select the server alias name you defined in a previous step.
- Click OK to add
this file definition.
- Click OK to save
and close the notebook.
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:
- Select Server
from the menu bar on the VisualAge RPG window.
- Select the Define
reference fields menu choice. The Define Reference Fields - VisualAge RPG window
appears.
- 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.
- Enter your user ID and password.
- Click OK to logon
to the AS/400. After this action is successfully performed, your initial library list
displays.
- 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.
- Click on the '+' sign beside CUSTOML3.
The list of format names for this file appears.
- Double-click on the only available
format name, CUSTOM01. All fields for this record format are shown in the
Fields list.
- Double-click on the first field, CUSTNO.
The Database Field Description - VisualAge for RPG window appears with detailed
information about this field.
- 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:
- Move the Customer
Information and Define Reference Field - VisualAge for RPG
windows so that you can see both of them.
- Move the mouse pointer over the CUSTNO
entry in the Fields list.
- 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.
- Double-click on the Entry
field part. The Properties notebook appears.
- 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.
- Move to the Style
tab of the notebook and then select the Read only option to prevent the
customer number from being changed.
- Move to the Data
tab of the notebook and verify the attributes are being adopted from the referenced field.
- Click OK to save
and close the notebook.
- 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:
- CUSTNA
- CONTAC
- CPHONE
- CADDR
- CCITY
- CZIP
- CZIPLO
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.
- Click Close to
close the Define Reference Fields - VisualAge for RPG window.
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.