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

reverse

Former Member
0 Likes
702

hi experts,

I want to reverse the string.i was tried one program but it rises the runtime error..i was paste my program here.please check and give the result....

DATA:REV(10).

CALL FUNCTION 'STRING_REVERSE'

EXPORTING

STRING = 'MA'

LANG = 'EN'

IMPORTING

RSTRING = REV

EXCEPTIONS

TOO_SMALL = 1

OTHERS = 2

.

*IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

IF SY-SUBRC = 0.

MESSAGE 'THE STRING WAS SUCCESFULLY REVERSED' TYPE 'I'.

ENDIF.

5 REPLIES 5
Read only

kostas_tsioubris
Contributor
0 Likes
669

Hi,

correct your code like this.

DATA:REV(10).

CALL FUNCTION 'STRING_REVERSE'

EXPORTING

STRING = 'MA'

LANG = <b>'E'</b>

IMPORTING

RSTRING = REV

EXCEPTIONS

TOO_SMALL = 1

OTHERS = 2

.

*IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

IF SY-SUBRC = 0.

MESSAGE 'THE STRING WAS SUCCESFULLY REVERSED' TYPE 'I'.

ENDIF.

Kostas

Read only

Former Member
0 Likes
669

HI,

USE LAGUAGE AS 'E' INSTEAD OF 'EN'.

Read only

Former Member
0 Likes
669

Hi,

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.

Regards

Sudheer

Read only

Former Member
0 Likes
669

Hi

Its simple

if you see the Dump section "Error Analysis" you will get your answer...

In this particular case, the variable " " for the addition "LANGUAGE" contained

the value "EN" in the length 2. According to the SAP text environment

table "TCP0C", values for "LANGUAGE" cannot be longer than 1 characters.

so the change is just put <b>LANG = 'E'</b> in your call to string_reverse.

mark if helpful

Tushar

Read only

Former Member
0 Likes
669

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.

you pass the value SY-LANGU insted of 'EN' to LANG parameter of function module STRING_REVERSE .

regards,

Ashokreddy.