How to convert to upper/lower case in ABAP ?

How to convert to upper/lower case in ABAP ?

Depending on the ABAP release you are using, there are different options: the classic TRANSLATE statement (used before syntax 7.40) and the modern functional expressions to_upper( ) and to_lower( ) introduced in newer releases.

Using TRANSLATE (before ABAP 7.40)

TRANSLATE modifies the variable in place and works with character-like types (e.g., STRING, CHAR).


DATA: lv_text TYPE string.

lv_text = 'Hello World'.
TRANSLATE lv_text TO UPPER CASE.
" lv_text now = 'HELLO WORLD'

TRANSLATE lv_text TO LOWER CASE.
" lv_text now = 'hello world'

Using to_upper( ) and to_lower( ) (ABAP 7.40+)

With modern ABAP, you can use functional expressions to convert case inline and compose expressions more cleanly.
It is Non-destructive, original value remains unchanged unless you assign back, and usable inside other expressions, e.g. SELECTs, string templates, or concatenations.


DATA(lv_text) = 'Hello World'.

DATA(lv_upper) = to_upper( lv_text ).
" lv_upper = 'HELLO WORLD'

DATA(lv_lower) = to_lower( lv_text ).
" lv_lower = 'hello world'

Search tag : convertir, majuscule, minuscule,

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply