2008 Jan 11 11:07 AM
i have an internal table with a 150 character long field(char 150) which has some value i want to replace character in that field with ASCII value less than 32 with space (ASCII 32).
how can i find that in internal table and replace it
2008 Jan 11 11:15 AM
2008 Jan 11 11:22 AM
2008 Jan 11 11:25 AM
Loop at itab.
i = 0.
j = 1.
Do 150 times.
char = itab+i(j).
If char = ascii32.
char = space.
Endif.
itab+i(j) = char.
i = i + 1.
j = j + 1.
clear char.
Enddo.
Endloop.
2008 Jan 11 11:31 AM
Hi karan,
you can use this command also
REPLACE ALL OCCURRENCES OF '<character>' IN text WITH ' '.
Reward if useful.
2008 Jan 11 11:34 AM
2008 Jan 11 11:40 AM
Hi Karan,
DATA: T(15) VALUE 'AbCdEfGhIjfxx'.
TRANSLATE T USING 'fZ'.( here 'f' is the character to be replaced and Z is character replaced).
Hope it helps u..
Reward points if helpful..
Regards,
Goutham.
2008 Jan 11 12:38 PM
i have to check if ASCII is less than 32 how can i do that .
i cannot chk 4 each char less than 32 individually.
2008 Jan 11 4:47 PM
Hi Karan.
you can try this code. But please recognize that this coding might have problems in an unicode system.
-
...
DATA : lv_char150 TYPE c LENGTH 150,
lv_len TYPE i,
lv_index TYPE sy-tabix.
FIELD-SYMBOLS <fs> TYPE x.
fill lv_char150 only to demonstrate...
CONCATENATE cl_abap_char_utilities=>horizontal_tab 'Hallo Test' INTO lv_char150.
lv_len = STRLEN( lv_char150 ).
DO lv_len TIMES.
lv_index = sy-index - 1.
ASSIGN lv_char150+lv_index(1) TO <fs> CASTING.
IF <fs> < ''20'.
<fs> = '20'.
ENDIF.
ENDDO.
...
-
Kindly regards,
Stefan