Assignment - ONGSOURCE Pseudovariable

Purpose

Sets the current value of the ONGSOURCE built-in function.

Syntax

ONGSOURCE() = string 

or

ONGSOURCE = string

The second syntax form can be used only when ONGSOURCE has been explicitly declared using the BUILTIN attribute.

Parameters

string
An expression that is converted to a graphic string. If the length of the field that caused the CONVERSION condition is greater than the length of string, string is padded with blanks. If the length of the field is less than the length of string, string is truncated to match the field length.

Description

The ONGSOURCE pseudovariable is used to replace the invalid string that caused the CONVERSION condition to be raised. This new string is used when the conversion is attempted again.

The ONGSOURCE pseudovariable is valid only in the context of a CONVERSION ON-unit. In all other cases, the ONGSOURCE pseudovariable is ignored.

Example:

This example assumes Codepage of 932 - SHIFT-JIS - Japanese.

ONGSRC: PROC OPTIONS(MAIN);

DCL I     FIXED BIN(15);
DCL CSTR  CHAR(4);
DCL GSTR  GRAPHIC(4);

ON CONVERSION BEGIN;
     PUT SKIP LIST("ON CONVERSION TRIGGERED");
     ONGSOURCE() = 'Err!';
     i = 99;
END ;

GSTR = '8989826182638264'GX;    /* x8989 invalid dbcs char */
PUT SKIP LIST(HEX(GSTR));

CSTR =  GSTR;     /* '8989'gx conversion error */
PUT SKIP LIST(HEX(GSTR));

CSTR =  GSTR;
PUT SKIP LIST(CSTR);
END;

Will print:

8989826182638264
ON CONVERSION TRIGGERED
8989826182638264
ON CONVERSION TRIGGERED
Err!

Restrictions

None.