cancel
Showing results for 
Search instead for 
Did you mean: 

Binding between two components

MikeB
Contributor
0 Kudos

Hello, SAP CRM Gurus

I'm a newbie in SAP CRM world and I have a question regarding to binding of different components controllers in SAP CRM.

I'm working with two components — PRD_PSIC_LOC_H and PRDIOOV.

I need to define value of my own variable on event in PRD_PSIC_LOC_H and after that to read this value in some event of PRDIOOV.

In order to do that I defined context nodes in both of these components controllers, let say GLCONFIG context node.

Now, to supply ability to transfer a data between two components I have to define a binding between these context node (

PRD_PSIC_LOC_H to PRDIOOV). And at this point I got a first issue — when I'm trying to define binding I got error warning: «You can't bind context node to itself» (this is close to text quote). After some research job I find a suggestion, telling me to define custom controller and try to bind custom controller to component controller. But it still doesn't work.

When I try to implement reverse binding, component controller to custom controller (PRDIOOV to PRD_PSIC_LOC_H), creation of binding process goes OK, but when I run CRM Web UI I got binding exception.

So, can you, please, provide a step-by-step guide how to implement a binding between two components, that i could access to context node's attribute from another component.

Also, I'm worrying about correct component usage definition.

Tell me please, if PRDIOOV wants to get value from PRD_PSIC_LOC_H, so where should I define component usage — in PRD_PSIC_LOC_H or in PRDIOOV or in both of them?

Thanks.

View Entire Topic
Former Member
0 Kudos

Hi Mike,

You can do the following steps:

1. Figure out the view and the context node in the component PRD_PSIC_LOC_H, in which the field value is getting changed in an event.

2. Go to the component PRDIOOV, do the following

   *  In the component controller, add the context node as found in the previous step if it is not there

   *  Check the view in which you want to display the value, if the same context node exists der. If it      does, then fine else create the context node of the same structure.

   *  Bind this context node with the component controller.

   *  Now in the runtime repository, expose this context node of the component controller and the      view.

   *  RUntime repository->component interface->add the view

   * RUntime repository->component interface->interface controller->context_add the context node      of the component controller.

3. Go to the component PRD_PSIC_LOC_H, and do the following.

     * In the component controller, add the context node as found in step1 if it is not there and

        it with the context node in the view

     * in the runtime repository, add the component PRDIOOV view as component usage.

     * in the component controller, write the following code in the method WD_USAGE_INITIALZE' to        bind the nodes of the component controller

CHECK iv_usage IS BOUND.

IF IV_USAGE->USAGE_NAME = "name of component usage

iv_usage->bind_context_node( iv_controller_type = cl_bsp_wd_controller=>co_type_component

iv_name = iv_usage->usage_name

iv_target_node_name = " context node

iv_node_2_bind =  " context node ).

ENDIF.

Now you wil be able to access the value in the other component PRDIOOV.

Let me know in case you face an issues.

Prerna

    

MikeB
Contributor
0 Kudos

Hi, Prerna

Thank you for your quick response.

I have a question regarding to your comment.

You wrote:

   *  Check the view in which you want to display the value, if the same context node exists der. If it      does, then fine else create the context node of the same structure.

Why should we create context node of view in this case?

Why we can't access to desirable content of context node inside of a component controller without defining additional context node in view?

Is the mandatory condition of just best practice/pattern for such kinds of questions?

Thanks.

Former Member
0 Kudos

It is not mandatory to create context node. It is just  a good practice to follow the approach i mentioned before.

You can directly access the content of the context node in component controller by using attribute comp_controller and its context nodes.

Fetch the reference using me->comp_controller, then get the collection wrapper and read the entities in it.

Hope this helps!!!

Prerna

MikeB
Contributor
0 Kudos

I'll try to implement your suggestion and will let you know if everything is alright.

Thank you!

MikeB
Contributor
0 Kudos

Hi, Prerna

I tried to implelement your suggestion about binding, but I faced out with the problem — this doesn't work.

Let's look what I did and will try to find out why it doesn't work.

1. First-of-all, i have to tell that I tried to store data in both — component controller's context node and in custom controller's context node.

2. After that I executed exposition of context node in runtime repository.

3. I've checked if usage is defined and payed attention that usage (of type PRD_PSIC_LOC_H) is defined in PRDIOOV, in other words, in component that need to get data from PRD_PSIC_LOC_H. Inspite of your suggestion to define usage in PRD_PSIC_LOC_H and not in PRDIOOV component.

Is it OK?

4. I've implemented WD_USAGE_INITIALZE and defined names of context nodes. I've also checked that we really enters to this method and execute it in debugger.

When I checked this code in debugger, I've found that we really store needed data in context node of component controller and of custom controller of PRD_PSIC_LOC_H, but neither component controller's context node, nor custom controller's context node don't contain wanted data.

Also, I've payed attention, that in your suggestion there is no place for context node binding step, I mean we don't execute binding procedure at any of guide steps. We don't bind any context node to other context node. Is it OK?

P.S. I've also focused my attention, that each time when I try to bind any context node of PRDIOOV to any compatible context node of PRD_PSIC_LOC_H, I get a dump in DO_INIT_BINDING method. Is it OK? And why does this occur?

Thanks.

MikeB
Contributor
0 Kudos

Hi, Prerna

Could you, please, clarify the following statement:

   *  RUntime repository->component interface->add the view

What and how exactly should I do it?

Which view do I need to add?

Thanks.

praveen_kumar194
Active Contributor
0 Kudos

hi mike,

component interface means by which you exposed your component parts to the outside, so that any another components can use it. component parts means your context nodes , windows ...etc.

1. go to the runtime repository. choose the edit button first.

2. choose the component interface.

3. choose interface view and right click on it and add the window of your component here.generally component interface is nothing but your component window (just like a view).