Functionality Intializes the group of function modules for processing texts in mixedlanguages. Note that the way in which TRANSLATE TO UPPER CASE works islanguage-dependent. Many programmers are obviously unaware of this. A brief look at how the function works confirms that there is aproblem, the seriousness of which varies according to the languageinvolved. What is the UPPER CASE of "a umlaut"? In German it is "Aumlaut" In French it is 'A'. In English it depends on implementationsince this letter is unknown in the English language. Serious errorsoccur in Japanese. The byte with the bit combination that looks like "aumlaut" is in fact the first half of a two-byte representation of manydifferent Kanji. If you try to process German data in a Russian environment, the resultsare inconsistent: "a umlaut" and "A umlaut" are processed correctly.But "o umlaut" becomes '¦' and "O umlaut" becomes '¶'. The bitcombination 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 solutionsince 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 sincethe SET LOCALE command is time-consuming. Furthermore, this solution does not take into account two specialconditions (even though they are not normally given). It is possiblethat the language contained in data-txt is not allowed. This wouldtrigger a RABAX. Or the program might not even run in the logonlanguage. The command SET LOCALE LANGUAGE SPACE always reverts to thelogon language. 3) Use Sort If the sorting of data is unproblematic (the data is already stored inan internal table that is not too large, for example), it may be moreefficient to re-sort the data and thus keep the number of switches to aminimum. 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 isonly worthwhile if you have large datasets that can be quicklyprocessed sequentially but cannot be easily sorted and are not alreadyroughly sorted by language. In the first run, you only convert the texts in your own language. Youalso use COLLECT to note all the other languages in a small internaltable. You then loop over this internal table, switch to the next language andrun through the entire dataset once more. Additional Notes SY-LANGU SET LOCALE also converts field SY-LANGU. If, in the program, youexecute processing other than TRANSLATE TO UPPER CASE and small actionswhich you can keep track of, or call other program parts, you shouldalways quickly switch back again after each individual action. Languages Depending on the data material, it is possible that a language IDcontains something nonsensical. Or a language may have been used thatcannot be processed by a particular application server. Or perhaps alanguage is not installed correctly. There are four function moduleswhich relieve the various applications of having to handle thesespecial 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 languageactive 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 mandatoryparameters for standard cases. Additional optional parameters areintroduced for special cases that occur relatively frequently. If exceptions are not queried, you can be sure that the function moduleeither fulfills its task or causes the program to terminate with anABAP 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 oreven incorrect data, exceptions can be collected and the errorsituations can be handled. |