I know of function module ALSM_EXCEL_TO_INTERNAL_TABLE. This FM creates an internal table with three columns (row, column, value). But I want to create an internal table which has the same layout as my Excel sheet. How can I achieve this?
You can use class cl_mass_spreadsheet_service if you are uploading the excel in foreground. See my example code below:
DATA:
lv_file TYPE if_mass_spreadsheet_types=>file_name,
lt_result TYPE STANDARD TABLE OF zsd_salesorder_create. "your result table
lv_file = 'C:\some_file.xlsx'.
cl_mass_spreadsheet_service=>fill_table(
EXPORTING
iv_file = lv_file "full path+name of file. See method navigate_to_file below
iv_from_file = abap_true "use to upload from excel/CSV
iv_from_clipboard = abap_false "use to copy directly from clipbiard
iv_tabname = 'Order_Create' "can be whatever
CHANGING
ct_table = lt_result "if ct_table have the same column names as the excel file, the order of the columns does not matter
).