{"id":1599,"date":"2008-05-27T03:45:18","date_gmt":"2008-05-27T08:45:18","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/docs\/?page_id=1599"},"modified":"2023-06-20T15:57:58","modified_gmt":"2023-06-20T20:57:58","slug":"validating-via-an-rpg-external-object","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/validating-via-an-rpg-external-object","title":{"rendered":"Validating via an RPG External Object"},"content":{"rendered":"\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">mrc recommends using the <a href=\"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/workflow-designer#setting-a-condition\">Workflow Designer<\/a> to validate user input going forward.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\n<p>This document will explain how to call an external object RPG program for validity checking. For basic information regarding validity checking please see <a href=\"https:\/\/www.mrc-productivity.com\/docs\/form-validation-techniques\/how-to-validate-user-input\">this<\/a> document.<\/p>\n\n\n\n<p>The source code for this RPG can be found <a href=\"https:\/\/www.mrc-productivity.com\/docs\/form-validation-techniques\/validating-via-an-rpg-external-object-source-code\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>. For the sake of this documentation, the RPG code will be located in MRCWORKLIB\/RPGLESRC and the file will be named VALIDDATES.<\/p>\n\n\n\n<p>First, we will define this external object to our data dictionary.<\/p>\n\n\n\n<p>Click &#8220;Admin&#8221; -&gt; &#8220;External Objects&#8221; -&gt; &#8220;Create New.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Be sure that the Program and Object name match.<\/p>\n\n\n\n<p>Now that your external object has been created, we need to map the matching parameters to the object.<\/p>\n\n\n\n<p>Since this object contains <strong>three<\/strong> parameters, we must map the same parameters, in the correct order, to this object that are listed in the RPG code.<\/p>\n\n\n\n<p>The first parameter must be the error message, and is noted as such:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage2.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">The &#8220;Selected Field Required&#8221; option is set to &#8220;No&#8221; because this parameter must not be mapped at runtime.<\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">*VALID must be included in the Object Parameter Description.<\/p>\n\n\n\n<p>Click &#8220;Accept&#8221;. Create the remainder of your parameters.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage3a.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage3b.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>After all the parameters are created, create a Stored Procedure by clicking the &#8220;Create&#8221; button for the specific object on the &#8220;Manage External Objects&#8221; screen.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage10.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>This will pull up the Create Stored Procedure screen where you can view the code used to create the stored procedure, or actually create the stored procedure.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage11.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>In this case, we want to click the Create button to create the stored procedure for this object. After clicking the Create button, you will see a confirmation that the stored procedure was created successfully.<\/p>\n\n\n\n<p>Now that the external object has been created, all that is left to do is to include this object into your maintenance application.<\/p>\n\n\n\n<p>Create your Maintenance application as you normally would. After including all of your specifications within Application Menu, click the &#8220;External Objects&#8221; button from the &#8220;2. Additional Options&#8221; tab.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage5.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Select the newly created object off of the &#8220;Select an Object&#8221; drop-down. 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).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/RPGimage6.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Click &#8220;Accept&#8221;. Build your application.<\/p>\n\n\n\n<p>Based upon the RPG logic provided, if a user forgets to enter a starting and ending date, forgets either the starting or ending date, or enters an ending date that is before the starting date, the external object will stop the record from being written to the database:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/images\/RPGimage7.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/images\/RPGimage8.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/images\/RPGimage9.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">The text of the error message is controlled within your RPG logic.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Notes<\/h3>\n\n\n\n<p>There are a few specific rules that must be followed for this methodology to work correctly.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first parameter must be specified for the error message, and must not be mapped to any field within your application.<\/li>\n\n\n\n<li>The first parameter must contain the text *VALID in the description.<\/li>\n\n\n\n<li>As a general rule for external objects, if you are chaining out to any tables, in your RPG you must include their libraries within the mrc-spring-context.xml file on the &#8220;libraries=&#8221; line to specify the run-time library list.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Overview This document will explain how to call an external object RPG program for validity checking. For basic information regarding validity checking please see this document. The source code for this RPG can be found here. For the sake of this documentation, the RPG code will be located in MRCWORKLIB\/RPGLESRC&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[264],"ht-kb-tag":[],"class_list":["post-1599","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-deprecated-documentation"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=1599"}],"version-history":[{"count":15,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1599\/revisions"}],"predecessor-version":[{"id":12866,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1599\/revisions\/12866"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=1599"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=1599"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=1599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}