‎2008 Mar 04 7:48 PM
Plse help me in this.this is not giving me proper output.
i am having flat file with tab delimiter...i want to use split command to get the data.check my code
data : begin of itab occurs 0,
matnr type c,
mbrsh type c,
meins type c,
end of itab.
data : begin of jtab occurs 0,
data(1024) type c,
end of jtab.
data : sep type xstring. ****byte string****
call function 'GUI_UPLOAD'
exporting
filename = 'C:\flat_files\sam.txt'
FILETYPE = 'ASC'
READ_BY_LINE = 'X'
tables
data_tab = jtab.
loop at jtab.
sep = 09. *****ASCII code for tab
split jtab-data at sep into itab-matnr itab-mbrsh itab-meins.
endloop.
loop at itab.
write : / itab-matnr ,itab-mbrsh , itab-meins.
endloop.
‎2008 Mar 05 4:22 AM
Hi,
Instead of using ASCII code....do this,
declare this stmt,
constants: con_tab value cl_abap_char_utilities=>horizontal_tab.
and write the below stmt..instead of urs..
split jtab-data at con_tab into itab-matnr itab-mbrsh itab-meins.
Hopr this helps u,
Regrds,
Arunsri
Edited by: Arunsri on Mar 5, 2008 5:23 AM
‎2008 Mar 05 4:22 AM
Hi,
Instead of using ASCII code....do this,
declare this stmt,
constants: con_tab value cl_abap_char_utilities=>horizontal_tab.
and write the below stmt..instead of urs..
split jtab-data at con_tab into itab-matnr itab-mbrsh itab-meins.
Hopr this helps u,
Regrds,
Arunsri
Edited by: Arunsri on Mar 5, 2008 5:23 AM
‎2008 Mar 05 4:32 AM
Hi,
IF you want to upload a tab separated file then just pass this parameter in GUI_UPLOAD
has_field_separator = 'X'
No need to have separate coding.
Regards,
Atish
‎2008 Mar 05 4:39 AM
Hi Ravi,
You didn't specify the length of fields in the itab structure. The length of the fields will be considered as 1 char. Here is the efficient way of reading data from a file which is tab delimited.
For the function module GUI_UPLOAD there is a parameter "has_field_separator" for which you can
specify whether your file is tab delimited or comma delimited,etc. If it is tab delimited you assign 'X' . If you use this parameter you dont have to use "split" command. The data in the file will be uploaded into the fields of the internal table directly. I commented the unnecessary code.
data : begin of itab occurs 0,
matnr(18) type c,
mbrsh type c,
meins(3) type c,
end of itab.
*** data : begin of jtab occurs 0,
*** data(1024) type c,
*** end of jtab.
**** data : sep type string.
call function 'GUI_UPLOAD'
exporting
filename = 'C:\flat_files\sam.txt'
FILETYPE = 'ASC'
READ_BY_LINE = 'X'
has_field_separator = 'X'
tables
data_tab = itab.
**loop at jtab.
**
**sep = 09.
**
**split jtab-data at sep into itab-matnr itab-mbrsh itab-meins.
*endloop.
loop at itab.
write : / itab-matnr ,itab-mbrsh , itab-meins.
endloop.Reward all helpful answers..
Sunny