You want to translate hard-coded strings? Here is how you should proceed!
I was tasked to replace hard-coded texts with text elements to output them in different languages.
Now I have the following problem.
WRITE 'PO Number'.
from this I tried to replace the hard-coded text ‘PO Number’ with a text element in the form
WRITE:/ Text-210 (101). "Text-210 is PO Number
but receive the following error message
Text symbol "TEXT-210 (102)": Offset and length not valid.
which means the offset length is invalid. But what does that mean exactly and what do I have to do?
There are a) hard-coded texts without translation preparation, b) variably coded texts with translation preparation, c) references to variably coded texts as well as d) offset specifications for partial strings.
WRITE 'CodeInspector will complain!'.
This line always outputs the only available text, regardless of the language selection during LOGON (“DE”,”ES”,…). This is poor programming (see CodeInspector).
WRITE 'Much better'.
By double-clicking on the string text, the system asks you whether you want to create the text element 001 because it does not yet exist. The question must be answered in the affirmative. A constant string with a length of 16 (current length of the used CHARs, changeable to max. 132) will be created.
WRITE 'Much better'(002).
WRITE text-001. "valid for all languages
The system displays the country-specific coded translation part of the text constant 001, if it exists in the current LOCALE of the logged on user, otherwise the value stored during creation.
Here, 10 characters of the character-type variable str from offset 3 onwards are displayed, where the offset specification can also be omitted in the general syntax.
Source (DE): http://www.gutefrage.net/frage/ich-moechte-aus-hardcodierten-texten-textelemente-machen-in-abap-wer-kann-mir-helfen