Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

7.17.3 CONDCHECK Examples

Structuring Functions for Inline Validation

...

Using the CONDCHECK Command for Validation with a Subroutine

Structuring Functions for Inline Validation

Typically functions using validation commands (eg: CONDCHECK, DATECHECK, FILECHECK, RANGECHECK and VALUECHECK) are structured for inline validation like this:

...

If a validation command inside the BEGINCHECK / ENDCHECK command block detects a validation error control is passed back to the REQUEST command. This happens because of the default IF_ERROR(*LASTDIS) parameter on the ENDCHECK command.  

Structuring Functions to Use a Validation Subroutine

Typically functions using validation commands (eg: CONDCHECK, DATECHECK, FILECHECK, RANGECHECK and VALUECHECK) are structured for subroutine validation like this:

...

If a validation command inside the BEGINCHECK / ENDCHECK command block detects a validation error control is returned to the main function loop with #ERRORCNT > 0. 

Using the CONDCHECK Command for Inline Validation

This example demonstrates how to use the CONDCEHECK command within the main program block to check the value of a field against a set of conditions. Here the salary of the new employee is added to the current salary of the department and checked that it is still under the salary budget.

...

If the salary for the new employee, when added to all existing salaries for that department, exceeds the budget for salaries the message defined with the CONDCHECK command is issued and program control returns to the last screen displayed. In this case the last screen displayed is the REQUEST screen.

Using the CONDCHECK Command for Validation with a Subroutine

This example demonstrates how to use the CONDCHECK command inside a subroutine to check the value of a field against a set of conditions.

...