cancel
Showing results for 
Search instead for 
Did you mean: 

how to copy the data of one node to another of the same context

Former Member
0 Kudos

hi experts,

i need to copy the data of one node to the other node of the same context.

the source node is a model node ( i.e comming from <b>RFC</b> ) and the destination node is a value node which i have creted.

what i have done is.

i have read the source node using wizard

do.

elem_t_p0591 = node_t_p0591->get_element(

index = sy-index ).

IF ( elem_t_p0591 IS INITIAL ).

EXIT.

ENDIF.

elem_t_p0591->get_static_attributes(

IMPORTING

static_attributes = stru_t_p0591 ).

IF stru_t_p0591 IS NOT INITIAL.

wa_p0591 = stru_t_p0591.

APPEND wa_p0591 TO itab_p0591.

ENDIF.

ENDDO.

and then i am trying to read the destination node so the tha data i have got by above method can be binded to the destination node.

but when i am trying to get the child node it is giving me a dump saying that

<b>'Access via 'NULL' object reference not possible' </b> i understand this because when i debug my value node is becoming <b>initial</b>, and when i am trying to access the destination node using this <b>initial</b> node it will give me a dump,

but what is the work aroud for this.

Plz help.

Regards,

Santosh.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi anoop,

this problem has got solved, i just created that node again and used a supply function to populate it in the same that was doing earlier, but still it's a puzzle for me because when i tried to do this in wddoinit method why dint it happen.

Regards,

Santosh.

Former Member
0 Kudos

Hi Santosh,

I tried replicating your behaviour in my system. This is what my context structure looks like:

Node_Test (c-> 0:n)

Name(attribute)

Node_Test2 (c-> 0:1)

Name2(attribute)

Now when i try to access Node_Test2 then it returns me (initial) i.e. no reference and i believe the reason is that my parent node, Node_Test, is of type table( because of the cardinality) so I am expected to perform an operation on my sub node, Node_Test2, based on the node i have selected, or have specified via index .. 1 is taken by default, in Node_Test.. which in WDDOINIT is initial as i havent got access to my view yet.. so instead what you can do is bind data to your parent node, relevant data ofcourse, and then bind the recieved data to your child node i.e. Node3.

I am pasting the code here for your reference :

method WDDOINIT .

DATA:

node_test TYPE REF TO if_wd_context_node,

elem_test TYPE REF TO if_wd_context_element,

stru_test TYPE wd_this->element_test ,

lt_table LIKE TABLE OF stru_test,

item_test_1 LIKE stru_test-test_1.

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

node_test = wd_context->get_child_node( name = wd_this->wdctx_test ).

  • @TODO handle not set lead selection

IF ( node_test IS INITIAL ).

ENDIF.

  • get element via lead selection

elem_test = node_test->get_element( ).

  • @TODO handle not set lead selection

IF ( elem_test IS INITIAL ).

ENDIF.

stru_test-test_1 = 'Anoop'.

APPEND stru_test to lt_table.

stru_test-test_1 = 'Avi'.

APPEND stru_test to lt_table.

stru_test-test_1 = 'Sid'.

APPEND stru_test to lt_table.

CALL METHOD node_test->bind_table

EXPORTING

new_items = lt_table

  • set_initial_elements = ABAP_TRUE

  • index =

.

DATA:

node_t2 TYPE REF TO if_wd_context_node,

elem_t2 TYPE REF TO if_wd_context_element,

stru_t2 TYPE wd_this->element_t2 ,

item_t2_1 LIKE stru_t2-t2_1.

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

  • node_test = wd_context->get_child_node( name = wd_this->wdctx_test ).

  • @TODO handle not set lead selection

IF ( node_test IS INITIAL ).

ENDIF.

<b>* navigate from <TEST> to <T2> via lead selection

node_t2 = node_test->get_child_node( name = wd_this->wdctx_t2 ).</b>

<b>* alternative navigation via index

Node_T2 = Node_Test->get_Child_Node(

Name = `T2` Index = 1 ).</b>

  • @TODO handle non existant child

  • if ( Node_T2 is initial ).

  • endif.

  • get element via lead selection

elem_t2 = node_t2->get_element( ).

  • get single attribute

elem_t2->get_attribute(

EXPORTING

name = `T2_1`

IMPORTING

value = item_t2_1 ).

endmethod.

I hope this helps.

Regards,

Anoop

Former Member
0 Kudos

hi anoop,

in a trail and error method i tried to change the cardinality of the node, the node was getting instantiated when i went saw it in debug mode, but then when i try to access the node below it, it gave me an error of 'CARDINALITY VOILATION'.

the structure is context->node1->node2->node3->(attributes).

previously when i was trying to access the child node2 from node1, node2 was not getting instantiated and hence it was giving me an error of 'Access via NULL Reference' i changed the cardinality now node2 is accessible but when i try to access node3 from node2 it give me an error of 'CARDINALITY VOILATION' .

i tried with all the four options of cardinality, but still it continues to give me the same error,

anoop now am i clearly able to explain you the problem,

and as u asked me i am trying to achieve this in WDDOINIT only is this a trouble?.

Regards,

Santosh.

Former Member
0 Kudos

Hi Santosh,

I hope that you are already getting the data desired and the issue that you are facing is in binding this internal table, itab_p0591, to the node that you have created in controller you are present in right ??

Can you please provide more info as to how and where you are trying to do this and also where your destination node is present ?

Regards,

Anoop

Removed WDDOINIT part

Message was edited by:

Anoop Singh Saini