‎2006 Feb 23 1:28 AM
Hi all,
I am trying to upload data from flat file to internal table using GUI_UPLOAD. The data in the file is tab delimited. what should I specify in the <b>HAS_FIELD_SEPARATOR</b>. I am forwarding my code too.
REPORT Z_FILE_READ.
data : begin of itab occurs 0,
carrid like sflight-carrid,
connid like sflight-connid,
end of itab.
data f_name type string value
'C:\Documents and Settings\Guest\Desktop\Book1'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\BW\Book1.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
READ_BY_LINE = 'X'
tables
data_tab = itab.
write 'vijay'.
Regards,
Varun.
‎2006 Feb 23 1:31 AM
‎2006 Feb 23 1:31 AM
‎2006 Feb 23 1:34 AM
Hi Rich,
Now I changed the value to X and in the input file I gave the seperator as ,(comma). But it still doesn't work properly.If not this FM what is the best way to upload data from file to internal table ?
Regards,
Varun.
Message was edited by: varun sonu
‎2006 Feb 23 1:37 AM
Try this code -
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gd_file
has_field_separator = 'X' "file is TAB delimited
TABLES
data_tab = it_record
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc NE 0.
write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
skip.
endif.
‎2006 Feb 23 1:38 AM
Hi Varun,
You can use FM WS_UPLOAD or UPLOAD.Though it says obselate,you can still use them.
‎2006 Feb 23 1:39 AM
Hi, I have created an tab delimited file and a test program. I have set the parameter to "X". It is working good for me. Create a tab delimited text file in notepad and save as .txt file. It should work.
report zrich_0001.
data: begin of itab occurs 0,
fl1(10) type c,
fl2(10) type c,
fl3(10) type c,
end of itab.
call function 'GUI_UPLOAD'
exporting
filename = 'C:test.txt'
filetype = 'ASC'
has_field_separator = 'X'
tables
data_tab = itab.
loop at itab.
write:/ itab-fl1, itab-fl2, itab-fl3.
endloop.Regards,
Rich Heilman
‎2006 Feb 23 1:45 AM
Hi all,
The previous two did not work out for me. when I use ws_upload the result is same. But when Iused If sy-subrc is 0.Guys you might have worked in real time. When you do call transaction or session ow do you upload data from flat file to internal table ? My purpose is also same.
Regards,
Varun.
‎2006 Feb 23 1:48 AM
‎2006 Feb 23 1:49 AM
‎2008 Oct 27 6:40 AM
i test the program,but it can not upload files include chinese chararcter.how can i upload chinese characters?