7.112.2 SET_ERROR Examples

Example 1: The following 2 validation blocks are functionally identical.

The first uses a "standard" validation check:

BEGINCHECK

CONDCHECK FIELD(#QUANTITY) COND('(#QUANTITY >= 0) AND (#QUANTITY <= (#MEASURE * 1.462))') MSGTXT('Quantity exceeds top measurement factor or is negative')

ENDCHECK

The second uses the SET_ERROR command to achieve exactly the same result:

BEGINCHECK

IF          COND('(#QUANTITY < 0) OR (#QUANTITY > (#MEASURE * 1.462))')

SET_ERROR FOR_FIELD(#QUANTITY) MSGTXT('Quantity exceeds top measurement factor or is negative')

ENDIF

ENDCHECK

Example 2: The following 2 validation blocks are also functionally identical.

BEGINCHECK

FILECHECK  FIELD(#PRODNO) USING_FILE(PRODUCT) MSGTXT('Product number not found in product master')

RANGECHECK FIELD(#ORDNUM) RANGE(A000000 Z999999) MSGTXT('Order number is not in range A000000 to Z999999')

RANGECHECK FIELD(#QUANTITY) RANGE(1 9999) MSGTXT('Quantity ordered must be in range 1 - 9999')

ENDCHECK

and

BEGINCHECK

CHECK_FOR  IN_FILE(PRODUCT) WITH_KEY(#PRODNO)

IF_STATUS  IS_NOT(*EQUALKEY)

SET_ERROR  FOR_FIELD(#PRODNO) MSGTXT('Product number not found in product master')

ENDIF

IF         '(#ORDNUM < A000000) OR (#ORDNUM > Z999999)'

SET_ERROR  FOR_FIELD(#ORDNUM) MSGTXT('Order number is not in range A000000 - Z999999')

ENDIF

IF         '(#QUANTITY < 1) OR (#QUANTITY > 9999)'

SET_ERROR  FOR_FIELD(#QUANTITY) MSGTXT('Quantity ordered must be in range 1 - 9999')

ENDIF

ENDCHECK