cancel
Showing results for 
Search instead for 
Did you mean: 

Error while binding data into Node which is Created Dynamically.

Former Member
0 Kudos

Hi All

We have a scenario , which is to create the Context and its attribute dynamically at runtime. When I create the context with structure. Using the method <b>‘create_nodeinfo_from_struct()’</b>.here the attributes under the created node is automatically taken from the provided structure ‘SPFLI’.

cl_wd_dynamic_tool=>create_nodeinfo_from_struct(

parent_info = rootnode_info

node_name = ‘DYN’

structure_name = ‘SPFLI’

is_multiple = abap_true ).

Using the above method it is working fine and I could bind the value into the node.

But our scenario is to create context and its attributes without giving any predefined structure. We need to add attributes manually giving one by one.

For that I have used the method ‘rootnode_info->add_new_child_node’ &

dyn_node->add_attribute( exporting attribute_info = ls_attribute ).

But am getting short dumb showing <b>‘Line types of an internal table and a work area not compatible’.</b>

Please give me a solution..

I used the following code….

data:

rootnode_info type ref to if_wd_context_node_info,

dyn_node type ref to if_wd_context_node,

data :ls_attribute type wdr_context_attribute_info.

rootnode_info = wd_context->get_node_info( ).

call method rootnode_info->add_new_child_node

exporting

  • SUPPLY_METHOD =

  • SUPPLY_OBJECT =

  • DISPOSE_METHODS =

  • DISPOSE_OBJECT =

  • STATIC_ELEMENT_TYPE =

name = 'DYN'

is_mandatory = abap_false

is_mandatory_selection = abap_false

is_multiple = abap_true

is_multiple_selection = abap_false

is_singleton = abap_true

is_initialize_lead_selection = abap_true

  • STATIC_ELEMENT_RTTI =

is_static = abap_false

  • ATTRIBUTES =

receiving

child_node_info = node_nsp

.

ls_attribute-name = 'CARRID'.

ls_attribute-type_name = 'S_CARR_ID'.

ls_attribute-value_help_mode = '0'.

node_nsp->add_attribute( exporting attribute_info = ls_attribute ).

ls_attribute-name = 'CONNID'.

ls_attribute-type_name = 'S_CONN_ID'.

ls_attribute-value_help_mode = '0'.

node_nsp->add_attribute( exporting attribute_info = ls_attribute ).

DATA : BEGIN OF str,

carrid TYPE s_carr_id,

connid TYPE s_conn_id,

END OF str.

DATA : it_str LIKE TABLE OF str.

select carrid connid from spfli into corresponding fields of table it_str

dyn_node = wd_context->get_child_node( name = 'DYN' ).

dyn_node->bind_table( it_str ).

data: l_ref_cmp_usage type ref to if_wd_component_usage.

l_ref_cmp_usage = wd_this->wd_cpuse_alv_usage( ).

if l_ref_cmp_usage->has_active_component( ) is initial.

l_ref_cmp_usage->create_component( ).

endif.

data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .

l_ref_interfacecontroller = wd_this->wd_cpifc_alv_usage( ).

l_ref_interfacecontroller->set_data(

r_node_data = dyn_node " Ref to if_Wd_Context_Node

).

Thanks in advance..

Nojish

Message was edited by:

nojish p

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nojish.

I gues the error happens when you try to read the static attributes of an element of

you dynamic node. This does not work using your defined type str, cause with

get_static_attribute you only receive the static and not the dynamic attributes.

Static attributes are attributes that are defined at design time. Thats why the

structure does not match.

But you can use the following code to get your dynamic attributes, for example

getting the lead selection element and the attribute carrid:

dyn_node = wd_context->get_child_node( name = 'DYN' ).
  lr_elelement = dyn_node->get_element( ).
  lr_el->get_attribute(
    EXPORTING
      name = 'CARRID'
    IMPORTING
      value = lv_carrid
  ).

Hope this helps.

PS: Or do you get the reerror in above code? Your code works here. If so pls provide short dump.

Cheers,

Sascha

Message was edited by:

Sascha Dingeldey

Former Member
0 Kudos

Hi Sascha Dingeldey

Thanks for looking into the issue..

As I thought the error is not with binding node . I have checked the ‘ dyn_node’ Binding was successful. After that I am passing this node to ALV using l_ref_interfacecontroller->set_data(r_node_data = dyn_node ).

Here am getting the exact error.As you mentioned , while using ALV internal methods may try to read the static attributes of the dynamic node.

Could you give any solution for passing the dynamic node to ALV in this case.

Regards

Nojish

Former Member
0 Kudos

Hi Nojish.

This problem is handled in this <a href="https://forums.sdn.sap.com/click.jspa?searchID=2479152&messageID=2832019">thread</a>.

Just come back if you still have questions.

Cheers,

Sascha

Former Member
0 Kudos

Hi Sascha Dingeldey

I have tried with that example, It is working fine .

Problem is solved.

Thanks a lot..

Nojish

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Nojish,

I checked everything in my system. It is working fine also. I executed the same code and working fine and adding the records also to the context node. Just check that may be you are gettting the error in some other method not in the following method.

Am I correct?????

Warm Regards,

Vijay.