기능 모듈 ALSM_EXCEL_TO_INTERNAL_TABLE을 알고 있습니다. 이 FM은 세 개의 열 (행, 열, 값)이있는 내부 테이블을 만듭니다. 하지만 내 Excel 시트와 동일한 레이아웃을 가진 내부 테이블을 만들고 싶습니다. 이것을 어떻게 할 수 있습니까?동일한 레이아웃의 내부 테이블로 Excel 가져 오기
2
A
답변
2
Excel을 포 그라운드로 업로드하는 경우 cl_mass_spreadsheet_service 클래스를 사용할 수 있습니다. 아래 예제 코드를보십시오 :
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
).
1
FM ALSM_EXCEL_TO_INTERNAL_TABLE을 사용하여 데이터를 업로드하는 경우이 FM이 사용하는 내부 테이블 (위에서 언급 한 행, 열, 값이있는 테이블)을 통해 루프하고 내부 시트 (Excel 시트).
이 클래스는 DDIC 구조체를 필요로하므로 완전히 동적 인 구조 솔루션이 아니지만 어쨌든 기능적입니다. 내가 보았던 것이 더 낫다, 환호! – Suncatcher
이 클래스는 7.40 이후에만 나타 났으며 7.31 이전 시스템에는 존재하지 않습니다. – Suncatcher