Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload a tab delimited CSV file into a dynamic internal table.

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

Hi,

I think u have to leave the parameter HAS_FIELD_SEPARATOR as blank and not 'X'

Thanks & regards.

0 Kudos

Yes I had tried doing that .. but still all the fields are populated in the first column for every records

0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

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.