REPORT zzzzztest2 MESSAGE-ID MM-01.
FIELD-SYMBOLS : <fs1> TYPE any.
DATA : GT_EXCEL TYPE TABLE OF MARA,
GS_EXCEL TYPE MARA.
DATA: file_table TYPE filetable,
rc TYPE i,
filedat TYPE string.
DATA : lv_desktop_dir TYPE string.
DATA : filename TYPE rlgrap-filename.
DATA : it_excel TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
wa_itab LIKE LINE OF it_excel.
PARAMETERS: p_file LIKE rlgrap-filename.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
"READ FILE
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = lv_desktop_dir.
CALL METHOD cl_gui_cfw=>update_view.
CLEAR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = space
initial_directory = lv_desktop_dir
file_filter = cl_gui_frontend_services=>filetype_excel
CHANGING
file_table = file_table
rc = rc
EXCEPTIONS
OTHERS = 1.
READ TABLE file_table INTO p_file INDEX 1.
CHECK p_file IS NOT INITIAL.
*--------------------------------------------------------------------*
* START-OF-SELECTION.
*--------------------------------------------------------------------*
START-OF-SELECTION.
"EXCEL TO INTERNAL
clear : it_excel, it_excel[].
if p_file is initial.
message s001 with '업로드 파일이 선택되지 않았습니다.' display like 'E'.
return.
endif.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_file
i_begin_col = 1
i_begin_row = 2
i_end_col = 100
i_end_row = 9999
tables
intern = it_excel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
.
if sy-subrc <> 0.
leave list-processing.
endif.
if it_excel is initial.
return.
endif.
loop at it_excel.
assign component it_excel-col of structure gs_excel to <fs1>.
<fs1> = it_excel-value.
at end of row.
* MOVE-CORRESPONDING: GS_itab TO GT_itab.
append gs_excel to gt_excel.
clear gs_excel.
endat.
endloop.
if sy-subrc ne 0.
message s001 display like 'E' with '파일을 확인해주세요.'.
endif.