Previous Topic: Handle Errors

Next Topic: Automatic Internal Validation

Internal Validation

In your own NCL procedure, you can perform all necessary panel field validations. Panel Services also includes powerful automatic editing capabilities for this function, called internal validation.

The Electronic Memo panel definition shown in the previous sample panel does not specify any Panel Services validation for data entered in the SELECT field. You need to define an NCL procedure to validate input and redisplay the panel with an error message.

You can do this by using the following code:

&CONTROL NOENDMSG
   .PANEL
      &PANEL PANEL1
      &IF .&SELECT EQ .  &THEN &GOTO .ERR1
      &A = &TYPECHK (NUM) &SELECT
      &IF .&A NE .NUM &THEN &GOTO .ERR2
      &IF &SELECT GT 5 OR +
         &SELECT LT 1 &THEN &GOTO .ERR2
      .
      .  other processing
      .
      .ERR1
         .
      .  build error message and then redisplay the panel.
      .
      .ERR2
         .
      .  build error message and then redisplay the panel.        

Panel Services can provide internal validation at a field level. This can perform most of the basic editing required for a field and can greatly simplify the processing required within an NCL procedure.

The type of field validation you require can be specified on the #FLD statement for the field character attributes marking the start of a field. Multiple #FLD control statements can be used to specify different validation criteria for individual fields.

The following sample shows a panel that includes the #FLD statement to define validation requirements.

#FLD _ REQUIRED=YES BLANKS=TRAIL RANGE=(1,5) %-------------------- Electronic Memo ---------------------------- +SELECT OPTION%===>_SELECT + % &SYSMSG % 1+Create a memo % 2+Send a Memo % 3+Display incoming memos % 4+Display incoming memo % 5+Exit from this function

In this sample, the standard underscore character (_) has been redefined:

Internal validation error processing depends on how the &CONTROL PANELRC option is set. If &CONTROL PANELRC is not in effect, automatic internal validation occurs; if it is in effect, advanced internal validation can be used.