ABAP Code page determines how the systeme interprets ?data and display the data.
In ABAP, you have to set the code page in order to handle the special characters. (?For exemple, in French ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? don’t exist in English keyboard.).
In this post, you will find the standard function to replace characters (the easy way ), then learn to get the Target ABAP Code Page for the country and a platform. Last thing is the standard CCC ABAP Conversion Classes.
Table of Contents
Replace Caracters for non ABAP Code Page
You can simply remplace this special characters with the correspondant characters
with this function module SCP_REPLACE_STRANGE_CHARS
For exemple: ? -> e .
Get target?ABAP Code Page Conversion
Or you can handle the specific the ABAP code page of the connection language and the country.
Actuallay, there is a SAP table TCP0C matching the platform, the language, the country and the right code page.
It is extremely helpfull if you manage file or text in non-EN language.
This sample abap code let you calculate the right code page to use:
DATA: l_v_spras TYPE spras, l_v_codepage TYPE cpcodepage. l_v_spras = sy-langu. * Getting the Codepage value for connection Language CALL FUNCTION 'SCP_CODEPAGE_FOR_LANGUAGE' EXPORTING language = l_v_spras IMPORTING codepage = l_v_codepage EXCEPTIONS no_codepage = 1 OTHERS = 2. IF sy-subrc IS INITIAL. WRITE l_v_codepage. ENDIF.
Standart CCC Converter CL_ABAP_CONV_*
Since 6.10, you can also use the standard CCC converter classes CL_ABAP_CONV_*.
A good sample code can be find in this link.
- CL_ABAP_CONV_IN_CE: converts bytes representing characters in a given codepage into a character or string variable
- CL_ABAP_CONV_OUT_CE: converts a character or string variable into bytes representing characters in a given codepage
- CL_ABAP_CONV_X2X_CE: converts bytes representing characters in a given codepage, into bytes representing characters in another given codepag