cancel
Showing results for 
Search instead for 
Did you mean: 

Filling subnodes in webdynpro for abap

Former Member
0 Kudos

I have a table with cardinaity of 0.n and a subnode with cardinality of 0.n. I am having trouble filling the subnode. When binding the data to the sub node I am getting an error u2018Access via 'NULL' object reference not possible.u2019 After method path_get_node lo_nd_funds is still initial. What do I need to do?

My code:

DATA lo_nd_funds TYPE REF TO if_wd_context_node.

*

data ls_funds type table of z_fundtable.

  • navigate from <CONTEXT> to <FUNDS2> via lead selection

lo_nd_funds = wd_context->PATH_GET_NODE( path = 'TABLE.FUNDS' ).

data: node_path type string.

data: node_index type STRING.

loop at lt_repeat_table into ls_repeat_table.

NODE_INDEX = SY-TABIX.

concatenate ' DETAIL_TABLE.' NODE_INDEX '.FUNDS' INTO NODE_PATH.

lo_nd_funds = wd_context->path_get_node( path = node_path ).

append ls_repeat_table-FUNDS to lS_funds.

LO_ND_FUNDS->BIND_TABLE( LS_FUNDS ).

endloop.

Thanks

Cindy

Accepted Solutions (1)

Accepted Solutions (1)

ChrisPaine
Active Contributor
0 Kudos

Hi Cindy,

I'd approach it in a slightly different manner...


lo_table_nd = wd_context->get_child_node( wd_this->wdctx_table ).

loop at lt_table_data into ls_table_data.

lo_table_element = lo_table_nd->bind_structure( new_item = ls_table_data-data
                                            SET_INITIAL_ELEMENTS = abap_false ).

lo_funds_nd = lo_table_element->get_child_node( wd_this->wdctx_funds ).

 lo_funds_nd->bind_table( ls_table_data-funds ).

endloop.

I personally don't like the path_get_node construct - as it's too easily open to typos...

Cheers,

Chris

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you Chris, it is working now.

Cindy

Former Member
0 Kudos

hi,Cindy

You know, when you want insert data into subnode, you should first insert data into its parent node if the parent node is initial.

So, according to your code, i think the parent Node " DETAIL_TABLE" should be inserted with data first.Otherwise you will get "Null Object " expcetion.


data: node_path type string.
data: node_index type STRING.
loop at lt_repeat_table into ls_repeat_table.
NODE_INDEX = SY-TABIX.
concatenate ' DETAIL_TABLE.' NODE_INDEX '.FUNDS' INTO NODE_PATH.
lo_nd_funds = wd_context->path_get_node( path = node_path ).
append ls_repeat_table-FUNDS to lS_funds.
LO_ND_FUNDS->BIND_TABLE( LS_FUNDS ).
endloop.

In addition, here, the cardinality is not very "Important". Why? though the subnode's cardinality is '0...n', however, in the static context node, you can see that "Subnode" must have one "Parent Node".

I don't know whether it can help or not.

Best wishes.