Note: Built-In Function Rules Usage Options
Creates/amends a "range of values" DICTIONARY or FILE level validation check into the data dictionary or file definition of the nominated field.
When adding a FILE level validation check to a field, the file involved must have been previously placed into an edit session by the START_FILE_EDIT Built-In Function.
All argument values passed to this Built-In Function are validated exactly as if they had been entered through the online validation check definition screen panels.
Normal authority and task tracking rules apply to the use of this Built-In Function.
For more information refer to Field Rules and Triggers in the LANSA for i User Guide.
This is a Specialized Built-In Function for use in a Development Environment only.
Arguments
|
Return Values
|
Example
A user wants to put a "range of values" validation check for a specific field, without going through the LANSA options provided on the "Field Control Menu" that enables the user to put a "range of values" validation check.
********* Define arguments and lists
DEFINE FIELD(#LEVEL) TYPE(*CHAR) LENGTH(1) LABEL('Level')
DEFINE FIELD(#FIELD) TYPE(*CHAR) LENGTH(10) LABEL('Field')
DEFINE FIELD(#SEQNUM) TYPE(*DEC) LENGTH(3) DECIMALS(0) LABEL('Sequence #')
DEFINE FIELD(#DESCR) TYPE(*CHAR) LENGTH(30) LABEL('Description')
DEFINE FIELD(#RETCOD) TYPE(*CHAR) LENGTH(2) LABEL('Return code')
DEFINE FIELD(#ENBADD) TYPE(*CHAR) LENGTH(1) LABEL('Enable ADD')
DEFINE FIELD(#ENBCHG) TYPE(*CHAR) LENGTH(1) LABEL('Enable CHG')
DEFINE FIELD(#ENBDLT) TYPE(*CHAR) LENGTH(1) LABEL('Enable DLT')
DEFINE FIELD(#TRUE) TYPE(*CHAR) LENGTH(6) LABEL('Action if True')
DEFINE FIELD(#FALSE) TYPE(*CHAR) LENGTH(6) LABEL('Action if False')
DEFINE FIELD(#MSGDET) TYPE(*CHAR) LENGTH(27) LABEL('Message Detail')
DEFINE FIELD(#MSGTXT) TYPE(*CHAR) LENGTH(80) LABEL('Message Text')
DEFINE FIELD(#FRMRNG) TYPE(*CHAR) LENGTH(20) LABEL('From range')
DEFINE FIELD(#TORNG) TYPE(*CHAR) LENGTH(20) LABEL('To range')
DEF_LIST NAME(#FRMWRK) FIELDS((#FRMRNG)) TYPE(*WORKING) ENTRYS(20)
DEF_LIST NAME(#TOWRK) FIELDS((#TORNG)) TYPE(*WORKING) ENTRYS(20)
DEF_LIST NAME(#RNGBRW) FIELDS((#FRMRNG) (#TORNG)) ENTRYS(20)
GROUP_BY NAME(#VALCHK) FIELDS((#LEVEL) (#FIELD) (#SEQNUM) (#DESCR) (#ENBADD) (#ENBCHG) (#ENBDLT) (#TRUE) (#FALSE) (#MSGDET) (#MSGTXT))
********* Initialize Browse list
CLR_LIST NAMED(#RNGBRW)
INZ_LIST NAMED(#RNGBRW) NUM_ENTRYS(20) WITH_MODE(*CHANGE)
********* Clear Working lists
BEGIN_LOOP
CLR_LIST NAMED(#FRMWRK)
CLR_LIST NAMED(#TOWRK)
********* Request Validation check details
REQUEST FIELDS((#VALCHK)) BROWSELIST(#RNGBRW)
********* Load From and To range value working lists
SELECTLIST NAMED(#RNGBRW)
ADD_ENTRY TO_LIST(#FRMWRK)
ADD_ENTRY TO_LIST(#TOWRK)
ENDSELECT
********* Execute Built-In Function - PUT_RANGE_CHECK
USE BUILTIN(PUT_RANGE_CHECK) WITH_ARGS(#LEVEL #FIELD #SEQNUM #DESCR #ENBADD #ENBCHG #ENBDLT #TRUE #FALSE #MSGDET #MSGTXT #FRMWRK #TOWRK) TO_GET(#RETCOD)
********* Put "range of values" validation check was successful
IF COND('#RETCOD *EQ ''OK''')
MESSAGE MSGTXT('Put "range of values" validation check(s) was successful')
********* Put "range of values" failed
ELSE
IF COND('#RETCOD *EQ ''ER''')
MESSAGE MSGTXT('Put "range of values" validation check(s) failed')
ENDIF
ENDIF
END_LOOP