Bsp. für SELECT auf IT
Funktioniert erst ab ABAP 7.52
Daher ist der Code erst ab dieser Version aktivierbar
*&---------------------------------------------------------------------*
*& Report ZTEST39
*&
*&---------------------------------------------------------------------*
*&
*& Demonstration of SQL on Internal Table Supported by OpenSQL
*% Since ABAP 7.52
*&---------------------------------------------------------------------*
REPORT ztest39.
TYPES: BEGIN OF ts_table,
id TYPE i,
name TYPE char5,
END OF ts_table.
DATA itab TYPE SORTED TABLE OF ts_table WITH UNIQUE KEY id.
itab = VALUE #( ( id = 1 name = 'one' )
( id = 2 name = 'two')
( id = 3 name = 'three' ) ).
DATA result1 LIKE itab.
TRY.
IF NOT cl_abap_dbfeatures=>use_features(
EXPORTING
requested_features =
"Error because feature is not suppoerted
"Programm cannot be activated
VALUE #( ( cl_abap_dbfeatures=>itabs_in_from_clause ) ) ).
"VALUE #( ( cl_abap_dbfeatures=>external_views ) ) ).
cl_demo_output=>display(
`System does not support internal tables as data source` ).
RETURN.
ENDIF.
cl_demo_output=>display(
`System does not support internal tables as data source` ).
CATCH cx_abap_invalid_param_value.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDTRY.
"First Query with Where clause
SELECT id , name
FROM @itab AS numbers
WHERE id = 2
INTO TABLE @result1
##db_feature_mode[itabs_in_from_clause]. "Unterdrückt das Warning beim Syntax-Check.
cl_demo_output=>write( result1 ).
"Selection of few columns
SELECT id AS number
FROM @itab AS numbers
INTO TABLE @DATA(result2).
cl_demo_output=>display( result2 ).