Skip to Content
author's profile photo Former Member
Former Member

Share context between two component

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Posted on May 05, 2013 at 02:01 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 16, 2013 at 01:30 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 21, 2013 at 10:22 AM

    This message was moderated.


    COMPA.jpg (69.4 kB)
    CompBusage.jpg (70.3 kB)
    dragB.jpg (55.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 22, 2013 at 03:28 PM

    please check the below document:

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

    Cheers,

    Mani

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 24, 2013 at 10:28 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.