cancel
Showing results for 
Search instead for 
Did you mean: 

Share context between two component

Former Member
0 Kudos

Hi all,

I would like to share a context between two component of the same applicatio, by reading some other posts I try to do it by it doesn't work, what I did is:

1. I create an interface controller in which I put a node like the ones I want share, then I declare a method GET_NODE too.

2. In my components A and B I declare the Interface controller.

3. In component A I declare the node like an interface node and I implement the method GET_NODE of interface controller in order to read my node.

4. In component B I map the node to share with interface node of interface controller in component A.

5. In component B I implement following code in order to read the context of component A:

  DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
  DATA lo_node_detail TYPE REF TO if_wd_context_node.

  lo_cmp_usage =   wd_this->wd_cpuse_cnt_carta( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

  DATA lo_interfacecontroller TYPE REF TO ziwci_fc_wda_cntcarta .
  lo_interfacecontroller =   wd_this->wd_cpifc_cnt_carta( ).

  lo_interfacecontroller->get_node(
    IMPORTING
      node =   lo_node_detail                         " ref to if_wd_context_node
  ).

Unfortunately it doesn't work... any suggest for me?

Thanks

GN

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello,

Please create a method in Component controller of Component A and make it as Interface method.

write your code of data retreival and attach the data to the node.

Call the interface method in Component B which you are executing , may be you can call in Init method and now you can see the data is retreived.

Please dont write code for Mapping of nodes from comp A to B becuase as said by other members you can just bind the Interface node of Comp A to Comp B by right click from node B.

Code you can use like below in Init method of Comp B to call the Comp A Interface method for data retreival.

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
  DATA lo_node_detail TYPE REF TO if_wd_context_node.

  lo_cmp_usage =   wd_this->wd_cpuse_cnt_carta( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

  DATA lo_interfacecontroller TYPE REF TO ziwci_fc_wda_cntcarta .
  lo_interfacecontroller =   wd_this->wd_cpifc_cnt_carta( ).

  lo_interfacecontroller->get_details( ).

Get details is the interface method created in Comp A.

manigandan_d2
Explorer
0 Kudos

please check the below document:

http://scn.sap.com/docs/DOC-41641

Cheers,

Mani

kutjohn
Active Participant
0 Kudos

This message was moderated.

amy_king
Active Contributor
0 Kudos

Hi Gabriele,

If you have defined the component controller's context node in Component A as an interface node (by checking the relevant checkbox in the context node's properties) and then assigned Component A as a used component in Component B, you will be able to just map the interface node from Component A's context to Component B's context by drag-and-drop.

Cheers,

Amy

former_member210266
Active Participant
0 Kudos

Hi

If you have mapped the context of both the components, then you can use the context of the component B as both the context will have the same data(since they are mapped). I don't feel the need to create a special method to do the work.

Regards

Swati