2007 Sep 03 10:29 AM
i have field ( 3 - 8 )
i need to look like ( 8 - 3 ) how i can do it.
2007 Sep 03 11:44 AM
try this it may help you
data : text(10) value '( 3 - 8 )',
text1(10),
text2(10),
text3(10).
split text at '(' into text1 text2.
split text2 at ')' into text3 text1.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
STRING = text3
LANG = sy-langu
IMPORTING
RSTRING = text3
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.
concatenate '(' text3 ')' into text separated by space.
write : / text.
regards
shiba dutta
i have field ( 3 - 8 )
i need to look like ( 8 - 3 ) how i can do it.
2007 Sep 03 10:32 AM
Hi,
do you mean reversing a string of characters? If so, please try function module STRING_REVERSE.
I hope it helps. Best regards,
Alvaro
2007 Sep 03 10:42 AM
2007 Sep 03 10:46 AM
Hi again,
I know it might sound funny but you may try to do TRANSLATE ... USING '())(' after the string reversal. If the string is well-built (I mean, if the parentheses make sense), this should work, doesn't it?
Best regards,
Alvaro
2007 Sep 03 11:08 AM
Hi little richi
Please try to use this code.
DATA v_text(20) TYPE c.
DATA v_new_text(20) TYPE c.
DATA v_num TYPE i.
DATA v_i TYPE i.
DATA v_2i TYPE i.
v_text = '( 8- 3 )'.
v_num = STRLEN( v_text ).
v_2i = 0.
v_i = v_num - 1.
DO v_num TIMES.
IF v_textv_i(1) <> '(' AND v_textv_i(1) <> ')'.
WRITE v_textv_i(1) TO v_new_textv_2i(1).
v_i = v_i - 1.
ELSE.
WRITE v_textv_i(1) TO v_new_textv_i(1).
v_i = v_i - 1.
ENDIF.
v_2i = v_2i + 1.
ENDDO.
WRITE 😕 v_text.
WRITE: / v_new_text.
Regards
Wiboon
2007 Sep 03 11:35 AM
2007 Sep 03 11:44 AM
try this it may help you
data : text(10) value '( 3 - 8 )',
text1(10),
text2(10),
text3(10).
split text at '(' into text1 text2.
split text2 at ')' into text3 text1.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
STRING = text3
LANG = sy-langu
IMPORTING
RSTRING = text3
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.
concatenate '(' text3 ')' into text separated by space.
write : / text.
regards
shiba dutta
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |