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

Delete From String Variable

Former Member
0 Likes
700

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
604

hii,

u can use REPLACE.

3 REPLIES 3
Read only

Former Member
0 Likes
605

hii,

u can use REPLACE.

Read only

Former Member
0 Likes
604

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
604

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