"Версия SAP Netweaver ниже 7.4
REPORT zab_demo.
TYPES:
BEGIN OF ty_connection,
connid TYPE s_conn_id,
END OF ty_connection.
DATA:
flight TYPE sflight,
flights TYPE STANDARD TABLE OF sflight,
connection_structured TYPE ty_connection,
connections_structured TYPE STANDARD TABLE OF ty_connection,
connections_unstructured TYPE STANDARD TABLE OF s_conn_id.
SELECT * FROM sflight INTO TABLE flights UP TO 10 ROWS.
LOOP AT flights INTO flight.
connection_structured-connid = flight-connid.
APPEND connection_structured TO connections_structured.
ENDLOOP.
LOOP AT flights INTO flight.
APPEND flight-connid TO connections_unstructured.
ENDLOOP.
" Версия SAP Netweaver выше 7.4 с встроенными объявлениями данных
REPORT zab_demo2.
"Types can be of course from Data Dictionary, here we define types for demonstaration purpose only.
TYPES:
BEGIN OF ty_connection,
connid TYPE s_conn_id,
END OF ty_connection.
TYPES:
BEGIN OF ty_cat,
cat TYPE s_conn_id,
END OF ty_cat.
TYPES ty_connections TYPE STANDARD TABLE OF ty_connection WITH NON-UNIQUE KEY connid.
DATA:
connections_structured2 TYPE ty_connections,
connections_unstructured TYPE STANDARD TABLE OF s_conn_id,
cats_structured TYPE STANDARD TABLE OF ty_cat WITH NON-UNIQUE KEY cat.
SELECT * FROM sflight INTO TABLE @DATA(flights) UP TO 10 ROWS.
DATA(connections_structured) = CORRESPONDING ty_connections( flights ).
connections_structured2 = CORRESPONDING #( flights ).
"FOR can be combined with REDUCE, WHERE, FILTER and INIT, to get out more from BI Queries
DATA(connections_structured3) = VALUE ty_connections( FOR flight IN flights ( connid = flight-connid ) ).
"Of course you can cut out 2 of 3 columns also, here we cut only one out
connections_unstructured = VALUE #( FOR flight IN flights ( flight-connid ) ).
"Move column to other internal table with different field name
cats_structured = CORRESPONDING #( flights MAPPING cat = connid ).
"Move column to other internal table with different type
connections_unstructured = VALUE string_table( FOR flight IN flights ( CONV string( flight-connid ) ) ).