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: 

GUI_UPLOAD: cannot interpret data in file

Former Member
0 Kudos

Dear Experts,

Im trying to upload simple CSV file into ALV and I'm getting the error message from GUI_UPLOAD: cannot interpret data in file.

What could be wrong at this:

DATA: ta_csv_data_raw  TYPE STANDARD TABLE OF zst_preisupload,

         wa_csv_data_raw  LIKE LINE OF ta_csv_data_raw.


zst_preisupload:


GUI_UPLOAD:


  v_filename = p_fname.

   CALL FUNCTION 'GUI_UPLOAD'

     EXPORTING

       filename = v_filename

       filetype = 'ASC'

     TABLES

       data_tab = ta_csv_data_raw.


Thank you!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

I suppose the problem is on the field PREIS (it's not char)

It should be better to upload data of file in an internal table without structure and then split the data in the table for ALV:


DATA: L_RECORD TYPE STRING.

DATA: T_FILE LIKE STANDARD TABLE OF L_RECORD.


CALL FUNCTION 'GUI_UPLOAD'

     EXPORTING

       filename = v_filename

       filetype   = 'ASC'

     TABLES

       data_tab = T_FILE..


DATA: BEGIN OF ST_FILE,

              VKORG TYPE VKORG,

              MATNR  TYPE MATNR,

               PREIS(13) TYPE C,

           END   OF ST_FILE.

LOOP AT T_FILE INTO L_RECORD.

  SPLIT L_RECORD AT ';' INTO ST_FILE-VKORG

                                                      ST_FILE-MATNR

                                                      ST_FILE-PREIS.

MOVE: ST_FILE-VKORG TO  wa_csv_data_raw-VKORG,

              ST_FILE-MATNR  TO  wa_csv_data_raw-MATNR,

             ST_FILE-PREIS     TO   wa_csv_data_raw-PREIS.

APPEND  wa_csv_data_raw TO  ta_csv_data_raw.

ENDLOOP..

But probably you should considere to implement a convertion routine for matnr (for leading zero) and preis (for integer and decimal part), but I don't know how your file is filled

Max

2 REPLIES 2

Former Member
0 Kudos

Hi

I suppose the problem is on the field PREIS (it's not char)

It should be better to upload data of file in an internal table without structure and then split the data in the table for ALV:


DATA: L_RECORD TYPE STRING.

DATA: T_FILE LIKE STANDARD TABLE OF L_RECORD.


CALL FUNCTION 'GUI_UPLOAD'

     EXPORTING

       filename = v_filename

       filetype   = 'ASC'

     TABLES

       data_tab = T_FILE..


DATA: BEGIN OF ST_FILE,

              VKORG TYPE VKORG,

              MATNR  TYPE MATNR,

               PREIS(13) TYPE C,

           END   OF ST_FILE.

LOOP AT T_FILE INTO L_RECORD.

  SPLIT L_RECORD AT ';' INTO ST_FILE-VKORG

                                                      ST_FILE-MATNR

                                                      ST_FILE-PREIS.

MOVE: ST_FILE-VKORG TO  wa_csv_data_raw-VKORG,

              ST_FILE-MATNR  TO  wa_csv_data_raw-MATNR,

             ST_FILE-PREIS     TO   wa_csv_data_raw-PREIS.

APPEND  wa_csv_data_raw TO  ta_csv_data_raw.

ENDLOOP..

But probably you should considere to implement a convertion routine for matnr (for leading zero) and preis (for integer and decimal part), but I don't know how your file is filled

Max

0 Kudos

Thank you very much Max for you help.

You cannot imagine how such advises help me to learn ABAP!