*----------------------------------------------------------------------* * FORM READ_XLS * *----------------------------------------------------------------------* FORM read_xls. TYPES: BEGIN OF ty_xlstab, row(8) TYPE N, col(4) TYPE N, value(50) TYPE C, END OF ty_xlstab. DATA lt_itab TYPE STANDARD TABLE OF ty_xlstab. DATA ls_itab LIKE LINE OF lt_itab. DATA: lv_xlsname LIKE rlgrap-filename, lv_brow TYPE I VALUE -9997, lv_erow TYPE I, lt_itab2 LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE. lv_xlsname = pa_file. WHILE lv_erow < pa_nlin. ADD 9999 TO lv_brow. ADD 9999 TO lv_erow. CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING filename = lv_xlsname i_begin_col = '1' i_begin_row = lv_brow i_end_col = '5' i_end_row = lv_erow TABLES intern = lt_itab2. LOOP AT lt_itab2. ls_itab-row = lt_itab2-row + lv_brow - 1. ls_itab-col = lt_itab2-col. ls_itab-value = lt_itab2-value. APPEND ls_itab TO lt_itab. ENDLOOP. ENDWHILE. SORT lt_itab BY row col. LOOP AT lt_itab INTO ls_itab. CASE ls_itab-col. WHEN '0001'. gs_in-kunnr = ls_itab-value. WHEN '0002'. gs_in-vkorg = ls_itab-value. WHEN '0003'. gs_in-vtweg = ls_itab-value. WHEN '0004'. gs_in-spart = ls_itab-value. WHEN '0005'. gs_in-kvgr3 = ls_itab-value. ENDCASE. AT END OF row. APPEND gs_in TO gt_in. ENDAT. ENDLOOP. ENDFORM. "read_xls
lunedì 4 agosto 2014
Leggere un file di Excel con più di 10.000 righe
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento