How to Convert ABAP Code to Upper or Lower Case?
To converts characters into upper or lower case one can use TRANSLATE statement, or uses substitution rules to convert all occurrences of one character to another character.
Converting to Upper or Lower Case:
TRANSLATE text TO UPPER CASE.
TRANSLATE text TO LOWER CASE.
To convert all lower case letters in the field <c> to upper case or vice versa one can use the above given statements.
There are two ways to convert abap code:
(1) Go to Utilities->User-Specific Settings->under ABAP Editor tab -> Pretty Printer ->Tick Convert Upper/Lower Case.
(2) Or you can also change it programmatically.
You can use the syntax READ REPORT to read the contents into a internal table.
Syntax: READ REPORT <report name> INTO <internal table>. This will put the code in an internal table.
Code is as Follow:
- Loop at itab.
- translate itab to UPPER CASE.
- modify itab.
- endloop.
- Use the INSERT REPORT to insert the internal to code.
Syntax: INSERT REPORT <program name> from <internal table>.
TRANSLATE text USING pattern
This statement replaces all characters in the text field according to the substitution rule stored in pattern. pattern can be a variable. Pattern holds letter pairs where first letter of every pair is replaced by second.
Obsolete variants of the TRANSLATE statement can be achieve with following documentation:
DATA: t(10) TYPE c VALUE 'AbCdEfGhIj',
string LIKE t,
rule(20) TYPE c VALUE 'AxbXCydYEzfZ'.
string = t.
WRITE string.
TRANSLATE string TO UPPER CASE.
WRITE / string.
string = t.
TRANSLATE string TO LOWER CASE.
WRITE / string.
string = t.
TRANSLATE string USING rule.
WRITE / string.
Output:
AbCdEfGhIj
ABCDEFGHIJ
abcdefghij
xXyYzZGhIj