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

Gui_download error..

former_member225134
Participant
0 Kudos
1,362

Hi,

   I am trying to download the  values from excel to internal table but it is throwing error.

EXCEL FILE CANNOT OPEN THE FILE NAME.XLSX BECAUSE FILE FORMAT OR FILE EXTENSION IS NOT VALID.

First data is in excel sheet,after debugging excel file also not opening and data also not downloaded into internal table.

Anyone suggest please?

9 REPLIES 9
Read only

deepan_v_s
Active Participant
0 Kudos
929

Hello Nitya,

Can you please specify how you are reading the excel file. Using which FM ??

Regards,

Deepan.

Read only

0 Kudos
929

Hi thanks for your reply,

   Am using gui_download fm..

file name; name.xlsx

Read only

0 Kudos
929

Hello Nithya,

I think GUI_DOWNLOAD can support file format .XLS and not XLSX. Could you please check with .XLS extension

Cheers,

Varun

Read only

0 Kudos
929

Hello,

GUI_DOWNLOAD FM is used to download the data in the Internal table into Local file (For eg: xlsx).

In case if you need to get the data from Excel into internal table, you have to use the FM GUI_UPLOAD.

While calling this FM, please specify the path of the xlsx file.

Hope it helps.

Regards,
Deepan Swaminathan.

Read only

0 Kudos
929

hi,

   Yeah now am able to getting datas in itab,but it is unconverted format,Is there any function module for

convert to sap internal table??

Read only

0 Kudos
929

pass

WRITE_FIELD_SEPARATOR           = 'X'

Read only

0 Kudos
929

To upload from excel file

use the following function

DATA: l_filename TYPE rlgrap-filename. "string.

   DATA: it_raw TYPE truxs_t_text_data.

   l_filename = p_file.

   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

     EXPORTING

*     I_FIELD_SEPERATOR    =

       i_line_header        = 'X'

       i_tab_raw_data       = it_raw       " WORK TABLE

       i_filename           = p_file  "l_filename

     TABLES

       i_tab_converted_data = gt_file    "ACTUAL DATA

     EXCEPTIONS

       conversion_failed    = 1

       OTHERS               = 2.

Read only

SujeetMishra
Active Contributor
0 Kudos
929

Hello Nithya,

Use below FM, it will convert excel into internal table format.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

      filename                      = FILEPATH

      i_begin_col                   = 1

      i_begin_row                   = 3

      i_end_col                     = 5

      i_end_row                     = 9

    tables

      intern                        = IT_TAB

*   EXCEPTIONS

*     INCONSISTENT_PARAMETERS       = 1

*     UPLOAD_OLE                    = 2

*     OTHERS                        = 3

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

Thanks,

Sujeet

Read only

danni_hardanni
Participant
0 Kudos
810

To download xlsx via GUI_Download, you can translate your itab into Binary.

To have a header, you need to set your itab fields into chars or string, then apend it at first row.

CLEAR lv_len.
  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table lo_salv
        CHANGING
          t_table      <lt_output>.

      CALL METHOD lo_salv->to_xml
        EXPORTING
          xml_type if_salv_bs_xml=>c_type_xlsx
        RECEIVING
          xml      lv_xml.

    CATCH cx_salv_error INTO lo_ex.
      lv_error lo_ex->get_text).
      BREAK-POINT.
  ENDTRY.

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        lv_xml
    IMPORTING
      output_length lv_len
    TABLES
      binary_tab    lt_bin.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      bin_filesize lv_len
      filename     p_file_str
      filetype     'BIN'
    TABLES
      data_tab     lt_bin
      fieldnames   lt_field.

Hope it help.