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: 

cl_frontend_services=>gui_upload

AJeB
Participant
0 Kudos
2,374

Hi i have a xlsx and csv data


when i use the csv file the internal table is



but in xlsx the data is

is there a function module needed after the gui_upload?
for the csv data i know i can solve it using split but i dont want to use split. i don't know if there is a function module for that.
for the xlsx i dont know why the data turns into different characters can someone explain please. and if there is a function module i need to use

TYPES: BEGIN OF t_datatab,
      col1(30)    TYPE c,
      col2(30)    TYPE c,
      col3(30)    TYPE c,
      END OF t_datatab.

parameters: p_file type string.
DATA: i_tab TYPE STANDARD TABLE OF t_datatab.
    DATA: lv_rc     TYPE i,
          lt_files  TYPE filetable.
at selection-screen on value-request for p_file.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog(
        CHANGING
          file_table              = lt_files
          rc                      = lv_rc
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5
      ).
      IF lv_rc GT 0.
        READ TABLE lt_files INDEX 1 INTO p_file.
      ENDIF.

start-of-selection.
call method cl_gui_frontend_services=>gui_upload(
  EXPORTING
    filename                = p_file
    filetype                = 'ASC'
    has_field_separator     = 'X'
*    header_length           = 0
*    read_by_line            = 'X'
*    dat_mode                = space
    codepage                = '4110'
*    ignore_cerr             = abap_true
*    replacement             = '#'
*    virus_scan_profile      =
*  IMPORTING
*    filelength              =
*    header                  =
  CHANGING
    data_tab                = i_tab
).



1 ACCEPTED SOLUTION

FredericGirod
Active Contributor
2,094

An Xlsx file is not a flat file, you cannot open it using a Notepad.exe on your Windows system. (Like a PDF, a Word doc, .....)

If you need to read a real Excel file (not a CSV) the better is to use the Abap2Xlsx

https://github.com/abap2xlsx/abap2xlsx

https://blogs.sap.com/2018/06/16/using-abap2xlsx-to-send-alv-table-output-as-excel-spreadsheet-via-i...

2 REPLIES 2

FredericGirod
Active Contributor
2,095

An Xlsx file is not a flat file, you cannot open it using a Notepad.exe on your Windows system. (Like a PDF, a Word doc, .....)

If you need to read a real Excel file (not a CSV) the better is to use the Abap2Xlsx

https://github.com/abap2xlsx/abap2xlsx

https://blogs.sap.com/2018/06/16/using-abap2xlsx-to-send-alv-table-output-as-excel-spreadsheet-via-i...

Sandra_Rossi
Active Contributor
2,094

XLSX is a special format. The first layer is a ZIP file (and so you can open it like any ZIP file). Inside the ZIP file, you have essentially XML files. It's documented by Microsoft (Office Open XML).

As the format is quite complex, there was a community project: abap2xlsx (which reads and writes XLSX files)