06-14-2006 2:57 PM
Hi at all,
i've a string field, where some carriage returns (##) occur. Now i want to split this string at the carriage return into a table. Now the question is, how can i split the string at the carriage return??
After the converting the value of the internal table should be concatenated again by carriage return.
Thanks for Your help,
Andi
06-14-2006 3:06 PM
06-14-2006 3:06 PM
06-14-2006 3:07 PM
u can use
split str at '##' into itab.
loop at itab.
concatenate itab '##' into str_new.
endloop.
06-14-2006 3:10 PM
data : a(10),b(10),c(10),d(40).
D = Apple##Orange##Banana.
Split d at ## into a b c.
Now u need to append the internal table or table where u want to hold these fields.
data: begin of itab occurs 0,
first(10),
second(10),
third(10),
end of itab.
itab-first = a.
itab-second = b.
itab-third = c.
append itab.
Now u need not even concatenate the string D again as we havent changed its value anywhere
Hope this helps, please award points if found helpful
06-14-2006 3:16 PM
07-18-2007 3:49 PM
Hi Rich,
I am having problem with this carriage return. I have a record which is split due to a carriage return. I want the record to be together in a single line, i want to check all the records and if there is a carriage return in the line, then i want the record to be in one single line. the file is a tab delimited file. The hex value for the carriage return is hex00d.
Pls help.
Thanks.
06-14-2006 3:40 PM
Hi Rich,
i agree with you. Before i posted my question, i tried split at '##'. It doesn't work.
Andi
07-18-2007 3:58 PM
hI,
Check this code this may be of some use.
begin of change by 0114_temp
data: cr type x value '0A', "(carriage return)
length type sy-fdpos.
end of change by 0114_temp
loop at it_data.
begin of change by 0114_temp
search for carriage returns and replace them
length = 1.
do.
search it_data-sgtxt for cr starting at length.
if sy-subrc = 0.
length = length + sy-fdpos .
replace cr with space into it_data-sgtxt.
modify it_data index sy-tabix transporting sgtxt.
else.
exit.
endif.
enddo.
Thanks,
Mahesh