cancel
Showing results for 
Search instead for 
Did you mean: 

How to read values from the context at runtime?

Former Member
0 Kudos

Hi,

I have a context like below.

Node1

Node2

Node3

Node4

Node5

Attrib1

Attrib2

How do I read values from Node5.Attrib1 at runtime>

Thanks in Advance.

Sundar

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thomas,

Thanks for your quick reply.

The following codes are generated by wizard in WDDOMODIFYVIEW.

lo_nd_t_cells_body = wd_context->path_get_node( path = `L_BODY_DATA.S_BODY.T_ROW_BODY.T_COLUMN_BODY.T_CELLS_BODY` ).

  • get element via lead selection

lo_el_t_cells_body = lo_nd_t_cells_body->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_t_cells_body IS INITIAL.

ENDIF.

  • alternative access via index

  • lo_el_t_cells_body = lo_nd_t_cells_body->get_element( index = 1 ).

  • @TODO handle non existant child

  • IF lo_el_t_cells_body IS INITIAL.

  • ENDIF.

  • get single attribute

lo_el_t_cells_body->get_attribute(

EXPORTING

name = `CAPTION`

IMPORTING

value = lv_caption ).

When this line is executed

lo_el_t_cells_body = lo_nd_t_cells_body->get_element( ).

I am getting error "Access via 'NULL' object reference not possible. ".

Note: This node attributes are bound with UI elements and it is working fine if I comment the above codes.

Thanks

Sundar

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

That must mean that one of your intermediate nodes has 0:1 or 0:n cardinality and has no elements at runtime. You have some data at the intermediate level to be able to navigate lower. I would check the cardinality consider how you are populating the data of these intermediate nodes.

Former Member
0 Kudos

Thomas,

Yes I agree.

But this attribute is bound with UI element Label's text property.

It has value at runtime.

But when I tried to access the value from context at runtime in WDDOMODIFYVIEW method, I'm getting the error.

Thanks

Thruna

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Are your nodes supposed to be nested in your question? They show nested in the email version of the thread, but not in the web page itself.

Have you tried using the code wizard to generate the logic to read the subnode? That is a really deep structure. Assuming you can use the lead selection to navigate through the nodes, however the resulting logic shouldn't be complex, just verbose.

I'm not sure what support package level it was introduced, but on my release you can navigate via lead selection using the node path:

* navigate from <CONTEXT> to <SELLER_ADDR> via lead selection
    lo_nd_seller_addr = wd_context->path_get_node( path = `SALES_ORDER.SELLER.SELLER_ADDR` ).

This code goes from Node:

SALES_ORDER

->SELLER

->->SELLER_ADDR

That makes things a little cleaner than having to retrieve each intermediate node via the GET_CHILD_NODE method.

Edited by: Thomas Jung on Jul 31, 2008 10:48 AM