In this SAP ABAP tutorials I will show you how to reverse a string in SAP ABAP. We just have to use a standard Function Module ‘STRING_REVERSE’ which has one exporting parameter string which takes the input as string and output will be the importing parameter rstring.
Example: input: SAP ABAP, output: PABA PAS
Please find the below program for your reference.
REPORT Z_REV_STRING.
DATA : lv_amount TYPE char255.
PARAMETERS : p_amount TYPE char255.
CALL FUNCTION ‘STRING_REVERSE’
EXPORTING
string = p_amount
lang = space
IMPORTING
rstring = lv_amount
EXCEPTIONS
too_small = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE : / lv_amount.
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP MM SD Consultant
Social Plugin