cancel
Showing results for 
Search instead for 
Did you mean: 

invalidate( ) doesn't invalidate child nodes

ged_hurst
Participant
0 Kudos

Hello everyone,

I've created context nodes dynamically through:


            new_node = node_info->add_new_child_node( name = nodename
                                           is_singleton = abap_false
                                           is_multiple = abap_false
                                           is_mandatory = abap_true
                                           is_initialize_lead_selection = abap_true
                                           is_static = abap_false ).

I've then invalidated the parent node through:


   lo_nd_contract = wd_context->path_get_node( path = `CONTRACT` ).
  lo_nd_contract->invalidate( ).
  lo_nd_contract = wd_context->path_get_node( path = `CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_1` ).
  lo_el_contract  = lo_nd_contract->get_element( ).
      lo_el_contract->get_attribute(
                EXPORTING
                  name =  `COMPANY_CONTACT_1`
                IMPORTING
                  value = lv_company_contact_0 ).

but the variable lv_company_contact_0 still retains the old value.

Any ideas as to what's going on?

Thank you!

Edited by: Development Themis on May 3, 2011 6:25 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

does any of these nodes CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_1 have supply function ?

This method invalidates all elements of the node. This means that all elements and subnode

instances are deleted. Afterwards the status of the node is as it is in its initial state. When an

element or an attribute is requested again, the supply method is called, if it is available.

ged_hurst
Participant
0 Kudos

Hi,

all of the nodes that I have created dynamically do NOT have any supply function assigned.

I have also tried :


 data mynode type ref to CL_WDR_CONTEXT_NODE.
  mynode ?= wd_context->path_get_node( path = `CONTRACT` ).
  mynode->reset( ).

which appears to work better, but the problem in this case is that all of the child nodes (including 'CONTRACT') are deleted (even those defined statically: e.g. CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_0 is defined statically but it's now deleted) and I do not know how to force a node to be re-instantiated to its original status.

To be honest this sounds like a bug to me...?

ged_hurst
Participant
0 Kudos

Hi,

I've found out this strange behaviour:


lo_nd_contract = wd_context->path_get_node( path = `CONTRACT.COMPANY_CONTACTS` ).
" the node `CONTRACT.COMPANY_CONTACTS`  has two child nodes. 
" Let's try to invalidate them
  lo_nd_contract->invalidate( ).
 " the debugger shows no child nodes under `CONTRACT.COMPANY_CONTACTS`  but 
" as soon as the statement included below executes, the debugger shows two nodes under
" `CONTRACT.COMPANY_CONTACTS`: `CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_0` 
" which was statically created and `CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_1` 
" which was created dynamically
  CALL METHOD lo_nd_contract->get_child_nodes
    EXPORTING
      index       = '1'
    RECEIVING
      child_nodes = child_nodes.

Why have they been restored?

Could anybody tell me what I'm doing wrong?

Thanks!

ashish_shah
Contributor
0 Kudos

Invalidate clears the nodes and then reinitializes it.

E.g.

1) Invalidate on a node with cardinality 0:1 --> will clear the elements if any

2) Invalidate on a node with cardinality 1:1 --> will clear the elements if any , and will also create one element in the node since minimum cardinality is 1.

3) Invalidate on a node with cardinality 0:n --> will clear the elements if any

4) Invalidate on a node with cardinality 1:n --> will clear the elements if any , and will also create one element in the node since minimum cardinality is 1.

So i guess the node that you are trying to invalidate has either 1:1 or 1:n cardinality.

Regards,

Ashish Shah

ashish_shah
Contributor
0 Kudos

see this thread for similar behavior : [;

ged_hurst
Participant
0 Kudos

I've fixed the problem.

The thing is that I created the node as

 is_mandatory = abap_true 

and the node was not deleted (actually it disappeared from the context in the Debug but appeared back in whenever I tried to access it).

Thank you so much.

Regards

ashish_shah
Contributor
0 Kudos

I've fixed the problem.

> The thing is that I created the node as

 is_mandatory = abap_true 

and the node was not deleted (actually it disappeared from the context in the Debug but appeared back in whenever I tried to access it).

If you understand the purpose of these properties while creating dynamic nodes , you will not run into issues again.

IS_MENDATORY --> Used to specify lower canrdinality

IS_MULTIPLE --> used to specify higher cardinality

So by specifying is_mandatory = abap_true , you had set lower cardinality to 1 and that caused the problem.

Regards,

Ashish Shah