Code: Alles auswählen.
*----------------------------------------------------------------------*
* T A B L E S
*----------------------------------------------------------------------*
TABLES: eina, "Einkaufsinfosatz - allgemeine Daten
eine, "Einkaufsinfosatz - Einkaufsorganisationsdaten
konh. "Konditionen (Kopf)
DATA: l_typedescr_ref TYPE REF TO cl_abap_typedescr,
l_strucdescr_ref TYPE REF TO cl_abap_structdescr,
l_tabledescr_ref TYPE REF TO cl_abap_tabledescr,
it_components TYPE cl_abap_structdescr=>component_table,
it_components_help TYPE cl_abap_structdescr=>component_table,
wa_components LIKE LINE OF it_components,
l_data_ref TYPE REF TO data,
l_data_help_ref TYPE REF TO data.
*----------------------------------------------------------------------*
* F I E L D - S Y M B O L S
*----------------------------------------------------------------------*
* Field-Symbols for dynamic table
FIELD-SYMBOLS: <fs_components> LIKE LINE OF it_components,
<fs_data> TYPE STANDARD TABLE,
<fs_data_help> TYPE STANDARD TABLE,
<fs_datensatz> TYPE ANY,
<fs_daten> TYPE ANY.
Code: Alles auswählen.
"Strukturbeschreibung abfragen
l_typedescr_ref = cl_abap_typedescr=>describe_by_name( 'EINA' ).
"Strukturbeschreibung casten
l_strucdescr_ref ?= l_typedescr_ref.
"Komponenten der Struktur in interner Tabelle speichern
it_components = l_strucdescr_ref->get_components( ).
l_typedescr_ref = cl_abap_typedescr=>describe_by_name( 'EINE' ).
l_strucdescr_ref ?= l_typedescr_ref.
it_components_help = l_strucdescr_ref->get_components( ).
"Felder aus EINA/EINE zusammenfügen
LOOP AT it_components_help INTO wa_components.
"MANDT/INFNR wäre sonst doppelt, ebenso gibt es ein Append in der EINE-Struktur, was ein leeren Feldnamen in it_components zur Folge hat
IF wa_components-name IS NOT INITIAL AND wa_components-name NE 'MANDT' AND wa_components-name NE 'INFNR'.
APPEND wa_components TO it_components.
ENDIF.
ENDLOOP.
TRY.
CALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components = it_components
* p_strict = TRUE
RECEIVING
p_result = l_strucdescr_ref
.
CATCH cx_sy_struct_creation .
ENDTRY.
TRY.
CALL METHOD cl_abap_tabledescr=>create
EXPORTING
p_line_type = l_strucdescr_ref
* p_table_kind = TABLEKIND_STD
* p_unique = ABAP_FALSE
* p_key =
* p_key_kind = KEYDEFKIND_DEFAULT
RECEIVING
p_result = l_tabledescr_ref
.
CATCH cx_sy_table_creation .
ENDTRY.
CREATE DATA l_data_ref TYPE HANDLE l_tabledescr_ref.
ASSIGN l_data_ref->* TO <fs_data>.
Code: Alles auswählen.
SELECT *
FROM eina AS a
INNER JOIN eine AS b ON a~infnr = b~infnr
INTO CORRESPONDING FIELDS OF TABLE <fs_data>
WHERE lifnr = '0000000001'.
Code: Alles auswählen.
LOOP AT it_components_help INTO wa_components.
if wa_components-name is not initial.
APPEND wa_components TO it_components.
endif.
ENDLOOP.
l_typedescr_ref = cl_abap_tabledescr=>describe_by_data( it_components ).
l_strucdescr_ref ?= l_typedescr_ref. "<- hier kommts zum Dump "MOVE_CAST_ERROR"
Code: Alles auswählen.
l_typedescr_ref = cl_abap_tabledescr=>describe_by_NAME( 'EINE' ).
l_strucdescr_ref ?= l_typedescr_ref.
Code: Alles auswählen.
ALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components = it_components
* p_strict = TRUE
RECEIVING
p_result = l_strucdescr_ref
.