Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to reverse a string

Former Member
14,851

HI all,

please tell me how to reverse a string like abc = cba

thanks

use fm STRING_REVERSE

4 REPLIES 4
Read only

Former Member
0 Likes
5,299

This message was moderated.

Read only

Former Member
0 Likes
5,299

HI,

use the function module STRING_REVERSE


DATA:str(10) value 'ABC',
     r_str(10).
CALL FUNCTION 'STRING_REVERSE'
  EXPORTING
    STRING          = str
    LANG            = 'E'
 IMPORTING
   RSTRING         = r_str.

WRITE:/ r_str.

rgds,

bharat.

Read only

Former Member
0 Likes
5,299

Check the below code...

data : l_str(15) type c.
data : l_len type i.
data : l_revstr(15).

l_len = strlen( l_str ).

do.
l_len = l_len - 1.
concatenate l_revstr l_str+l_len(1) into l_revstr.
if l_len = 0.
   exit.
endif.
enddo.

write : / l_str, 
        / l_REvstr.

Hope this is helpful.

THanks,

Pavan

Read only

Former Member
0 Likes
5,299

use fm STRING_REVERSE