2009 Sep 08 1:20 PM
Hi,
In webdynpro for abap, I want to create a node dynamically based on either of the following inputs.
1. Fieldcatalog.
2. Dynamically generated to-be contents of the node from a function module i.e. some internal table.
Can somebody help me in this regard.
Regards,
Soumya
Hi,
In webdynpro for abap, I want to create a node dynamically based on either of the following inputs.
1. Fieldcatalog.
2. Dynamically generated to-be contents of the node from a function module i.e. some internal table.
Can somebody help me in this regard.
Regards,
Soumya
2009 Oct 07 1:25 PM
Above problem is solved with the following solution.
DATA: ls_component TYPE cl_abap_structdescr=>component,
lr_type TYPE REF TO cl_abap_datadescr,
lt_components TYPE cl_abap_structdescr=>component_table,
ls_fieldcatlog TYPE LINE OF lvc_t_fcat.
LOOP AT lt_fieldcatlog INTO ls_fieldcatlog.
lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = lt_fieldcatlog-rollname ).
ls_component-name = ls_fieldcatlog-fieldname.
ls_component-type = lr_type .
APPEND ls_component TO lt_components.
ENDLOOP.
******* Next, create a new structure and assign it to a new dynamic context node *******
DATA: lr_root_info TYPE REF TO if_wd_context_node_info ,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_structdescr TYPE REF TO cl_abap_structdescr.
CALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components = lt_components
RECEIVING
p_result = lr_structdescr.
* Get context node info
lr_root_info = wd_context->get_node_info( ).
* Generate new node with the dynamic structure
CALL METHOD lr_root_info->add_new_child_node
EXPORTING
name = 'DYN_NODE'
is_initialize_lead_selection = abap_true
static_element_rtti = lr_structdescr
is_static = abap_false
RECEIVING
child_node_info = lr_node_info.