请问在SAP里怎样上传EXCEL数据到数据库表

2024-12-23 02:55:55
推荐回答(1个)
回答1:

DATA : BEGIN OF itab1 OCCURS 100, matnr(18)TYPE c, erfmg(13)TYPE c, erfme(3) TYPE c, have TYPE i,END OF itab1. CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING filename = p_file i_begin_col = 1 i_begin_row = 1 i_end_col = 256 i_end_row = 65536 TABLES intern = itab EXCEPTIONS inconsistent_parameters = 1 upload_ole = 2 OTHERS = 3.IF sy-subrc NE 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.SORT itab BY row col.CLEAR itab1. REFRESH itab1.LOOP AT itab. CASE itab-col. WHEN 1. itab1-matnr = itab-value. WHEN 2. itab1-erfmg = itab-value. WHEN 3. itab1-erfme = itab-value. ENDCASE. AT END OF row. APPEND itab1. CLEAR itab1. ENDAT.ENDLOOP.