ABAP : How to create dynamic tables and structures

preview_player
Показать описание
This video demonstrates how to create dynamic tables and structures in the ABAP programming language.
Рекомендации по теме
Комментарии
Автор

Your presentation is excellent; however, please keep the video quality high as we were unable to adequately see the code.

pwfqten
Автор

Code from video:



Data: lo_struct type REF TO cl_abap_structdescr,
lo_table TYPE REF TO cl_abap_tabledescr,
lo_datareftab type REF TO data,
lo_datarefstruct type ref to data.

Data: li_comp type cl_abap_structdescr=>component_table,
ls_comp like LINE OF li_comp.

FIELD-SYMBOLS: <li_table> type STANDARD TABLE,
<ls_struct> type ANY.

ls_comp-name = 'VBLEN'.
ls_comp-type =

APPEND ls_comp to li_comp.
FREE ls_comp.

ls_comp-name = 'POSNR'.
ls_comp-type =

APPEND ls_comp to li_comp.
FREE ls_comp.

lo_struct = cl_abap_structdescr=>create( li_comp ).
lo_table = cl_abap_tabledescr=>create( p_line_type = lo_struct ).

CREATE DATA lo_datareftab TYPE HANDLE lo_table.
ASSIGN lo_datareftab->* to <li_table>.

CREATE DATA lo_datarefstruct type HANDLE lo_struct.
ASSIGN lo_datarefstruct->* TO <ls_struct>.

ASSIGN COMPONENT 'VBLEN' of STRUCTURE <ls_struct> to FIELD-SYMBOL(<lv_vblen>).
if <lv_vblen> is ASSIGNED.
<lv_vblen> =
endif.

ASSIGN COMPONENT 'POSNR' of STRUCTURE <ls_struct> to FIELD-SYMBOL(<lv_posnr>).
if <lv_posnr> is ASSIGNED.
<lv_posnr> = '000010'.
endif.

APPEND <ls_struct> to <li_table>.

cl_demo_output=>display( <li_table> ).

tiagopinto