‎2010 Feb 24 7:21 AM
Hi Experts,
I have one string variable.
data : inputstr type string value 'ABCDE'.
Now Based on this inputstr, i need to find different combinations. Like,
BCDE, ACDE, ABDE, ABCE.
So I need to read the string by the index, if index is one then i need to remove A from 'ABCDE' and
If the index is 2 then I need to remove B from 'ABCDE'.
Please give me your all valuable suggestions.
Thank in advance,
Helps will be appreciated.
‎2010 Feb 24 7:37 AM
‎2010 Feb 24 7:37 AM
‎2010 Feb 24 7:39 AM
Hi,
DATA: lv_input TYPE string.
DATA: lv_output TYPE string.
DATA: lv_output1 TYPE string.
DATA: lv_output2 TYPE string.
DATA: lv_index TYPE sy-index.
DATA: lv_length TYPE i.
lv_input = 'ABCDE'.
lv_length = STRLEN( lv_input ).
DO.
lv_output1 = lv_input(lv_index).
lv_output2 = lv_input.
SHIFT lv_output2 BY lv_index PLACES.
SHIFT lv_output2 BY 1 PLACES.
CONCATENATE lv_output1 lv_output2 INTO lv_output.
WRITE: lv_output, /.
ADD 1 TO lv_index.
IF lv_index EQ lv_length.
EXIT.
ENDIF.
ENDDO.
regards Marcel
‎2010 Feb 24 7:47 AM
Hello,
You can try this code snippet:
DATA v_str TYPE string.
DATA:
v_str1(1000) TYPE c,
v_str2(1000) TYPE c,
v_len TYPE i,
v_idx TYPE i.
v_str = 'ABCDEFGH'.
v_str1 = v_str.
v_len = STRLEN( v_str1 ).
DO v_len TIMES.
v_idx = sy-index - 1.
v_str2 = v_str1.
v_str2+v_idx(1) = ` `.
CONDENSE v_str2 NO-GAPS.
WRITE: / v_str2.
CLEAR v_str2.
ENDDO.BR,
Suhas
Edited by: Suhas Saha on Feb 24, 2010 1:22 PM