cancel
Showing results for 
Search instead for 
Did you mean: 

Filling dynamic context node attributes

Former Member
0 Kudos

Hi Experts,

in a Wed Dynpro Method I built a new context node and created new attributes with a loop and "add_attribute" with the following coding:


data: lr_root_node_info type ref to if_wd_context_node_info,
        lr_table_node_info type ref to if_wd_context_node_info,
        stru_field type dd03l,
        ls_node type ref to if_wd_context_node_info,
        ls_attribute type wdr_context_attribute_info.

 lr_root_node_info = wd_context->get_node_info( ).

 lr_table_node_info = lr_root_node_info->add_new_child_node(
        name = 'DYN_NODE'
*        is_mandatory = abap_false
*        is_multiple = abap_true
*        is_mandatory_selection = abap_false
*        is_multiple_selection = abap_false
*        is_singleton = abap_true
*        is_initialize_lead_selection = abap_true
         is_static = abap_false ). 

  loop at lt_ded_gc_alv into stru_ded_gc_alv.
    stru_field-fieldname = stru_ded_gc_alv-fieldname.
    select  datatype comptype rollname from dd03l into
       corresponding fields of stru_field
       where fieldname = stru_field-fieldname
       and tabname = stru_ded_gc_alv-tablename.
    endselect.
      ls_attribute-name = stru_field-fieldname.
      ls_attribute-type_name = stru_field-rollname.
      ls_attribute-value_help_mode = '0'.
      ls_attribute-is_static = abap_false.
      ls_attribute-node_info = lr_table_node_info.

      call method lr_table_node_info->add_attribute
        exporting
          attribute_info = ls_attribute.

      clear ls_attribute.
  endloop.

How can I fill these attributes with values? The context node is dynamic and built of if_wd_context_node_info. There is no method set_attribute or method bind table as I can find in if_wd_context_node. How can I do? I tried with bind_table like this:


* get instance of new node
    dyn_node = wd_context->get_child_node( name = 
    'DYN_NODE' ).

* Bind internal table to context node
   dyn_node->bind_table( <tab> ).

But then I got an error message:

german: Falscher Typ eines Operanden bei der Anweisung MOVE-CORRESPONDING.

english: Wrong type of operand at the statement MOVE-CORRESPONDNG

It came in the method IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE.

How can I solve the problem?

Thanks al lot for your help in advance.

Best Regards,

Ingmar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try using

dyn_node->bind_elements( <tab> ) INSTEAD OF

dyn_node->bind_table( <tab> ).

This should work.

Regards,

Wenonah

Former Member
0 Kudos

Hi Wenonah,

thanks for your answer.

It doesn't work. It's the same error as with bind_table.

I think, the problem is that bind_table or bind_element is out of if_wd_context_node and the node himself is out of if_wd_context_node_info ! Bind_tables or bind_elements want to have static attributes but they get dynamic attributes!!

Because of this the error occurs in if_wd_context_node~get_static_attributes_table .

Are there other possibilities?

Thanks a lot!

Best regards,

Ingmar

Former Member
0 Kudos

Hi,

Do you know the actual structure of the context node, atleast at runtime? If yes, then you can pass it as the parameter static_element_rtti in the method add_new_child_node.

Or else, you can directly create the node info using the method cl_wd_dynamic_tool=>create_nodeinfo_from_struct. This too would work only if the structure is known beforehand. Then bind_elements can be used and it will work.

Regards,

Nithya

Former Member
0 Kudos

Thanks Nithya,

your answer and the idea with static_element_rtti brought me to the following [Thread|] with Reginas post. That solved my problem. But I give you all points

Answers (0)