Skip to content

Instantly share code, notes, and snippets.

@antelio
Forked from edegula/ABAP_Dynamic_Struct.abap
Last active October 30, 2015 14:32
Show Gist options
  • Save antelio/b7feb50f977c997bacd0 to your computer and use it in GitHub Desktop.
Save antelio/b7feb50f977c997bacd0 to your computer and use it in GitHub Desktop.
ABAP_Dynamic_Struct
*----------------------------------------------------------------
* METHOD create_tab_for_display
* IMPORTING
* edo_table type ref to data
* edo_struc type ref to data.
*----------------------------------------------------------------
method create_tab_for_display.
data:
go_sdescr_new type ref to cl_abap_structdescr,
go_tdescr type ref to cl_abap_tabledescr,
gs_comp type abap_componentdescr,
gt_components type abap_component_tab.
data:
lv_bukrs type bukrs.
* build components
clear gs_comp.
gs_comp-type ?= cl_abap_datadescr=>describe_by_name( 'LFA1-LIFNR' ).
gs_comp-name = 'LIFNR'.
append gs_comp to gt_components.
clear gs_comp.
gs_comp-type ?= cl_abap_datadescr=>describe_by_name( 'CHAR20' ).
gs_comp-name = 'ACTION'.
append gs_comp to gt_components.
loop at gt_bukrs into lv_bukrs.
clear gs_comp.
gs_comp-type ?= cl_abap_datadescr=>describe_by_name( 'ICON_D' ).
concatenate 'BUKRS_' lv_bukrs into gs_comp-name.
append gs_comp to gt_components.
endloop.
clear gs_comp.
gs_comp-type ?= cl_abap_datadescr=>describe_by_name( 'ICON_D' ).
gs_comp-name = 'SUS_ASSIGN'.
append gs_comp to gt_components.
clear gs_comp.
gs_comp-type ?= cl_abap_datadescr=>describe_by_name( 'ICON_D' ).
gs_comp-name = 'PURCH_BLOCK'.
append gs_comp to gt_components.
go_sdescr_new = cl_abap_structdescr=>create( gt_components ).
go_tdescr = cl_abap_tabledescr=>create( go_sdescr_new ).
create data edo_table type handle go_tdescr.
create data edo_struc type handle go_sdescr_new.
endmethod. "create_table_for_display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment