2006 Nov 15 6:01 PM
ho do i upload a file that is tab delimited, if the file is comma separated we items "split at ',' . how do i split tab separated items
2006 Nov 15 6:16 PM
hi,
In GUI_upload FM
the Export Parameter HAS_FIELD_SEPARATOR will be used as follows.
<b>'X':</b> Fields are separated by tabs.
<b>SPACE:</b> Fields are not separated by tabs. In this case, the table must contain only one column or all columns must be contained in the file in their entire length.
Sudheer.A
2006 Nov 15 9:12 PM
Hullo,
the hexadecimal code for 'tab' is 09.
declare a constant like:
CONSTANTS: c_tab TYPE x VALUE '09'.
and then you can use "split at c_tab".
Hope this helps.
2006 Nov 15 10:52 PM
Hi,
sudheer Addepalli is absolutely correct. All you have to do is set the field to 'X' and specify your internal table.
Regards,
Vara
2006 Nov 16 5:35 AM
HI Willard
As you know, handling of files w.r.t presentation server and application server differs.
<b>Presentation Server</b>: We can use FM: <b>GUI_UPLOAD</b> for the same.
<b>Application Server</b>:
1. Declare a variable of long text.
Eg: data: l_data(1024) type c.
2. Declate a variable which identifies tab character;
data: <b>l_tab(1) type c value cl_abap_char_utilities=>horizontal_tab</b>.
3. While reading the dataset, read into l_data.
4. Split l_data at l_tab into work area fields.
Eg:
data: l_text(1024) type c,
l_tab(1) type c value cl_abap_char_utilites=>horizontal_tab.
open dataset fname for input in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Error Opening File'.
else.
do.
read dataset fname into l_text.
if sy-subrc ne 0.
exit.
else.
split l_text at l_tab into wa-fld1 wa-fld2 ....
append wa to itab.
endif.
enddo.
close dataset fname.
endif.
Hope the above info gives you some idea.
Kind Regards
Eswar
2007 Mar 14 11:25 AM
I edit my post after i realised that i was wrong trying to do the same... but i can't to delete it.
Sorry...
Message was edited by:
Kike CI