Unicode check for old programs

SAP supports Unicode and Non-Unicode ABAP programs. These two environments and approaches have their own rules which can be checked through attribute of the program or with the transaction UCCHECK. This transaction is often used to prepare the system for the migration from Non-Unicode to Unicode.

There are programming constructions, which give different effects in Non-Unicode and Unicode system and which are not reported as a problem during the activation of a program or by the transaction UCCHECK. This is a potential problem for the migration.

Consider, there is a Non-Unicode flat file, which you are going the read into the SAP system. The content of the file is simple Non-Unicode text, e.g ‘1234’.
The code below will not be reported as a problem during activation or by the transaction UCCHECK but lead to different result:

DATA:
  filename TYPE string VALUE '/tmp/test',
  buffer TYPE string,
  bukrs TYPE bukrs.

OPEN DATASET filename FOR INPUT IN BINARY MODE.
READ DATASET filename INTO buffer MAXIMUM LENGTH 4.
CLOSE DATASET filename.
MOVE buffer TO bukrs.
WRITE: / bukrs.

In Non-Unicode system you get the expected text ‘1234’ as the output.
In Unicode system you get strange characters from exotic codepage.

The idea to open this file as a binary is of course bad, nevertheless the transfer from such file to character variable should be reported as an error through program check or transaction UCCHECK.

To correct the program, open the file in text mode as follows:

OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
Scroll to Top