Copyright 2024 - BV TallVision IT

Both OPEN DATASET and funtion module GUI_DOWNLOAD operate with codepages, effectively the character-translation table for your character sets. The SAP system will have a default codepage in case no codepage is defined, so normally you won't know there is one and you won't need to specify one. But what if special characters don't show as expected in your downloaded file ?

Where to find the system default codepage

The system's default codepage can be determined via function module RFC_SYSTEM_INFO which has a reference to the codepage in RFCSI_EXPORT-RFCCHARTYP. Function SYSTEM_CODEPAGE can also be used. Transaction code SNLS NLS Languages, Characters, Character sets and Locales. It shows the current code page of the Application server as well as the Codepage of the front end.

Make sure you have a look at transaction SCP (SAP code pages), which is mentioned in the longtexts that SAP added to codepage related dumps.

The help text in SAP reveals a nice bit of info on these codes: the first digit is the "Code":

  • 0 EBCDIC character sets
  • 1 ASCII character sets
  • 2 mixed single byte / double byte character sets
  • 4 double-byte character sets
  • 6 mixed character sets
  • 8 double byte and multibyte character sets
  • 9 reserved for code pages you define

Then the second digit: specified country:

  • 1-3 countries that use the Latin alphabet (Western Europe, North and South America, Australia, Africa)
  • 4-6 countries that use non-Latin alphabets and writing systems (Eastern Europe, Asia, Arabic countries in Africa)
  • 7-9 reserved for special languages

The other digits serve a sequential numbering purpose.

Wrong codepage ?

When you are writing data to a file with e.g. TRANSFER and the codepage is not known, the system will produce a dump. As codepages is a world-wide matter, someone could think up a codepage definition that is not known in SAP. That's what will produce this dump.  

For a list of codepages that SAP knows, you could use the F4 function on the codepage field in transaction SCP SAP code pages. This transaction reveals a lot of information on codepages (which I've not found very useful in practice).

The other - more common - dump is CONVT_CODEPAGE which comes in the form of Conversion from codepage 4110 to 4013 or similar. The "root cause" is that the information that needs to be "code-paged" (effectively checking each character of the data against the codepage table, which itself is a character translation table) holds characters that can not be translated. Thus the information you are trying to process contains special characters that were not covered in the target codepage definition. The system panics and this dump is there to tell you just that.

A solution could be to filter out the special characters from your output, or to choose an alternate codepage to save your file with. Mozes and the mountain.

Application server default and front end default

The default setting for a codepage can be set in the frontend, which makes sense as codepages are not necessarily a system-wide matter. To view or change the default codepage on your setup, you will need to go to the system's logon pad (SAPGUI). Select the system you need but don't log in. Instead press the right mouse button and select "Properties" (or press ctrl-E), which will reveal a popup with a series of tabs. The 3rd or most right tab is about codepages. 

These function modules help pick up settings (source: transaction SNLS):

  • SCP_GET_CODEPAGE_NUMBER Get the codepage default as specified on the application server (it's system parameter install/codepage/appl_server)
  • SCP_GUI_USES_UTF8 Get the codepage default as specified on the front end.
  • A code page for a language ? Try SCP_CODEPAGE_FOR_LANGUAGE - "A Used Code Page Should Be Determined for an SAP Language" which will return a code page number for a given language.

Possible values for codepage numbers can be found on TCP00 - SAP code page catalogue - and TCP00A - Code Page Attributes -. Code page numbers per country can be found on TCP09,

Code page translations

Use function module TRANSLATE_CODEPAGE_EXCEPT to transform data from code page to code page. TRANSLATE_CODEPAGE_IN and TRANSLATE_CODEPAGE_OUT could be useful here as well.