Online Tutorials & Training Materials | STechies.com
Register Login
Advertisement

Convert ABAP Code to Upper or Lower Case

|| 1

Convert ABAP Code to Upper or Lower Case
Stechies

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:

  1. Loop at itab.
  2. translate itab to UPPER CASE.
  3. modify itab.
  4. endloop.
  5. 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


Comments

  • 10 Jan 2013 4:03 am
    IS THRER IS WAY TO CONVER JAVA LOGIC TO ABAP LOGIC?

Advertisement
Advertisement
Advertisement