‎2008 Nov 04 8:05 AM
Hi everybody i wanted to know how to reverse a string and extract the last 3 charcters of the string into a separate variable.
I have to reverse the string using the function module.
Thanks
Prem
‎2008 Nov 04 8:13 AM
Let me be a bit more specific about the problem i want to know where is the reverse string stored i.e in which parameter and how to extract only the last 3 characters of the reversed string.
Thanks
‎2008 Nov 04 8:07 AM
‎2008 Nov 04 8:08 AM
‎2008 Nov 04 8:13 AM
Let me be a bit more specific about the problem i want to know where is the reverse string stored i.e in which parameter and how to extract only the last 3 characters of the reversed string.
Thanks
‎2008 Nov 04 8:15 AM
REPORT ZSRK_023 .
PARAMETERS : P_STRING(30).
DATA : RSTRING(30),
LEN TYPE I,
L TYPE I,
RESULT(3).
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
STRING = P_STRING
LANG = 'E'
IMPORTING
RSTRING = RSTRING
EXCEPTIONS
TOO_SMALL = 1
OTHERS = 2.
LEN = STRLEN( RSTRING ).
L = LEN - 3.
RESULT = RSTRING+L(3).
WRITE : / RESULT.
‎2008 Nov 04 8:22 AM
does it mean, that you only need the first three characters of the original string in reversed order? if yes, you can use:
CONCATENATE string+2(1) string+1(1) string(1) INTO string_new.
‎2008 Nov 04 8:22 AM
‎2008 Nov 04 8:46 AM
Hi eric,
No i actually want the last 3 charcters of the original in reverse order. actually i apologize for the confusion.
Thanks for your help.
‎2008 Nov 04 8:59 AM
no problem, I have a simplier solution for that as well
DATA : gv_length TYPE i,
gv_text TYPE string,
gv_result(3) TYPE c.
gv_length = strlen( gv_text ).
DO 3 TIMES.
gv_length = gv_length - 1.
CONCATENATE gv_result gv_text+gv_length(1) INTO gv_result.
ENDDO.
‎2008 Nov 04 9:22 AM