‎2007 Jun 15 2:12 PM
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.
‎2007 Jun 15 2:15 PM
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
‎2007 Jun 15 2:18 PM
‎2007 Jun 15 2:18 PM
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
‎2007 Jun 15 2:26 PM
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
‎2007 Jun 15 2:29 PM
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.