Skip to Content

BAD DATA FORMAT using cl_gui_frontend_services=>gui_upload

Hello SAPients!

I'm using the method cl_gui_frontend_services=>gui_upload to upload a file to my program like this

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = lvs_input_f1

filetype = 'ASC'

CHANGING

data_tab = in_rec[]

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

not_supported_by_gui = 17

error_no_gui = 18

OTHERS = 19.

The SY-.SUBRC field always returns with a value of 8 (Bad data format?). The thing is that the last field of the structure IN_REC is of type i (integer) and I think this is the problem. I modified the file with a text editor and set the last field with 2, 4, 8 and 16 chars but I always receive the same error. I can't change the last field to char. Does any one have an idea of what is the problem? How can I ensure that the last field have an integer value?

Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Posted on Jan 17, 2007 at 06:50 PM

    If you want, you can send me a copy of the file and the program code and I can test it out here. See my email address on my business card.

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 17, 2007 at 07:12 PM

    Hai

    Check the following Code

    tables : mara.

    types : begin of t_mara,

    matnr type mara-matnr,

    meins type mara-meins,

    end of t_mara.

    data : it_mara type standard table of t_mara with header line.

    CALL METHOD cl_gui_frontend_services=>gui_upload

    EXPORTING

    FILENAME = 'C:\Documents and Settings\sreenivasulup\Desktop\mat_file.txt'

    FILETYPE = 'ASC'

    CHANGING

    data_tab = it_mara[]

    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

    NOT_SUPPORTED_BY_GUI = 17

    ERROR_NO_GUI = 18

    others = 19.

    if sy-subrc = 0.

    loop at it_mara.

    write :/ it_mara-matnr,

    it_mara-meins.

    endloop.

    The flat file Structure as follows

    SREE_MAT011 KG

    SREE_MAT012 KG

    SREE_MAT013 KG

    Regards

    Sreeni

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Ricardo Fernandez Vazquez

      Hai

      Check the code again

      tables : mara.

      types : begin of t_mara,

      matnr type mara-matnr,

      sno type I,

      meins type mara-meins,

      end of t_mara.

      data : it_mara type standard table of t_mara with header line.

      CALL METHOD cl_gui_frontend_services=>gui_upload

      EXPORTING

      FILENAME = 'C:\Documents and Settings\sreenivasulup\Desktop\file.txt'

      FILETYPE = 'ASC'

      HAS_FIELD_SEPARATOR = 'X'

      DAT_MODE = 'X'

      CHANGING

      data_tab = it_mara[]

      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

      NOT_SUPPORTED_BY_GUI = 17

      ERROR_NO_GUI = 18

      others = 19.

      if sy-subrc = 0.

      loop at it_mara.

      write :/ it_mara-matnr,

      it_mara-sno,

      it_mara-meins.

      endloop.

      endif.

      Flat file structure like the following way

      SREE_MAT014 1 KG

      SREE_MAT015 2 KG

      SREE_MAT016 3 KG

      regards

      Sreeni