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

sap-abap

Former Member
0 Likes
654

can anybody help me this program.

RAMAIAH

this can be printed in reverse order :HAIAMAR

plz help me.

can anybody help me this program.

RAMAIAH

this can be printed in reverse order :HAIAMAR

plz help me.

4 REPLIES 4
Read only

Former Member
0 Likes
614

hi,

u follow this logic to printing string inn reverse.

    • declarations

data: c1,

c2,

c3,

c4,

c5,

c6,

c7,

string value 'RAMAIAH',

string1.

c1 = string+6(1). " here i use string offset and length functionality

c2 = string+5(1).

c3 = string+4(1).

c4 = string+3(1).

c5 = string+2(1).

c6 = string+1(1).

c7= string(1).

CONCATENATE c1 c2 c3 c4 c5 c6 c7 <b>into</b> string1.

write:/ 'reverse o fstring is', string1.

regards,

sudheer

Read only

Former Member
0 Likes
614

Hi,

Use the FM STRING_REVERSE.

  CALL FUNCTION 'STRING_REVERSE'
    EXPORTING
      string    = v_name1
      lang      = sy-langu
    IMPORTING
      rstring   = v_name2
    EXCEPTIONS
      too_small = 1
      OTHERS    = 2.

Hope this helps.

Regards,

Richa

Read only

anversha_s
Active Contributor
0 Likes
614

hi,

just execute this program.

data : c(5) value 'RAMAIAH'.
data : l type i,i type i value -1.
data : str(5) .
l = strlen( c ).

do l times.
i = i + 1.
l = l - 1.
STR+i(1) = C+l(1).
enddo.
write STR.

Rgds

Anversha

Read only

Former Member
0 Likes
614

hi,

Use the FM STRING_REVERSE.

data : v_string1(20) type C.

data : v_string2(20) type C.

initialization.

v_string1 = 'RAMA'.

CALL FUNCTION 'STRING_REVERSE'

EXPORTING

string = v_string1

lang = sy-langu

IMPORTING

rstring = v_string2

EXCEPTIONS

too_small = 1

OTHERS = 2.

write 😕 v_string1,v_string2.