Code: Alles auswählen.
REPORT z_einlesen_2.
DATA: itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA: wa_itab LIKE LINE OF itab.
TYPES: BEGIN OF t_record,
spalte1 LIKE alsmex_tabline-value,
spalte2 LIKE alsmex_tabline-value,
spalte3 LIKE alsmex_tabline-value,
spalte4 LIKE alsmex_tabline-value,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'C:\Test\Input.xls'
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '4'
i_end_row = '10'
TABLES
intern = itab
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT itab.
AT NEW row.
APPEND wa_record TO it_record.
ENDAT.
CASE itab-col.
WHEN 1.
wa_record-spalte1 = itab-value.
WHEN 2.
wa_record-spalte2 = itab-value.
WHEN 3.
wa_record-spalte3 = itab-value.
WHEN 4.
wa_record-spalte4 = itab-value.
ENDCASE.
ENDLOOP.
APPEND wa_record TO it_record.
LOOP AT it_record INTO wa_record.
WRITE: / sy-tabix, wa_record-spalte1, 35 wa_record-spalte2, 55
wa_record-spalte3, 75 wa_record-spalte4.
ENDLOOP.
Code: Alles auswählen.
AT NEW row.
APPEND wa_record TO it_record.
ENDAT.
Code: Alles auswählen.
AT END OF row.
APPEND wa_record TO it_record.
ENDAT.