9 180 PUT_FILE_CHECK

LANSA Technical

9.180 PUT_FILE_CHECK

Þ Note: Built-In Function Rules.

Creates/amends a "code/table file lookup" 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.

For use with

LANSA for i

YES

Do not use on IBM i in an RDMLX partition.

Visual LANSA for Windows

YES

 

Visual LANSA for Linux

NO

 

 

 

Arguments

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Req

Level of validation check.

D = Dictionary level

F = File level

1

1

 

 

2

A

Req

Name of field in dictionary to which validation rule is to be applied.

1

10

 

 

3

N

Req

Sequence number of check.

1

3

0

0

4

A

Req

Description of check.

1

30

 

 

5

A

Req

Enable check for ADD.

Y = Check performed on ADD

U = Check performed on ADDUSE

N = Check not performed on ADD

1

1

 

 

6

A

Req

Enable check for CHANGE.

Y = Check performed on CHG

U = Check performed on CHGUSE

N = Check not performed on CHG

1

1

 

 

7

A

Req

Enable check for DELETE.

Y = Enable check.

N = Do not enable check.

1

1

 

 

8

A

Req

Action if check is true.

NEXT = Perform next check

ERROR  = Issue fatal error

ACCEPT = Accept value and do no more checking.

4

6

 

 

9

A

Req

Action if check is false.

NEXT = Perform next check

ERROR  = Issue fatal error

ACCEPT = Accept value and do no more checking.

4

6

 

 

10

A

Req

Message file details.

Details of error message to be issued from a message file.

Message file details should be formatted as follows:

From - To   Description

1 - 7   Error Message Number

8 - 17   Message File Name

18 - 27   Message File Library

If message text is used, pass this argument as blanks.

27

27

 

 

11

A

Req

Message text.

1

80

 

 

12

A

Req

Name of file that check is to be performed against.

1

10

 

 

13

L

Req

Working list to contain key fields/values to use when checking in the file.

The calling RDML function must provide a working list with an aggregate entry length of exactly 20 bytes and at most 10 key fields/values entries may be specified.

Each list entry sent should be formatted as follows :

From - To   Description

1 - 20   Key fields/values

1

20

 

 

 

 

Return Values

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Req

Return code

OK = validation check defined

ER = fatal error detected

In case of "ER" return code error message(s) are issued automatically. When a file edit session is involved it is ended automatically without commitment.

2

2

 

 

 

 

Example

A user wants to put a "code/table file lookup" 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 "code / table file lookup" validation check.

********* Define arguments and lists
DEFINE     FIELD(#FILNAM) TYPE(*CHAR) LENGTH(10)
DEFINE     FIELD(#LIBNAM) TYPE(*CHAR) LENGTH(10)
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(#CODFIL) TYPE(*CHAR) LENGTH(10) LABEL('File name')
DEFINE     FIELD(#KEYFLD) TYPE(*CHAR) LENGTH(20) LABEL('Key field')
DEF_LIST   NAME(#KEYWRK) FIELDS((#KEYFLD)) TYPE(*WORKING) ENTRYS(10)
DEF_LIST   NAME(#KEYBRW) FIELDS((#KEYFLD)) ENTRYS(10)
GROUP_BY   NAME(#VALCHK) FIELDS((#LEVEL) (#FIELD) (#SEQNUM) (#DESCR) (#ENBADD) (#ENBCHG) (#ENBDLT) (#TRUE) (#FALSE) (#MSGDET) (#MSGTXT) (#CODFIL))
*********  Initialize Browse list
CLR_LIST   NAMED(#KEYBRW)
INZ_LIST   NAMED(#KEYBRW) NUM_ENTRYS(10) WITH_MODE(*CHANGE)
*********  Start file edit
REQUEST    FIELDS(#FILNAM #LIBNAM)
**********      
USE        BUILTIN(START_FILE_EDIT) WITH_ARGS(#FILNAM #LIBNAM 'DEM') TO_GET(#RETCOD)
*********  Clear Working lists
BEGIN_LOOP      
CLR_LIST   NAMED(#KEYWRK)
*********  Request Validation check details
REQUEST    FIELDS((#VALCHK)) BROWSELIST(#KEYBRW)
*********  Load key field working list
SELECTLIST NAMED(#KEYBRW)
ADD_ENTRY  TO_LIST(#KEYWRK)
ENDSELECT      
*********  Execute Built-In Function - PUT_FILE_CHECK
USE        BUILTIN(PUT_FILE_CHECK) WITH_ARGS(#LEVEL #FIELD #SEQNUM #DESCR #ENBADD #ENBCHG #ENBDLT #TRUE #FALSE #MSGDET #MSGTXT #CODFIL #KEYWRK) TO_GET(#RETCOD)
*********  Put "code/table file lookup" validation successful
IF         COND('#RETCOD *EQ ''OK''')
MESSAGE    MSGTXT('Put "code/table file lookup" validation check(s) was successful')
*********  Put "code/table file lookup" failed
ELSE      
IF         COND('#RETCOD *EQ ''ER''')
MESSAGE    MSGTXT('Put "code/table file lookup" validation check(s) failed')
ENDIF      
ENDIF      
END_LOOP      
USE        BUILTIN(END_FILE_EDIT) ('Y')