cancel
Showing results for 
Search instead for 
Did you mean: 

How to check wether node is initial or not ?

Former Member
0 Kudos

Hi,

we have a variable MO_Current_ORGval  which refers to IF_WD_CONTEXT_element.

During runtime i need to check wether the node is initial or not ?

how to achieve this ?

i have tried using  MO_Current_ORGval->get_node( ) is initial .

But no use.

source code:

check wd_comp_controller->mo_current_orgval is not initial.

"" Here i need to check , whether the node is having any value or not.





Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Aravindan,

In general,you can access the attributes of an object as below

object->name_of_attribute.

In your case, you need to get the node reference and get the no. of elements inside the context element.

Here is one point:

as mo_current_orgval is a context element of a node, if element is not initial, that means : the node is already having at least one element.

Hence NODE will never be initial if mo_current_orgval is not initial

If you want to know how many elements inside the context node.


check wd_comp_controller->mo_current_orgvalis not initial.

"" Here i need to check , whether the node is having any value or not.


data lo_node type ref to if_wd_context_node.

data lv_no_of_elements type i.

lo_node = wd_comp_controller->mo_current_orgval->get_node( ).

if     lo_node is bound. "mean, object reference to node bound

lv_no_of_elements =     lo_node->GET_ELEMENT_COUNT( ).

endif.

" similarly you can use the GET_STATIC_ATTRIBUTES_TABLE method to retrieve static attributes of node ( 0..n )

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Ramakrishna,

Thanks for your reply.

In our case wd_comp_controller->mo_current_orgval is not initial,

But the node is not having any values.

thats why we need to check wether the node is initial or not.

if we call get_node , it goes for a dump.

Regards

Aravindan M

ramakrishnappa
Active Contributor
0 Kudos

Hi Aravindan,

Okay, I could see from snap shot that, NODE is an attribute of class CL_WDR_CONTEXT_ELEMENT.

Please try the below code


data lo_wdr_element type ref to cl_wdr_context_element.

lo_wdr_element ?= wd_comp_controller->mo_current_orgval.

if lo_wdr_element is bound.

    

    if lo_wdr_element->node is bound.

     endif.

endif.

Hope this resolves your issue.

Regards,

Rama

Former Member
0 Kudos

Hi Ramakrishna,

Thanks a lot. It solved the issue..

Best Regards

Aravindan M

Answers (0)