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.

Accepted Solutions (1)

Accepted Solutions (1)

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).

Answers (2)

Answers (2)

MikeB
Contributor
0 Kudos

Hello, Prerna & Praveen.

We've solved our problem with binding and now it works.

The key challenge was to declare a correct usage in correct component.

Here are a key steps to implement binding between two different components:

1. Define context nodes in comp_controller with the same name (recommended)

2. Expose these context nodes in Runtime Repository of both of components

3. Call bind_context_node() binding method in WD_USAGE_INITIALZE of client component (component, which takes data from another component) and pass names of context nodes.

That's all.

Thanks for the operative help!

praveen_kumar194
Active Contributor
0 Kudos

hi

component usage is depend on requirements.

say you have component C1 and you want to use some views say V1 AND V2 of another component C2. Then you will define component usage in C1.

based on above , you need to define component usage in the component PRDIOOV as you want to read vlaue of component PRD_PSIC_LOC_H in the PRDIOOV.

Just binding the context nodes does not provide resuls means when you click on something or in your event, you need to set the data in the context node. then only you can access the data through binding mechanism.

as you have mentioned that even custom controller is not having the data, then check the context node of view is having the data or not.

Let me know if you need further help.

MikeB
Contributor
0 Kudos

Actually context node of custom controller & component controller of PRD_PSIC_LOC_H does contain the data after I use set_property_as_string() method, the problem is to allow access to this data in PRDIOOV.

So, how can I check if binding does really work?

Former Member
0 Kudos

Hi Mike,

You were correct and as Praveen explained, define component usage in the component PRDIOOV.

Now do the context node binding in the WD_USAGE_INITIALIZE method in component controller.

Once that is done,try reading the collection of the context node in the component controller of PRDIOOV to check the context node data of component PRD_PSIC_LOC_H.

Let me know in case you face any issues.

Prerna

former_member228349
Participant
0 Kudos

Hi

i have similar issue.  I wanted Text window in the PRDHS HeaderVS -

i have enhanced and

created component usage - Notes. Notes Window

then i assigned the view in the HeaderVS -> view set

in the component controller i added one context node - > TextAttr (value Node)

and in the wd_usage_initialize - i bindeded (GSTEXT /Notes)

WHEN 'Notes'.

         CALL METHOD lv_usage->bind_context_node

           EXPORTING

             iv_controller_type  = cl_bsp_wd_controller=>co_type_component

             iv_target_node_name = 'TEXTATTR'

             iv_node_2_bind      = 'ATTR'.


now there is a text box is visible in the view.. but not editable and dont know how to make it editable


can anyone throw some light,  how to make it editable and pass the TD-ID etc.. and also retrieve the value and display it back..


thanks


dhinesh

MikeB
Contributor
0 Kudos

Dear Dhinesh,

As far as I remember, in order to supply the input/edit ability of the context node, you have to implement the I-GETTER (GET_I_%CN_NAME%) of the specific context node. Please, check the value of the boolean RV_DISABLED, which is returning parameter of an I-GETTER method to activate (FALSE-value) or deactivate (TRUE-value) the input functionality.

former_member228349
Participant
0 Kudos

hi mike,

thanks for the response

can you please tell how i can enforce this methods from other component.. i have embedded the gstext notes view thru component usage

thanks

dhinesh

MikeB
Contributor
0 Kudos

Unfortunately, I don't have an access to the SAP CRM now, thus it will be hard for me to find what exactly to do. GET_I should define the status of the controller: enabled or disabled for the input. So, first we have to supply the binding and after that to care to enable the container for the edit.

Hope, there is someone here who can give you more detailed explanation.