PDL error handling functions return data identifying the cause of a runtime error in an error procedure. If you use an error handling function other than in an error procedure, N/A is returned.
When an application moves non-numeric data into a numeric field, a numeric error occurs. $ERROR-CLASS and $ERROR-TYPE return the value NUM. $ERROR-NAME returns the name of the sending field in the MOVE. There are several ways to determine the value of the field.
$ERROR-VALUE returns a string showing the value of the field. A question mark (?) marks each byte containing non-numeric data.
For example, if the string 12A45B was moved into a numeric field and the error procedure was invoked, then $ERROR-VALUE contains 12?45?, indicating the positions of the letters A and B.
For a program to see what the actual data was, you can use the $CHAR-TO-HEX function on the sending field in error. For example:
<<ERROR>> PROCEDURE
IF $ERROR-TYPE = 'NUM'
SELECT $ERROR-NAME
WHEN 'field-name-1'
SET VAR1 = $CHAR-TO-HEX(field-name-1)
WHEN 'field-name-2'
SET VAR2 = $CHAR-TO-HEX(field-name-2)
ENDSEL
ENDIF
ENDPROC
You must include a WHEN clause for every possible sending field. You can directly list the contents without using an intermediate field, for example:
LIST $CHAR-TO-HEX(field-name-1)
You can also issue a LIST ERROR statement in the scope of the error procedure. The resulting listing displays the contents of the field in error in hex, although the results are not of use in the error procedure.
You can help prevent numeric runtime errors by using the $VERIFY function to make sure that each sending field is numeric before doing a move.
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|