cancel
Showing results for 
Search instead for 
Did you mean: 

Two different CuCo instances in one component?

Former Member
0 Kudos

Hi,

I am working on component ICCMP_BP_SEARCH. Here I have the views BuPaSearch and BuPaSelectCustomer.

Within each of the views I created a new value node ZPARTNER. The CuCo CuCoSearch also got a value node ZPARTNER. Now I binded the nodes of the each view to the node of the CuCo and added an attribute to the CuCo as well.

Now when I perform a search I fill data into the context node of the view BuPaSearch and set the attribute in the CuCo.

In the view BuPaSelectCustomer (html-file) I try to get the current instance of the CuCo to read the attribute and the value node.

I expected the changes of my value node in BuPaSearch to be published to the CuCo and the BuPaSelectCustomer view. Maybe I need to add some coding, but at least the global attribute should be available, no?

When I get the custom controller in the html file (BuPaSelectCustomer) the CuCo is initial. If I access the CuCo inside the BuPaSearch view where it was filled, I have all the attributes and entities I created.

Seems I am wrong in my thinking or I have some mistake in my implementation.

Any idea what I should check or what could have gone wrong?

Thanks for help!

Accepted Solutions (0)

Answers (1)

Answers (1)

VishnAndr
Active Contributor
0 Kudos

Hello, Benedikt.

Do you get a CuCo as initial. Or CuCo is not initial but your attribute is initial?

How do you try to get CuCo? Please provide some coding.

Former Member
0 Kudos

Thanks for your reply.

It's not the CuCo being initial but my attribute and the collection wrapper of the value node has only one entry, the empty one which is added in the INIT-method of the context node. So it feels like a second instance of my CuCo as inside the other view I have my collection, attribute etc.

This is my coding to get the CuCo:

DATA: lr_cucosearch       TYPE REF TO   zl_iccmp_bp_cucosearch_impl.
lr_cucosearch ?= get_custom_controller( 'ICCMP_BP_SEARCH/CuCoSearch' ).

This coding I use in both views. This is wrong? I debugged and it looked like it would search for an instance and then return it instead of creating a second one.

Am I mistaken?

Thanks.

VishnAndr
Active Contributor
0 Kudos

No, you're correct with getting CuCo by this coding.

But have you debugged the sequence of calling pieces of code which set and get this attribute. Are they in the right order?

Former Member
0 Kudos

Yes, absolutely. The attribute is set at the ONSEARCH event and read in the result view. So by this order it should not be overwritten.

Very strange. In a singleton environment it should not happen to have two instances.

VishnAndr
Active Contributor
0 Kudos

Could you check is this the same instance of CuCo in both cases? For this check ID of lr_cucosearch in both cases (in debugger, there is a number in the second column when you put this lr_cucosearch in the watch area). They should be the same. If yes, then I'd suggest to put a watchpoint on your attribute and after setting it catch the place where it's cleared.

Former Member
0 Kudos

By ID you mean COMPONENT_ID? Yes, this one would be the same: C4_ziccmp_bpsearch/cucosearch

The Watchpoint seems is not working or I set it wrong. It stopped once when I set the value and afterwards it did not.

VishnAndr
Active Contributor
0 Kudos

No, under ID I ment ID of the instance.

You can see it when in debugger you put your variable lr_cucosearch in Variables 1 tab's grid. Then you'll see something like:

lr_cucosearch | {0:2469*\CLASS=....

So I've asked about "2469" in your case.

Former Member
0 Kudos

Ah, ok. No, in this case it's two different IDs. 619 and 929.

So I have two instances of one CuCo, right? How can that happen?

Former Member
0 Kudos

I double checked the hierarchy of the component. The Search-View and the Result-View are each wrapped by a ViewSet. The both ViewSets are combined together via CRMCMP_BPIDENT. So sure there is no common CuCo.

I guess I need to go via CuCoBuPa now. Not good.

VishnAndr
Active Contributor
0 Kudos

May be you should take a look on Global Data Context.

Former Member
0 Kudos

GDC will not work for me as it only supports BOL objects but I am working with value nodes.

The CuCo now works. But you need to replace the CuCo in the runtime profile to have your redefined CuCo loaded.