TYPES: BEGIN OF ty_s_tableline,
matnr TYPE matnr,
spras TYPE spras,
maktx TYPE maktx,
END OF ty_s_tableline.
TYPES: ty_it_table TYPE STANDARD TABLE OF ty_s_tableline WITH DEFAULT KEY.
START-OF-SELECTION.
TRY.
* Open Cursor and SELECT mit UPPER-CASE-Funktion
* ist im Standard-OpenSQL nicht möglich
EXEC SQL.
OPEN dbcur FOR
SELECT matnr,
spras,
maktx
FROM makt
WHERE spras = 'D'
AND UPPER(maktx) LIKE 'SCH%'
ENDEXEC.
IF sy-subrc = 0.
DATA: lv_line TYPE ty_s_tableline.
DATA: it_table TYPE ty_it_table.
* Loop Cursor Data
DO.
* DB-Cursor auf nächsten Datensatz setzen, solange, wie Daten vorhanden sind
EXEC SQL.
FETCH NEXT dbcur INTO :lv_line
ENDEXEC.
IF sy-subrc = 0.
* Daten an itab anfügen
APPEND lv_line TO it_table.
ELSE.
EXIT.
ENDIF.
ENDDO.
* Close Cursor
EXEC SQL.
CLOSE dbcur
ENDEXEC.
* Daten ausgeben
cl_demo_output=>display( it_table ).
ENDIF.
CATCH cx_sy_native_sql_error INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.