Skip to Content
author's profile photo
Former Member

upload csv file

hey

when i try to compile below GUI_UPLOAD method, i get below error

"ITAB IS NOT TYPE-COMPATIBLE WITH FORMAL PARAMETER DATA_TAB."

i declared internal table as below.

DATA: BEGIN OF ITAB OCCURS 0,

TRKORRNUM LIKE ZMW0001-TRKORRNUM,

CLIENT LIKE ZMW0001-CLIENT,

IMPORTDAY TYPE STRING,

CONVERTFILENAME LIKE ZMW0001-CONVERTFILENAME,

TRANSNO LIKE ZMW0001-TRANSNO,

EXETIMING LIKE ZMW0001-EXETIMING,

PRETRKORRNUM LIKE ZMW0001-PRETRKORRNUM,

MEMO LIKE ZMW0001-MEMO,

END OF ITAB.

CALL METHOD TEST->GUI_UPLOAD

EXPORTING

filename = Sourcepath

FILETYPE = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

CHANGING

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.

  • SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *

IF sy-subrc <> 0.

MESSAGE E001.

ENDIF.

could you please tell why.

ambichan.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Posted on Jan 19, 2005 at 03:04 PM

    You can not directly upload the file into your internal table. My suggestion is to upload into a flat structured internal table. Then loop at that internal table and parse out the string into your fields of the other internal table. You are getting that error message because you must define you internal table to be compatiable with the DATA_TAB parameter of the method.

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

    • Why not?

      Here is a sample.

      report zrich_0004.

      types: begin of tdata_tab,

      rec(500) type c,

      end of tdata_tab.

      data: data_tab type table of tdata_tab.

      data: filename type string.

      parameters: p_file type localfile default

      'C:\test.txt'.

      at selection-screen on value-request for p_file.

      call function 'KD_GET_FILENAME_ON_F4'

      exporting

      static = 'X'

      changing

      file_name = p_file.

      start-of-selection.

      filename = p_file.

      call method cl_gui_frontend_services=>gui_upload

      exporting

      filename = filename

      changing

      data_tab = data_tab

      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.

      check sy-subrc = 0.

      Regards,

      Rich Heilman

  • author's profile photo
    Former Member
    Posted on Jan 19, 2005 at 03:48 PM

    Does the file have to be csv, because if you convert it to tab delimeted I belive your original code will work. see http://www.sapdevelopment.co.uk/file/file_uptabpc.htm

    Mart

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Rich Heilman

      types: begin of flat_itab,

      rec(500) type c,

      end of flat_itab.

      Data: begin of new_itab occurs 0,

      field1(10) type c,

      field2(20) type c,

      field3(10) type c,

      field4(10) type c,

      field5(10) type c,

      field6(10) type c,

      field7(10) type c,

      field8(100) type c,

      end of new_itab.

      data: data_tab type table of flat_itab.

      data: fname type string.

      fname = 'C:\sun\rs3text.csv'.

      call method cl_gui_frontend_services=>gui_upload

      exporting

      filename = fname

      changing

      data_tab = data_tab

      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.

      write sy-subrc.

      loop at data_tab.

      split data_itab at ',' into new_itab-field1

      new_itab-field2

      new_itab-field3

      new_itab-field4

      new_itab-field5

      new_itab-field6

      new_itab-field7

      new_itab-field8.

      append new_itab.

      endloop.

      actually my file is CSV tab delimited file..how to proceed. when i compile this i get compile error saying

      "data_tab contains no header." INTO WA.....

      why