Ansicht
Dokumentation

SCP_MIXED_LANGUAGES_1_INIT - Mixed Language Processing: Start (1st Method)

SCP_MIXED_LANGUAGES_1_INIT - Mixed Language Processing: Start (1st Method)

BAL_S_LOG - Application Log: Log header data   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

Intializes the group of function modules for processing texts in mixed languages.

Task: Converting numerous texts in various languages to upper case.

Note that the way in which TRANSLATE TO UPPER CASE works is language-dependent. Many programmers are obviously unaware of this.

A brief look at how the function works confirms that there is a problem, the seriousness of which varies according to the language involved. What is the UPPER CASE of "a umlaut"? In German it is "A umlaut" In French it is 'A'. In English it depends on implementation since this letter is unknown in the English language. Serious errors occur in Japanese. The byte with the bit combination that looks like "a umlaut" is in fact the first half of a two-byte representation of many different Kanji.

If you try to process German data in a Russian environment, the results are inconsistent: "a umlaut" and "A umlaut" are processed correctly. But "o umlaut" becomes '¦' and "O umlaut" becomes '¶'. The bit combination for "O umlaut" is the same bit code for a lower-case "sch" in the Russian character set.

There are several solutions.

First of all, a suggestion for all developers:

-----------------------------------------------------------
|                                                         |
| 1) Conventional       TRANSLATE data-txt TO UPPER CASE. |
|                   ||                                    |
|                   \/                                    |
| 2) Suggestion         SET LOCALE LANGUAGE data-langu.   |
|                       TRANSLATE data-txt TO UPPER CASE. |
|                       SET LOCALE LANGUAGE SPACE.        |
|                                                         |
-----------------------------------------------------------

The second solution is the correct one. It is also a simple solution since it does not require you to make extensive program changes.

You call each TRANSLATE TO UPPER CASE in the appropriate environment.

Disadvantage: A very large number of switches may be necessary since the SET LOCALE command is time-consuming.

Furthermore, this solution does not take into account two special conditions (even though they are not normally given). It is possible that the language contained in data-txt is not allowed. This would trigger a RABAX. Or the program might not even run in the logon language. The command SET LOCALE LANGUAGE SPACE always reverts to the logon language.

3) Use Sort

If the sorting of data is unproblematic (the data is already stored in an internal table that is not too large, for example), it may be more efficient to re-sort the data and thus keep the number of switches to a minimum.

    SORT DATA BY LANGU.
    LOOP AT DATA.
      IF DATA-LANGU >< SY-LANGU.
        SET LOCALE LANGUAGE DATA-LANGU.
      ENDIF.
      TRANSLATE DATA-TXT TO UPPER CASE.
    ENDLOOP.
    SET LOCALE LANGUAGE SPACE.
    SORT DATA BY keyfield1 keyfield2.

4) Several Runs

The fourth method requires the most programming effort. This method is only worthwhile if you have large datasets that can be quickly processed sequentially but cannot be easily sorted and are not already roughly sorted by language.

In the first run, you only convert the texts in your own language. You also use COLLECT to note all the other languages in a small internal table.

You then loop over this internal table, switch to the next language and run through the entire dataset once more.

Additional Notes

SY-LANGU

SET LOCALE also converts field SY-LANGU. If, in the program, you execute processing other than TRANSLATE TO UPPER CASE and small actions which you can keep track of, or call other program parts, you should always quickly switch back again after each individual action.

Languages

Depending on the data material, it is possible that a language ID contains something nonsensical. Or a language may have been used that cannot be processed by a particular application server. Or perhaps a language is not installed correctly. There are four function modules which relieve the various applications of having to handle these special cases individually.

SCP_MIXED_LANGUAGES_1_INIT
You call this function module sometime at the start of processing.
SCP_MIXED_LANGUAGES_1_SWITCH
This function module switches to the required language.
SCP_MIXED_LANGUAGES_1_NORMAL
During processing you can temporarily switch back to the language active at the time of SCP_MIXED_LANGUAGES_1_INIT
SCP_MIXED_LANGUAGES_1_FINISH
You call this function module sometime at the end of the action.

As is customary for function modules, there are few mandatory parameters for standard cases. Additional optional parameters are introduced for special cases that occur relatively frequently.

If exceptions are not queried, you can be sure that the function module either fulfills its task or causes the program to terminate with an ABAP mini dump.

With these functions, solution two looks like this:

-----------------------------------------------------------
|                                                         |
| CALL FUNCTION 'SCP_MIXED_LANGUAGES_1_INIT'.             |
| ...                                                     |
|                                                         |
| LOOP AT DATA.     " Oder SELECT, oder...                |
|   ...                                                   |
|   CALL FUNCTION 'SCP_MIXED_LANGUAGES_1_SWITCH'          |
|     EXPORTING need_lang = data-txt.                     |
|   TRANSLATE data-txt TO UPPER CASE.            "old code|
|   CALL FUNCTION 'SCP_MIXED_LANGUAGES_1_NORMAL'          |
|   ...                                                   |
| ENDLOOP.                                                |
|                                                         |
| ...                                                     |
| CALL FUNCTION 'SCP_MIXED_LANGUAGES_1_FINISH'.           |
|                                                         |
-----------------------------------------------------------

If you want a program to continue working robustly with problematic or even incorrect data, exceptions can be collected and the error situations can be handled.

Example

Notes

Further information





Parameters

Exceptions

Function Group

SCP5

TXBHW - Original Tax Base Amount in Local Currency   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 11858 Date: 20240523 Time: 083641     sap01-206 ( 104 ms )