In the following example, components of type X are used to store characters. In Unicode programs, this is no longer possible.
Before Unicode conversion
data: begin of L_LINE,
TEXT1(10) type c,
MARK1(1) type x value '00',
TEXT2(10) type c,
MARK2(1) type x value '00',
TEXT3(10) type c,
MARK3(1) type x value '00',
BLANK(100) type c,
end of L_LINE,
HEX0(1) type x value '00',
CRLF(2) type x value '0D0A'.
L_LINE-TEXT 1 = 'SYSTEM: '.
L_LINE-TEXT 2 = 'USER: '.
L_LINE-TEXT 3 = 'CLIENT: '.
replace: HEX0 with SY-SYSID into L_LINE, ß Unicode error
HEX0 with SY-UNAME into L_LINE, ß Unicode error
HEX0 with SY-MANDT into L_LINE. ß Unicode error
condense L_LINE. ß Unicode error
concatenate L_LINE CRLF into L_LINE. ß Unicode error
*Further processing of L_LINE.
After Unicode conversion
By using constants from the class CL_ABAP_CHAR_UTILITIES, you can avoid using any X fields.
data:
begin of L_LINE,
TEXT1(10) type c,
MARK1(1) type c
TEXT2(10) type c,
MARK2(1) type c
TEXT3(10) type c,
MARK3(1) type c
BLANK(100) type c,
end of L_LINE,
HEX0(1) type c,
CRLF(2) type c.
HEX0 = CL_ABAP_CHAR_UTILITIES=>MINCHAR.
CRLF = CL_ABAP_CHAR_UTILITIES=>CR_LF.
L_LINE-TEXT1 = 'SYSTEM: '.
L_LINE-TEXT2 = 'USER: '.
L_LINE-TEXT3 = 'CLIENT: '.
replace: HEX0 with SY-SYSID into L_LINE,
HEX0 with SY-UNAME into L_LINE,
HEX0 with SY-MANDT into L_LINE.
condense L_LINE.
concatenate L_LINE CRLF into L_LINE.
*Further processing of L_LINE.
Note: This example, which was found in a similar fashion in a real application, is unnecessarily complicated and certainly not an example of a good programming style. The following is an example of a much clearer solution:
class CL_ABAP_CHAR_UTILITIES definition load.
data: L_LINE(133) type c.
concatenate ‘SYSTEM: ‘ SY-SYSID
‘USER: ‘ SY-UNAME
‘CLIENT: ‘ SY-MANDT
CL_ABAP_CHAR_UTILITIES=>CR_LF into L_LINE.