‎2007 Apr 17 12:59 PM
hi friends,
mi special requirement is this:
i have a string containing:
"Jose[12] M[36]ller" and i only want to see [12][36] afterwards, so how could i remove the remaining characters ?
Thank you!
‎2007 Apr 17 1:53 PM
Hi Clemens,
if u only want the data enclosed in the parentheses[] along with the parentheses then this program will work fine for you. Check the same and get back to us. If u can elaborate ur reqmt then we can help in a better way.
REPORT zyh284_test2.
DATA:
w_string TYPE string VALUE 'Jose[12] M[36]ller',
w_sub_string TYPE string,
w_int TYPE i,
w_char,
w_counter TYPE i,
fl_flag.
w_int = STRLEN( w_string ).
w_counter = 0.
DO w_int TIMES.
w_char = w_string+w_counter(1).
IF w_char EQ '['.
fl_flag = 'X'.
ENDIF.
IF fl_flag = 'X'.
CONCATENATE w_sub_string w_char INTO w_sub_string.
ENDIF.
IF w_char EQ ']'.
CLEAR fl_flag.
ENDIF.
w_counter = w_counter + 1.
ENDDO.
WRITE:w_sub_string.
‎2007 Apr 17 1:34 PM
Hi,
Just paste the following code, I hope this solves your Query.
data :
w_char(30) value 'Jose[12] M[36]ller',
w_copy like w_char,
w_off type i,
w_length type i.
w_length = strlen( w_char ).
do w_length times.
if w_char+w_off(1) CN sy-abcde
and w_char+w_off(1) CN 'abcdefghijklmnopqrstuvwxyz'.
concatenate w_copy w_char+w_off(1) into w_copy.
endif.
add 1 to w_off.
enddo.
write w_copy.
Regards,
sandhya
‎2007 Apr 17 1:53 PM
Hi Clemens,
if u only want the data enclosed in the parentheses[] along with the parentheses then this program will work fine for you. Check the same and get back to us. If u can elaborate ur reqmt then we can help in a better way.
REPORT zyh284_test2.
DATA:
w_string TYPE string VALUE 'Jose[12] M[36]ller',
w_sub_string TYPE string,
w_int TYPE i,
w_char,
w_counter TYPE i,
fl_flag.
w_int = STRLEN( w_string ).
w_counter = 0.
DO w_int TIMES.
w_char = w_string+w_counter(1).
IF w_char EQ '['.
fl_flag = 'X'.
ENDIF.
IF fl_flag = 'X'.
CONCATENATE w_sub_string w_char INTO w_sub_string.
ENDIF.
IF w_char EQ ']'.
CLEAR fl_flag.
ENDIF.
w_counter = w_counter + 1.
ENDDO.
WRITE:w_sub_string.
‎2007 Apr 17 2:04 PM
Thank you, this is just great and does as by my requirement!
Clemens