CONVERSION condition

Indicates that the contents of the result field are undefined.

Enabled/Disabled status

Always enabled.

Result

When CONVERSION is raised, the contents of the entire result field are undefined.

Raised

When an invalid conversion is attempted on character data. This attempt can be made during direct assignment of character data to numeric variable or during an input/output operation. For example, this condition can be raised when a character value that is being converted to a Fixed Binary value contains non-numeric characters, or if a character other than 0 or 1 is being converted to a bit data type.

Notes

You can use the ONSOURCE, ONCHAR, ONGSOURCE, and ONWSOURCE pseudovariables in CONVERSION ON-units to correct conversion errors.

All conversions of character data are carried out in a left-to-right sequence, character-by-character. The condition is raised for each invalid character, and when all the characters are blank, with the following exceptions:

  • Input with the F-format item, a value of zero is assumed.
  • Input with the E-format item, sometimes the ON-unit is repeatedly entered.

If a null string or a string of one or more blanks is assigned to a numeric variable, the CONVERSION condition is not raised.

When the CONVERSION condition is raised, the ONSUBCODE built-in function returns the index of the offending character or graphic.

When an invalid character is encountered, the invalid character can be replaced within the ON-unit by using the ONSOURCE or ONCHAR pseudovariables.

If the CONVERSION condition is raised and it is disabled, this means that the program is in error.

Other information

Abbreviation
CONV
Condition codes
600, 672
Implicit action
Prints a message and raises the ERROR condition.
Normal return
Upon return from a CONVERSION ON-unit, the program will retry the conversion if the ONSOURCE or ONCHAR pseudovariable has been used. If the error is not corrected, the ERROR condition is raised and control is passed back to the code that caused the exception to occur.

If the conversion error is not corrected by using pseudovariables, the program loops.