Code: Alles auswählen.
REPORT Z_TESTTEST.
TYPE-POOLS: abap.
DATA: obj_table2 TYPE REF TO cl_abap_tabledescr,
obj_struc2 TYPE REF TO cl_abap_structdescr.
DATA: lt_component TYPE abap_component_tab,
wa_component TYPE abap_componentdescr.
DATA: obj_data2 TYPE REF TO data.
FIELD-SYMBOLS:
<table2> TYPE ANY TABLE,
<wa> type any.
DATA Name_neu TYPE c LENGTH 10 VALUE 'Spalte'.
DATA index_neu TYPE c LENGTH 1.
DATA final TYPE c LENGTH 14.
DO 4 TIMES.
index_neu = sy-index.
CONCATENATE Name_neu index_neu INTO final .
CLEAR wa_component.
wa_component-name = final.
wa_component-type ?= cl_abap_typedescr=>describe_by_name( 'STRING' ).
INSERT wa_component INTO TABLE lt_component.
enddo.
obj_struc2 = cl_abap_structdescr=>create( lt_component ).
CALL METHOD cl_abap_tabledescr=>create
EXPORTING
p_line_type = obj_struc2
RECEIVING
p_result = obj_table2.
REFRESH: lt_component.
CREATE DATA obj_data2 TYPE HANDLE obj_table2.
ASSIGN obj_data2->* TO <table2>.
ASSIGN obj_data2->* TO <wa>.
*** Dieser Teil funktioniert leider nicht
DATA text TYPE string VALUE '<wa>-Spalte1'.
FIELD-SYMBOLS <fs> TYPE any.
ASSIGN (text) to <fs>.
Write <fs>.
Code: Alles auswählen.
DATA text TYPE string VALUE '<wa>-Spalte1'.
FIELD-SYMBOLS <fs> TYPE any.
ASSIGN text to <fs>.
Write <fs>.
Code: Alles auswählen.
<fs> = 'Hallo'.
insert <wa> into table <itab>. " und in <itab> gibt es jetzt eine Zeile, wo bei Spaltenname "Spalte1" Hallo drinne steht.
Code: Alles auswählen.
DATA text TYPE string VALUE '<WA>-SPALTE1'.
Code: Alles auswählen.
data: text type string value 'SPALTE1'.
field-symbols: <fs> type any.
assign component text of structure <ws> to <fs>.
write <fs>.
" PsychoMantisfolgendes sollte eigentlich funktionieren:
Code: Alles auswählen.
REPORT Z_TESTTEST.
TYPE-POOLS: abap.
DATA: obj_table2 TYPE REF TO cl_abap_tabledescr,
obj_struc2 TYPE REF TO cl_abap_structdescr.
DATA: lt_component TYPE abap_component_tab,
wa_component TYPE abap_componentdescr.
DATA: obj_data2 TYPE REF TO data.
FIELD-SYMBOLS:
<table2> TYPE ANY TABLE,
<wa> type any.
DATA Name_neu TYPE c LENGTH 10 VALUE 'SPALTE'.
DATA index_neu TYPE c LENGTH 1.
DATA final TYPE c LENGTH 14.
DO 4 TIMES.
index_neu = sy-index.
CONCATENATE Name_neu index_neu INTO final .
CLEAR wa_component.
wa_component-name = final.
wa_component-type ?= cl_abap_typedescr=>describe_by_name( 'STRING' ).
INSERT wa_component INTO TABLE lt_component.
enddo.
obj_struc2 = cl_abap_structdescr=>create( lt_component ).
CALL METHOD cl_abap_tabledescr=>create
EXPORTING
p_line_type = obj_struc2
RECEIVING
p_result = obj_table2.
REFRESH: lt_component.
CREATE DATA obj_data2 TYPE HANDLE obj_table2.
ASSIGN obj_data2->* TO <table2>.
insert initial line into table <table2>.
*** Dieser Teil funktioniert leider nicht
DATA text TYPE string VALUE 'SPALTE1'.
FIELD-SYMBOLS <fs> TYPE any.
loop at <table2> assigning <wa>.
ASSIGN component text of structure <wa> to <fs>.
Write <fs>.
endloop.
Code: Alles auswählen.
REPORT z_testtest.
TYPE-POOLS: abap.
DATA: obj_table2 TYPE REF TO cl_abap_tabledescr,
obj_struc2 TYPE REF TO cl_abap_structdescr.
DATA: lt_component TYPE abap_component_tab,
wa_component TYPE abap_componentdescr.
DATA: obj_data2 TYPE REF TO data.
FIELD-SYMBOLS:
<table2> TYPE ANY TABLE,
<wa>,
<fs>.
DATA name_neu TYPE c LENGTH 10 VALUE 'Spalte'.
DATA index_neu TYPE c LENGTH 1.
DATA final TYPE c LENGTH 14.
DO 4 TIMES.
index_neu = sy-index.
CONCATENATE name_neu index_neu INTO final .
CLEAR wa_component.
wa_component-name = final.
wa_component-type ?= cl_abap_typedescr=>describe_by_name( 'STRING' ).
INSERT wa_component INTO TABLE lt_component.
ENDDO.
obj_struc2 = cl_abap_structdescr=>create( lt_component ).
CALL METHOD cl_abap_tabledescr=>create
EXPORTING
p_line_type = obj_struc2
RECEIVING
p_result = obj_table2.
CREATE DATA obj_data2 TYPE HANDLE obj_table2.
ASSIGN obj_data2->* TO <table2>.
LOOP AT <table2> ASSIGNING <wa>.
LOOP AT lt_component INTO wa_component.
TRANSLATE wa_component-name TO UPPER CASE.
ASSIGN COMPONENT wa_component-name OF STRUCTURE <wa> TO <fs>.
IF <fs> IS ASSIGNED.
WRITE <fs>.
ENDIF.
ENDLOOP.
ENDLOOP.