‎2009 May 29 2:34 PM
Hi Experts ,
I want to replace all characters between < > with *. Data is stored in variable type char255.
Example ,
Suppose variable contains : Wage Type <Wage Type> Not Valid For Interface ID <ID>
I want output as Wage Type * Not Valid For Interface ID *.
Thanks & Regards ,
Jigar Thakkar
‎2009 May 29 3:06 PM
Hi Jigar,
Find the length of the string and use DO...ENDDO statement. Inside the loop, didnt consider the text between < and > and move to another string and add * when > is encountered in the string.
data:
gv_len type i,
gv_str type string value 'Wage Type <Wage Type> Not Valid For Interface ID <ID>',
gv_rep_str type string,
gv_flag type char1,
gv_index type sy-index.
gv_len = strlen( gv_str ).
do gv_len times.
gv_index = sy-index - 1.
if gv_str+gv_index(1) = '<'.
gv_flag = 'X'.
continue.
elseif gv_str+gv_index(1) = '>'.
clear gv_flag.
concatenate gv_rep_str '*' into gv_rep_str.
continue.
elseif gv_flag is initial.
concatenate gv_rep_str gv_str+gv_index(1) into gv_rep_str.
endif.
enddo.
write:/ gv_rep_str.
Thanks,
Vinay
Edited by: Vinaykumar G on May 29, 2009 8:04 PM
‎2009 May 29 2:47 PM
Hi,
Wage Type <Wage Type> Not Valid For Interface ID <ID>
REPLACE <Wage Type> WITH '*' INTO l_string.
REPLACE <ID> WITH '*' INTO l_string.Is this you are looking for ?
‎2009 May 29 2:55 PM
Hi Avinash ,
No.
Text inside < > is not fixed. So i Can't hardcode values.
I need some dynamic code wich will replace character inside < > with * irrespective of text inside < >.
Thanks & Regards ,
Jigar Thakkar.
‎2009 May 29 2:59 PM
Hey jigar,
is there any part of the text fix e.g. 'Wage Type'?
regards
Uwe
‎2009 May 29 2:49 PM
Hi jigar,
to replace parts of a variable type string or c do this (example):
REPORT ZREPLACE
Data text type string.
text = 'Token 1, Token 2, Token 3, Token 4'.
while sy-subrc = 0.
replace ',' with '-' into text.
endwhile.
* to check it is correct
write / text.
‎2009 May 29 3:04 PM
You can create new variables. Put "Wage Type" into the first, "Not Valid For Interface ID" into another and than concatenate them with "*" in between.
Rob
‎2009 May 29 3:06 PM
Hi Jigar,
Find the length of the string and use DO...ENDDO statement. Inside the loop, didnt consider the text between < and > and move to another string and add * when > is encountered in the string.
data:
gv_len type i,
gv_str type string value 'Wage Type <Wage Type> Not Valid For Interface ID <ID>',
gv_rep_str type string,
gv_flag type char1,
gv_index type sy-index.
gv_len = strlen( gv_str ).
do gv_len times.
gv_index = sy-index - 1.
if gv_str+gv_index(1) = '<'.
gv_flag = 'X'.
continue.
elseif gv_str+gv_index(1) = '>'.
clear gv_flag.
concatenate gv_rep_str '*' into gv_rep_str.
continue.
elseif gv_flag is initial.
concatenate gv_rep_str gv_str+gv_index(1) into gv_rep_str.
endif.
enddo.
write:/ gv_rep_str.
Thanks,
Vinay
Edited by: Vinaykumar G on May 29, 2009 8:04 PM
‎2009 May 29 3:34 PM
Hi,
first find your length of your field using strlen(field) then you can put * in the first and last field correspondingly.