mrc Documentation
michaels, ross & cole, ltd.
http://www.mrc-productivity.com/

 

 

How to Validate using External Logic

 

Working within a mrc Maintainer it is often useful to be able to validate a user’s input. We offer basic validation methods directly within the Maintenance template itself (checking to see if a value is in a specified list, if it is greater/less than a number, if it is equal to blank, etc…). However, there are times when a more rigorous method of validation is necessary. For example, lets say that you need to check to see that a new information already exists in three other tables before you add the record. This validation can be controlled by an external object.

 

While this will work for both RPG or JAVA, this document explains how to validate within RPG. The source code for this RPG can be found here. For the sake of this documentation, the RPG code will be located in MRCAPPLLIB/QOBJLESRC and the file will be named OVLDSRVEXP.

 

First we will define this external object to our data dictionary.

 

Click the Data Dictionary tab, then click “Manage External Objects.” Click “Create”

 

 

Since this is an RPG program, the class and method boxes below (not shown) can be left blank. Click “Accept.”

 

Now that your external object has been created, we need to map the matching parameters to the object.

 

Since this object contains two parameters, we must map the same parameters, in the correct order, to this object.

 

The first parameter must be the error message, and is noted like this:

 

 

Note: The “Selected Field Required” option is set to “N” because this parameter must not be mapped at runtime.

Note: *VALID must be included in the Object Parameter Description.

 

Click Accept. Create the remainder of your parameters (in this case, I only have the customer number to register).

 

 

Click “Accept.” Now that all the parameters are created, I must click the “Create Stored Procedures” link for the specific object.

 

 

Now that the external object has been created, all that is left is including the logic into my maintenance application.

 

Create your Maintenance application as you normally would. After including all of your specifications within Application Options, click the “External Objects” link.

 

 

Select the newly created object off of the “Select an Object” dropdown. Select the *FLDVALID location. Map all parameters, except for the Error Message Parameter (as it must be left blank [i.e. no field mapped to it]).

 

 

Click Accept. Build your application.

 

Based upon my RPG logic, if a user enters in a “0” for the Customer Number, they will see the following screen:

 


Note: The text of the error message is controlled within your RPG logic. Entering a value other than zero will allow the record to be written.

 

There are a few specific rules that must be followed for this methodology to work correctly.