Application Development and Automation 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: 
Read only

FM - gui_upload. Problems uploading CSV format file

Former Member
0 Likes
3,095

Hi experts,

I am facing an issue here. I tried to upload a .csv format file using FM - gui_load, in the table LT_RAW all the information is all in one column and rest of the columns are empty.

How can i get the information to its respective fields?

below are my codes:


CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = pv_file
      READ_BY_LINE            = 'X'
      HAS_FIELD_SEPARATOR     = 'X'
      codepage                = '4110'
    IMPORTING
      filelength              = lv_filelength
    TABLES
      data_tab                = lt_raw
    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.

I can only upload using .CSV format.

12 REPLIES 12
Read only

Former Member
0 Likes
1,800

up

Read only

Former Member
0 Likes
1,800

up

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,800

Hello,

Please remove the param. READ_BY_LINE & execute the FM again.

Does this problem occur again? Do revert back.

BR,

Suhas

Read only

Former Member
0 Likes
1,800

Hi Suhas,

The problem still persist.

Any more ideas?

Thanks,

Lawrence

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,800

Hello Lee,

Can you please try to remove that HAS_FIELD_SEPARATOR because it identifies only TABs as FIELD_SEPARATOR?

Can you please share how you have defined your table?

I donot have any CSV files to test this :-((

BR,

Suhas

Read only

Former Member
0 Likes
1,800

Hi Suhas,

below is the new code that i used. now the data is not filled in only one column,

Instead it will fill up the max length of the field and continue the data in other field and fill up its max length of the field.



" my declaration of lt_raw and ls_raw
lt_raw            TYPE TABLE OF ZCTD_MIGCUSTOMER,
ls_raw            like line of lt_raw,

CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = pv_file
      codepage                = '4110'
    IMPORTING
      filelength              = lv_filelength
    TABLES
      data_tab                = lt_raw
    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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,800

Hello,

What do you mean by:

Instead it will fill up the max length of the field and continue the data in other field and fill up its max length of the field

Please elaborate.

BR,

Suhas

Read only

Former Member
0 Likes
1,800

Hi Suhas,

I think i solved my problem already. I saved it as .txt and it works. Previously, i saved it as .txt format but it does not work when uploading.

Now it works.

Thanks for your help

Read only

Former Member
0 Likes
1,800

Hi Lawrence,

Please check the parameters and their types which you are passing to the Function module.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                        = 'C:\test.csv'
   FILETYPE                          = 'ASC'
   HAS_FIELD_SEPARATOR  = '#'
  TABLES
    DATA_TAB                      = itab
 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.

Regards,

Amit.

Read only

0 Likes
1,800

Hi Amit,

I tried the parameters that you highlighted. But the problem still persist.

Any more ideas? Is it something got to do with my lt_raw table?

Thanks,

Lawrence

Read only

Former Member
0 Likes
1,800

Check patch level..

Are you using Vista??

Read only

0 Likes
1,800

Hi SHASHANK,

no. I am using XP.

here is my patch level.

SAP_AP 700 0011 SAPKNA7011 SAP Application Platform