Here is a very simple program that will capture and write a list of the fields and their definitions of a database table that I have explicitly assigned to a variable using the type statement. I have been playing with this code and attempting to dynamically associate a database table structure with a variable, and then using that variable to assign it's structure to a <FS>. Everything that I tried generated a syntax error.
Could somebody please tell me what syntax I need to dynamically associate a database structure with a variable, versus statically?
This is the code.
data: dr_dref type ref to data,
rf_descr_ref type ref to cl_abap_typedescr .
data: <b>wa_vbap type vbak</b>. " DB table reference
field-symbols: <fs> type any.
Assign every field of this structure to the untyped field symbol.
assign component sy-index of structure <b>WA_vbap</b> to <fs>.
if sy-subrc ne 0.
call method cl_abap_typedescr=>describe_by_data
p_data = <fs>
p_descr_ref = rf_descr_ref.
write: / sy-index, rf_descr_ref->type_kind,