‎2006 Jun 15 11:15 PM
Hi
I am on Unicode system . I am reading a file from application server. i am doing like this
Data:char TYPE C,
test(2000).
READ DATASET DATASET INTO test.
IF SY-SUBRC <> 0. EXIT. ENDIF.
in test i am getting data like 'KK#hh#jkjkjkjk#jkjlk hjkjh hkjh 4354#
<b>I try these both statment.
REPLACE all occurences of CHAR in test WITH space.
REPLACE CHAR WITH ' ' INTO test.</b>
But its just replacing the '#' in last occurrence "KK#hh#jkjkjkjk#jkjlk hjkjh hkjh 4354<b>#</b>"
Why its not replacing all with space?
Cheers
Usman
‎2006 Jun 15 11:24 PM
‎2006 Jun 15 11:20 PM
hi
try the below example.
<b>data rule(2) type c value '# '.
translate test using rule.</b>
Cheers,
Abdul Hakim
‎2006 Jun 15 11:22 PM
Hi Usman,
Use <b>SPLIT</b> Statement instead of replace this defintely works as it worked for me...
i.e, Split at '#'.
Reward if it helps.
Regards,
Santosh
‎2006 Jun 15 11:24 PM
‎2006 Jun 15 11:27 PM
Thanks a lot Rich .
Its removing '#' but not giving spaces ? Why
Its also leaving '#' sign at the end of string
e,g
'KK#hh#jkjkjkjk#jkjlk hjkjh hkjh 4354#
<u><b>after code </b></u>
'KKhhjkjkjkjkjkjlk hjkjh hkjh 4354<b>#</b>
Cheers
Usman
Message was edited by: Usman Akram
‎2006 Jun 16 12:08 AM
Not sure why it is not leaving space. That is strange. The last # must not be a tab, but a CR_LF.
After the REPLACE statement, do it again, this time with.
cl_abap_char_utilities=>cr_lfHopefully it will get rid of the # at the end. If not, then do another REPLACE with the '#' sign.
Regards,
Rich Heilman
‎2006 Jun 16 12:16 AM
Wow, that is weird. I'm seeing the same with it not leaving the space. Anyway. Here is a work around.
report zrich_0006.
data: d1 type localfile value '/usr/sap/nsp/test.txt'.
data: str type string.
open dataset d1 for input in text mode encoding default.
do.
read dataset d1 into str.
if sy-subrc <> 0 .
exit.
endif.
<b> replace all occurrences of
cl_abap_char_utilities=>horizontal_tab
in str with '%'.</b>
<b> translate str using '% '.</b>
write:/ str.
enddo.
close dataset d1.
REgards,
Rich Heilman
‎2006 Jun 16 3:38 PM
Yes, I dont why its not creating spaces but this work
replace all occurrences of
cl_abap_char_utilities=>horizontal_tab
in str with '%'.
translate str using '% '.
Cheers
Usman