‎2009 Jan 09 11:09 AM
HI All,
How can I replace ' - ' with SPACE.
I m using
REPLACE ALL OCCURRENCES OF '-' IN VALUE WITH ' '.
It is removing '-' but not getting space.
How can I have space.
Thanks,
Anshul.
‎2009 Jan 09 11:16 AM
‎2009 Jan 09 11:17 AM
Try this code
Suppose var_a is haveing data which have data along with '-' and has to be replaced by space
data: temp(1) type c value '-'.
REPLACE temp WITH space INTO var_a.
Now see the content of variable var_a all the '-' will be replaced by space.
Hope this helps.
Regards
Bikas
‎2009 Jan 09 11:20 AM
‎2009 Jan 09 11:23 AM
Hi,
The below code will work for your requirement.
DATA:w_txt TYPE char50 VALUE 'Hi How-are-you?'.
DO."Repeat until ',' is thr
IF w_txt CA '-'. "Checking for '-'.
w_txt+sy-fdpos(1) = space. "Replacing the '-' with space
ELSE.
EXIT. "Come out when thr is no '-'.
ENDIF.
ENDDO.
WRITE:/ w_txt.i/p is: Hi How-are-you?
o/p is : Hi How are you?
Hope thi helps you.
Regards,
Manoj Kumar P
Edited by: Manoj Kumar on Jan 9, 2009 12:23 PM
‎2009 Jan 09 11:23 AM
data:val(10) value 'hh-m-kk'.
TRANSLATE val USING '- '.
write val.
‎2009 Jan 09 11:25 AM
Hi,
In this case you would have to replace it by applying the logic.
first find '-' and then replace it with ' '.
use this code,this is working surely:
DATA: g_string TYPE string VALUE 'abc-def-ghi-jkl-',
g_newstring TYPE string,
g_text(1) TYPE c VALUE '-',
g_cnt TYPE i,
g_char(1) TYPE c,
g_int TYPE sy-index,
g_flag(1) TYPE c.
g_cnt = STRLEN( g_string ).
DO g_cnt TIMES.
IF g_char IS INITIAL.
g_char = g_string+0(1).
ELSE.
g_int = sy-index - 1.
g_char = g_string+g_int(1).
ENDIF.
IF g_char = '-'.
g_flag = 'X'.
CONCATENATE ' ' g_newstring INTO g_newstring.
ELSE.
IF g_flag = 'X'.
CONCATENATE g_newstring g_char INTO g_newstring separated by space.
clear g_flag.
ELSE.
CONCATENATE g_newstring g_char INTO g_newstring.
ENDIF.
ENDIF.
ENDDO.Regards,
Neha
Edited by: Neha Shukla on Jan 9, 2009 5:28 PM
‎2009 Jan 09 12:08 PM
hi,
try this
data: var(20) type c.
data: begin of itab occurs 0 ,
var(20) type c,
end of itab.
var = 'HAO-how-are-you'.
write:/ var.
split var at '-' into TABLE itab.
CLEAR VAR.
LOOP AT ITAB.
IF SY-TABIX EQ 1.
CONCATENATE ITAB-VAR VAR INTO VAR SEPARATED BY SPACE.
ELSE.
CONCATENATE VAR ITAB-VAR INTO VAR SEPARATED BY SPACE.
ENDIF.
ENDLOOP.
WRITE:/ VAR.
regards,
Venkatesh