[ABAP]EXCEL파일 INTERNAL 테이블로 만들기

SAPWISE·2023년 8월 16일
0
"EXCEL READ
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.


  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.
    clear : it_excel, it_excel[].
  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_itab to <fs1>.
    <fs1> = it_excel-value.
    at end of row.
*    MOVE-CORRESPONDING: GS_itab TO GT_itab.
      append gs_itab to gt_itab.
      clear gs_itab.
    endat.
  endloop.
profile
SAP, ERP, ABAP

1개의 댓글

comment-user-thumbnail
2023년 8월 16일

좋은 정보 감사합니다

답글 달기

관련 채용 정보