mrc Documentation
michaels, ross & cole, ltd.
http://www.mrc-productivity.com/
|
|
Creating Drop-Down Lists from an External File (For use with Maintenance Applications)
Often times, especially when
making a maintenance application, you would like a user to specify a value from
a drop-down list. Let’s say you have an order entry screen and as customer’s
add new orders they need to specify a ship-to state. Using the standard “A” or
“D” in the User Defined Field Control (as you do with Reports and Retrievals)
is impractical because this method queries the file to populate the list (What
would happen if you wanted to ship to
Overview
Step 1 – Build External Object
Inquiry over State File
Step 2 – Build the External Object
Reference under the Data Dictionary Tab
Step 3 – Map the Correct Parameter
Step 4 – Call the External Object
from a Maintenance Application
Note: Steps 1 through
3 only need to be done once. All future applications can utilize this object
for a drop down list. The only step that needs to be repeated each time is Step
4.
Step 1
Our first step is to build the
External Object Inquiry over our file that contains the data for our drop down
list. For this example it is the STATES file. After I select my “STATES” file,
I need to select two fields – The name of the state and the abbreviation. After
sequencing, select Preformat. We need to tell this object which values will be
the “D”escription and which will be the “V”alue. That is, I wish for our end
user to see the entire name of the state but when the data is written to the
file, I only want the abbreviation.

Be sure to select the “External
Object Inquiry.” Build/Compile your Object.

Step 2
Since our object is now
successfully created, we need to register it within the m-Power environment. To
do this, click on the Data Dictionary tab and click the “Manage External
Objects” link. Click the “Create” button.

Create your Drop-Down List based
upon the screen shot above.
Note: Object Type must be set at
M, as this is a Java Method.
The class name, HURCKES.I01905s,
is the address of the object we created in Step 1.
The Method name,
For Drop-Down List output: getSelect("Select a
State", pName, pValue, "select", 1)
This tells the external object how
to behave. You can change “Select a State” to whatever text you want your
dropdown list to have by default. You can also choose to have your output as a
radio button by changing “select” to radio (Note: If choosing radio button, be sure to increase the 1 to a
greater number, as this value determines how many buttons are listed per row):
For Radio Button output:
getSelect("Select a State", pName, pValue, "radio", 10).
Click Accept.
Step 3
Now since we have our External Object
registered, we must register the parameter that will be passed from the
maintenance application to our application we built in Step 1.
Search for the object you just
created, and click on the “Parameters” link for this object.
Since the field that we specified
as the “V”alue field in Step 1 is a 2A field, this parameter must also be 2A.
Remember: The
parameter you create must match the attributes of the field you specified as a
“Value field in Step 1.
Click Accept.
Step 4
Now that we have created our
External Object, Referenced it, and created the parameter it is time to create
the Maintainer application that will use it.
After you have selected the proper
file, fields, and sequencing, select the “External Objects” link.

Based on the screen above, you can
see we are calling the Object we referenced in Step 2, passing along the
parameter we defined in Step 3. Also notice that the location we are using is
entitled *Select. This location is needed to create the Drop-Down list (or
Radio buttons).
Click the Accept Button.

When the Application is run, we
are shown this screen. Note: Notice
the “Select a State” text, this is seen because we specified it when we created
the reference to this object.
Clicking on the drop down, I am
shown the following screen:

So, even though I entered my data
like this:

The actual data in the file
(queried with a basic Work-With Maintainer) looks like this:

Notice the data in the file was
written as “CO” rather than “