CCSID conversions during input and output operations

When an alphanumeric, graphic, or UCS2 field is used in an input or output operation, CCSID conversion may be performed between the data in the field and the data in the input or output buffer for the file. A field is used in an input or output operation in the following cases:
  • The field appears on an input or output specification used for the operation.
  • The field appears in a search argument for a keyed operation.
  • The field appears in the list of fields specified by the %FIELDS built-in function.
  • The field is a subfield of a data structure used in a %KDS built-in function.
  • The field is a subfield of a data structure used in a result data structure for an input or output operation.

CCSID conversion may also be performed by database for alphanumeric and graphic fields when placing the data from the record into the input buffer, when placing data from the output buffer into the record, or when interpreting the search argument for keyed operations.

  • If DATA(*NOCVT) is in effect for the file, CCSID conversion is not done.
  • If the job CCSID is 65535, CCSID conversion is not done.
  • If the job CCSID is not 65535, and DATA(*NOCVT) is not in effect for the file, alphanumeric fields with a CCSID other than 65535 are converted to the job CCSID, and graphic fields with a CCSID other than 65535 are converted to the DBCS CCSID related to the job CCSID. See DATA(*CVT | *NOCVT) for information about how the DATA keyword affects CCSID conversion at the database level.
CCSID conversion is performed between the data in the input or output buffer and the program field when all of the following conditions are true:
  • The CCSID of the program field is not 65535 (*HEX).
  • The CCSID of the field in the file is not 65535.
  • The CCSID of the field in the input or output buffer is different from the CCSID of the field.
  • The CCSID of the program field is known or the DATA keyword is in effect for the file. The CCSID of a UCS-2 field is always known. The CCSID of a graphic field is known unless CCSID(*GRAPH:*IGNORE) is in effect. For information about the CCSID of alphanumeric fields, see CCSIDs of Data. For information about whether the DATA keyword is in effect for the file, see DATA(*CVT | *NOCVT).
Warning: If the DATA keyword is not in effect for the file, or if the CCSID of an alphanumeric field is not considered to be known, RPG may make incorrect assumptions about the CCSID of alphanumeric data in a program when the job CCSID is 65535 at runtime.