Many times I have seen people are using the ABAP Text Elements. You must not use them as constants.
Don’t get me wrong. Text symbols are good, but don’t overdo them. As part of my QA reviews, many times, I see developers use Text Symbols everywhere. In this short article, I want to let you know when not to use them.
Where are they used
I have seen them used as:
- For Column descriptions
- For providing messages
- Column Names for ALV
- Column Names for Dynamic Field access
- Description of the internal text
What Is the main Problem?
Since text symbols are specific to language and the main purpose of them is to provide language specific feedback to user, they would need to be translated in all the languages in which program can be executed. If they are not translated, it would provide incorrect result when executed in different language.
When (not) to use Text Symbols
- You should only use the text symbols when you think the text would be visible to end-user. Like the text in the message, message log for the jobs, Selection screen, Report output, Column names, etc
- You must not use the text symbols if the text is for internal purpose. Consider this example, that somebody has designed a table which stores actual description as status instead of the status identifier – This itself is a big NO-NO. In this situation, you should better off creating with constant
- Column names must be created with constants if they are used as parameter to subroutine, parameter to method, parameter to FM, or dynamic access
- Text symbols are private to that specific class and not accessible in the inherited classes so, they must not be used if it is not visible to end user
How to avoid them?
Once you are done with your development, take a look at the text pool and identify if any of them are incorrectly maintained. If you find that, don’t hesitate to change unless you are planning to code the logic like that.
Have you seen these type of text symbols?