on 02-25-2011 5:23 AM
Hi,
i have one node which is built dynamically with five attributes, when i use this node to pass data to alv using set_data method of alv interface controller it is not working, if i pass other node which is created statically it is working.
so what i can infer from this is set_data takes only static attributes not the dynamic attributes, what i am trying to create is i am assigning static attributes to this dynamically created node by creating internal table dynamically using (dynamic)attributes of this node.
so when i use set_static_attributes method, it is showing dump at this point ( from st22 )
1 method if_wd_context_element~set_static_attributes.
2
3 data: client_component type ref to cl_wdr_client_component,
4 l_name type string.
5
6 field-symbols:
7 <fs> type data,
8 <component> like line of me->node_info->static_element_rtti->components.
9
10 if me->is_finalized = abap_true or me->is_static_finalized = abap_true.
11 me->_temp_buffer = me->if_wd_context_element~get_path( ).
12 raise exception type cx_wd_context exporting textid = cx_wd_context=>finalized element_n
13 endif.
14
15 assign me->static_attributes->* to <fs>.
16 if static_attributes is supplied.
>>>> move-corresponding static_attributes to <fs>.
18 else.
19 clear <fs>.
20 endif.
below is the code snippet i am using
lr_table_result = wd_context->get_child_node( 'RESULT_TABLE' ).
lr_node_info = lr_table_result->get_node_info( ).
lt_attributes_info = lr_node_info->get_attributes( ).
Build dynamic internal table
LOOP AT lt_attributes_info INTO ls_attributes_info.
CLEAR: ls_comp.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_attributes_info-reference_field ).
ls_comp-name = ls_attributes_info-name.
APPEND ls_comp TO lt_components.
ENDLOOP.
DESCRIBE TABLE lt_components LINES lv_lines.
Create dynamic structure and table
lr_sdescr_new = cl_abap_structdescr=>create( lt_components ).
lr_tdescr = cl_abap_tabledescr=>create( lr_sdescr_new ).
" Create data refence followed by table creation
CREATE DATA lr_handle TYPE HANDLE lr_sdescr_new.
ASSIGN lr_handle->* TO <ls_wa>.
Read dynamic attributes and create static attributes
because method set_data will not work with dynamic attributes
Get all elements
lt_elements = lr_table_result->get_elements( ).
LOOP AT lt_elements INTO lr_element.
for each element get the attribute values
LOOP AT lt_components INTO ls_comp.
lv_tabix = sy-tabix.
ASSIGN COMPONENT lv_tabix OF STRUCTURE <ls_wa> TO <lv_fname>.
lr_element->get_attribute( EXPORTING name = ls_comp-name
IMPORTING value = <lv_fname> ).
ENDLOOP.
lr_element->set_static_attributes( <ls_wa> ).
ENDLOOP.
how can i assing the static attributes?? is it not possible??
i just read the documentation, it is not possible to pass dynamic context node to set_data method.
http://help.sap.com/saphelp_em70/helpdata/en/42/b9ea094f4a3118e10000000a1553f7/content.htm
Edited by: kranthi kumar on Feb 25, 2011 1:28 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Karanthi,
it is very much possible to bind DYNAMIC created node to the alav data node. see my code snippet
data:
lo_parent_node_info type ref to if_wd_context_node_info,
lo_child_node_info type ref to if_wd_context_node_info,
lv_struct_name type string,
lo_nd_gen_tab type ref to if_wd_context_node,
lo_interfacecontroller type ref to iwci_salv_wd_table,
lt_child_node_map type wdr_context_child_info_map.
lo_parent_node_info = wd_context->get_node_info( ).
* " get child node info
*
lt_child_node_map = lo_parent_node_info->get_child_nodes( ).
read table lt_child_node_map transporting no fields with table key name = `DYNAMIC_TBL`.
if sy-subrc = 0.
" REMOVE_CHILD_NODE
lo_parent_node_info->remove_child_node( `DYNAMIC_TBL` ).
endif.
lv_struct-name = <assign ddic struc name>.
call method lo_parent_node_info->add_new_child_node
exporting
* supply_method =
* supply_object =
* dispose_method =
* dispose_object =
static_element_type = lv_struct_name
name = `DYNAMIC_TBL`
* is_mandatory = ABAP_FALSE
* is_mandatory_selection = ABAP_FALSE
is_multiple = abap_true
* is_multiple_selection = ABAP_TRUE
* is_singleton = ABAP_FALSE
* is_initialize_lead_selection = ABAP_TRUE
* static_element_rtti = lv_struct_name
is_static = abap_false
* attributes =
receiving
child_node_info = lo_child_node_info
.
if not lo_child_node_info is initial.
lo_nd_gen_tab = wd_context->get_child_node( name = `DYNAMIC_TBL` ).
lo_interfacecontroller = wd_this->wd_cpifc_usage_alv( ).
lo_interfacecontroller->set_data(
* only_if_new_descr = " wdy_boolean
r_node_data = lo_nd_gen_tab " ref to if_wd_context_node
).
wd_this->alv_config_table = wd_this->lo_ref_alv_controller->get_model( ).
wd_this->configure_alv( ).
endif.
Baskaran,
i agree, it is very much possible to assign dynamically created node to alv, however data is not getting displayed!!!
that's is my actual problem, that is the reason i was reading these dynamic attributes and trying to assign to static attributes ( though logically it does not make sense, as we dont have static attributes ).
Hi,
it is working for me, very simple coding. one thing i forgot in my above code is that you need to bind a table to the dynamically created node for data population
if not lo_child_node_info is initial.
lo_nd_gen_tab = wd_context->get_child_node( name = `DYNAMIC_TBL` ).
"insert your dat population code here for binding lo_nd_gen_tab
lo_interfacecontroller = wd_this->wd_cpifc_usage_alv( ).
lo_interfacecontroller->set_data(
only_if_new_descr = " wdy_boolean
r_node_data = lo_nd_gen_tab " ref to if_wd_context_node
).
wd_this->alv_config_table = wd_this->lo_ref_alv_controller->get_model( ).
wd_this->configure_alv( ).
endif.
baskaran,
its not working for me, i am confused because i can see the data in the node using debugger but in the out put empty table is being dispalyed.
i was assuming this is sap functionality ( not displaying data for alv using dynamically created nodes ) as sap help is testimony for that
[http://help.sap.com/saphelp_em70/helpdata/en/42/b9ea094f4a3118e10000000a1553f7/content.htm]
under context node section..
Thanks,
Kranthi.
>
> its not working for me, i am confused because i can see the data in the node using debugger but in the out put empty table is being dispalyed.
>
Hallo Kranthi,
what is not working for you. Have you changed your code and do what i posted or you kept your code and trying to modify ?.
Create your Dynamic node like below and bind the node with table data. Use set method of aLV controller to set the data.
lv_struct-name = <assign ddic struc name>.
call method lo_parent_node_info->add_new_child_node
exporting
supply_method =
supply_object =
dispose_method =
dispose_object =
static_element_type = lv_struct_name
name = `DYNAMIC_TBL`
is_mandatory = ABAP_FALSE
is_mandatory_selection = ABAP_FALSE
is_multiple = abap_true
is_multiple_selection = ABAP_TRUE
is_singleton = ABAP_FALSE
is_initialize_lead_selection = ABAP_TRUE
static_element_rtti = lv_struct_name
is_static = abap_false
attributes =
receiving
child_node_info = lo_child_node_info
.
Hi Baskaran,
the difficulty for me is dynamic node and dynamic attribues creation is done by sap all i can do is write post exit for wddomodifyview and use api to change those created node and attribute properties created dynamically.
below is code snippet which sap is used to create dynamic node and also attributes are not coming from static structure type or static rtti type instead they have created dynamically using add_attribute method of if_wd_context_node_info, that is why i think it is not working.
Create dynamic context node RESULT_TABLE
CALL METHOD lr_root_node_info->add_new_child_node
EXPORTING
name = lv_node_name
is_mandatory = abap_false
is_mandatory_selection = abap_false
is_multiple = abap_true
is_multiple_selection = abap_true
is_singleton = abap_true
is_initialize_lead_selection = abap_false
is_static = abap_false
RECEIVING
child_node_info = lr_child_node_info.
Fill context node attributes info (ls_attribute_info)
ls_attribute_info-name = lv_column_id.
ls_attribute_info-type_name = ls_fielddescr-rollname.
ls_attribute_info-node_info = lr_child_node_info.
ls_attribute_info-is_static = abap_false.
Add attribute to context node.
CALL METHOD lr_child_node_info->add_attribute
EXPORTING
attribute_info = ls_attribute_info
in this case i dont have static_element_type or static_element_rtti instead attributes are created dynamically .
even while creation of attribute sap is not using is_static of structure ls_attribute_info as it is suggested in some other post given by sarbjeet.
Please suggest if there is any api which i can use to change the properties( which you guys suggested) of dynamically created node and attribute as i said above.
and also what i can observe from the code snippets so far we had, it is not possible for set_data method of alv to get data from a node where node is dynamic and attribues are also dynamic,
atleast attributes should be static even though node is dynamic, this will work as you suggested.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.