11-08-2011 9:03 AM
Hi all,
How to upload a tab delimited CSV file into a dynamic internal table.
I am using GUI_UPLOAD FM to upoad the file. Howerver, in this case all the fields of the row are uploaded into the first field of the table.
Following are the parameters passed to the FM.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = lv_filename
HAS_FIELD_SEPARATOR = 'X'
DAT_MODE = ' '
TABLES
DATA_TAB = <dyn_table>
Kindly provide me some solution for the same.
Regards,
Amruta
11-08-2011 10:12 AM
Hello Amruta,
Please use this FM 'KCD_CSV_FILE_TO_INTERN_CONVERT'
CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
EXPORTING
i_filename = 'C:\Temp\Book1.csv'
i_separator = ','
TABLES
e_intern = l_intern
EXCEPTIONS
upload_csv = 1
upload_filetype = 2.
Hope you find this useful.
Regards,
Reetesh
11-08-2011 9:10 AM
Hi,
I think u have to leave the parameter HAS_FIELD_SEPARATOR as blank and not 'X'
Thanks & regards.
11-08-2011 9:17 AM
Yes I had tried doing that .. but still all the fields are populated in the first column for every records
11-08-2011 9:30 AM
hi,
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = WA_BIN.
pass this way and try..
thanks & regards.
11-08-2011 9:24 AM
Hi,
With filetype 'ASC' and field_separator set to 'X', this sould work....
This could work also with filetype 'DAT'.
If you did this, there are probably no tab separator in the file itself!
Kr,
Manu.
11-08-2011 10:12 AM
Hello Amruta,
Please use this FM 'KCD_CSV_FILE_TO_INTERN_CONVERT'
CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
EXPORTING
i_filename = 'C:\Temp\Book1.csv'
i_separator = ','
TABLES
e_intern = l_intern
EXCEPTIONS
upload_csv = 1
upload_filetype = 2.
Hope you find this useful.
Regards,
Reetesh
11-11-2011 10:19 AM
Hi,
You can use an internal table of type string. No need to pass any parameter for 'FIELd SEPARATOR of GUI_UPLOAD. Use the following:-
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_filename
TABLES
data_tab = it_string
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.
LOOP AT it_string INTO st_string.
SPLIT st_string AT cl_abap_char_utilities=>horizontal_tab INTO st_project-project
st_final-field1
st_final-field2
st_final-field3
st_final-field4.... and so on....
ENDLOOP.