cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set a table to an attribute in a context?

Former Member
0 Kudos

Hi Guys,

I have an structure mapped in the context and one field is a table. At the beginning I need to initialize this table but the others are useless. Using Web Dynpro Wizard with the instruction set selecting this attribute, I have a problem at runtime

  • Access via 'NULL' object reference not possible.

How can I load a field whose type is a table? An example would be very useful, please.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Sergio,

The context attribute that is a table should be created as a node with cardinality 0..n or 1..n.

Cheers,

Amy

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sergio,

  you can go with the following  approach.

  DATA lo_nd_node_name TYPE REF TO if_wd_context_node.
  DATA lo_el_node_name TYPE REF TO if_wd_context_element.
  DATA ls_node_name TYPE wd_this->element_node_name.


* navigate from <CONTEXT> to <NODE_NAME> via lead selection
  lo_nd_node_name = wd_context->get_child_node( name = wd_this->wdctx_node_name ).

* get element via lead selection
  lo_el_node_name = lo_nd_node_name->get_element(  ).

  Data lt_sflight TYPE TABLE OF SFLIGHT.

  SELECT * from Sflight INTO TABLE lt_sflight.

   ls_node_name-table = lt_sflight.   * this contain a attribute of table type 'SFLIGHT'

* get all declared attributes
  lo_el_node_name->set_static_attributes(
    EXPORTING
      static_attributes = ls_node_name ).


Regards,

Monishankar Chatterjee

Former Member
0 Kudos

try using bind_structre method of if_wd_context_node instead of set_attribute of if_wd_context_element

hope it help