cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Attributes from different context nodes in the same view

Former Member
0 Kudos

Hi,

I have added a new field as part of an enhancement for Trade Promotions. This field is a checkbox and part of the context node TRADE in the view TPMOE/HeaderEOF. This field will be checked or unchecked using a logic in the background.

The logic will be based on an attribute (Fund Plan ID) which is part of another context node FUNDPLAN in the same view.

How can I read the attribute of FUNDPLAN context node in TRADE context node?

A sample code will be quite helpful as I am new to CRM 2007.

Thanks,

Abhishek

Edited by: Abhishek Periwal on Oct 16, 2008 2:35 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please follow the bellow maintain thread.

Regards

Gaurav

Former Member
0 Kudos

Hi Gaurav,

The above thread gives details about accessing a field from one component to another but I need to access a field from one Context node to another in the same component and view.

Please let me know how should I proceed.

Thanks,

Abhishek

former_member813607
Contributor
0 Kudos

Hi Abhishek,

If you want to read the value of a field in different context node of the same view and same component, you can follow the steps below..

You have to write the code in implementation class of the controller ( view controller ) for reading the the value

data: lr_entity type ref to cl_crm_bol_entity.

lr_entity ?= me->typed_context->(context_node name)->collection_wrapper->get_currrent( ).

lv_field_value = lr_entity->get_property_as_String( **pass the field name here ).

Note: the code snippet above I have typed here as I dont have acces to server right now, you refer / compare some similar standard codes.

hope it helps,

Regards, Sudeep..

Former Member
0 Kudos

Hi Abhishek,

If I understand your question correctly, you would like to access the Fund plan ID (in a different context node) in the getter setter methods of the check box attribute which you have added.

The code snippet mentioend by sudeep works perfectly fine when you are making any checks in the view implementation class. But since you are in the getter setter methods of the context class, this doesnot work as "me" always refers to the class instance in which you are present.

Now in this case what you need to do is :

1) create an attribute <view_controller> in your context class. Here the context is TRADE. The type of this attribute wud be same as the view controller class CL_TPMOE_HEADEREOF0_IMPL

2) Go to the view controller class and redefine the method

DO_VIEW_INIT_ON_ACTIVATION. This method is called only once when the view is loaded for the first time.

3) In this method, put the following code

me->typed_context->(Trade)->[view_controller] = me.

by the above code, you are setting the newly created attribute to the view controller instance.

4) The next step would be, go back to your getter setter methods or what ever it may be, try referring to the Fund plan ID by the code snippet mentioned below

data: lr_entity type ref to cl_crm_bol_entity.

lr_entity ?= me->[view_controller]->typed_context->[the context node in which the fund plan id is present]->get_current().

lv_field_value = lr_entity->get_property_as_String( **pass the field name here ).

This should definitely resolve the problem.

Thanks,

Vinay

Former Member
0 Kudos

Hi,

Suppose u r in BTAdminH node and u want to access BTOpportH node.then do like this...

data: lr_entity type ref to cl_crm_bol_entity.

data: lv_test type string.

lr_entity ?= collection_wrapper->get_current( ).

lr_entity = lr_entity->get_related_entity( 'BTHeaderOpportunityExt' ).

lv_test = lr_entity->if_Bol_bo_property_access~get_property_as_string( 'PROBABILITIY' ).

It may help u.

Regards

Gaurav

Former Member
0 Kudos

Hi Vinay,

I tried the code step wise given by you. However I couldn't what is required.

I am getting runtime error due to the method DO_VIEW_INIT_ON_ACTIVATION. I have given this code:

IF me->ztyped_context->ztrade IS BOUND

AND me->ztyped_context->ztrade->zview_cont IS BOUND.

me->ztyped_context->ztrade->zview_cont = me.

ENDIF.

I had to give the conditions as the runtime error was coming. This method is called just once when the trade promotion screen is opened. So this code is not triggered again and is not assigned.

Also this is the code which I had given in the getter method:

lr_entity ?= me->zview_cont->ztyped_context->fundplan->collection_wrapper->get_current( ).

The attribute zview_cont is the view controller created in the context node class which is always INITIAL. So this code is also not triggered.

Please help me out for this issue.

Thanks a lot for your response.

Abhishek

Former Member
0 Kudos

Hi Gaurav,

I tried your code and it didnt give any error but the when I tried to create Trade Promotion in Web UI the HeaderEOF view was gone and it gave an exeption on the screen.

Please let me know if there are any changes in the code.

Thanks,

Abhishek

Former Member
0 Kudos

Hi Abhishek,

Can you tell me what is the runtime error this is displayed ??

Please paste the error..

What is the type of the zview_cont you used ?? Is it same as the implementation class of the view ?

Why are using the ztyped_context ?? Is there a attribute like this in the view implementation class ? If yes, is this set to the context in the SET_MODELS method of this clas.

In the debugging mode when the DO_VIEW_INIT_ON_ACTIVATION is called, can you check the values of ztyped_context, ztrade etc ??

Let me know once you cehck this.

Regards,

Vinay

Former Member
0 Kudos

Hi,

What value u passed in lr_entity = lr_entity->get_related_entity( 'XXXXXXXX' ). in place of XXXXXXXXX.

See in my sample code I am passing BTHeaderOpportunityExt which contain actual structure for BTOpportH ie. CRMST_OPPORTH_BTIL from where we are reading PROBABILITIY attribute for this context node.

U can find this Header Item relation ship in GENIL_MODEL_BROWSER by choosing rootnode BTOrder-->relationship(BTHeaderOpportunityExt).

Here BTAdminH is header node and BTOrderH is related node for this.

Regards

Gaurav

Former Member
0 Kudos

Hi Gaurav,

I am getting this exception:

Cannot display view TPMOE/HeaderEOF

An exception has occurred Exception Class CX_CRM_UNSUPPORTED_RELATION - Relation FUNDPLAN is not (yet) supported

Method: CL_CRM_GENIL_OBJ_MODEL=>IF_GENIL_OBJ_MODEL~RELATION_IS_CACHEABLE

Source Text Row: 13

I have given this code:

DATA: lr_entity TYPE REF TO cl_crm_bol_entity.

lr_entity ?= collection_wrapper->get_current( ).

lr_entity = lr_entity->get_related_entity( 'FUNDPLAN' ).

l_fundid = lr_entity->if_bol_bo_property_access~get_property_as_string( 'FUND_PLAN_ID' ).

I need to access FUNDPLAN Context node (attribute FUND_PLAN_ID) from TRADE context node. Both these context nodes are in the view TPMOE/HeaderEOF.

Please let me where I have gone wrong.

Thanks,

Abhishek

Former Member
0 Kudos

Hi Gaurav,

Your code worked out. I found out the relation from GENIL_MODEL_BROWSER and got the values.

Thanks a lot for your help guys.

Thanks,

Abhishek

Former Member
0 Kudos

Hello Abhishek,

Good that the problem is resolved. One thing from my side is calling the BOL methods like GET_RELATED_ENTITIES multiple nr of times might cause performance issues at later point of time, as internally the core APIs & the whole process is executed everytime.

My recommendation is create all your context nodes using the relations and once u have the values in your context, it is better you access like me->typed_context->context_node->collection_wrapper() etc..

Regards,

Vinay

Former Member
0 Kudos

Thanks Vinay,

Will take care of your suggestion next time but will need your help for that.

Will keep in touch.

Thanks again,

Abhishek

Former Member
0 Kudos
Hi,

Suppose u r in BTAdminH node and u want to access BTOpportH node.then do like this...

data: lr_entity type ref to cl_crm_bol_entity.
data: lv_test type string.

lr_entity ?= collection_wrapper->get_current( ).
lr_entity = lr_entity->get_related_entity( 'BTHeaderOpportunityExt' ).

lv_test = lr_entity->if_Bol_bo_property_access~get_property_as_string( 'PROBABILITIY' ).

It may help u.

Gaurav, in which method shall i write this code?

Regards,

Kamesh

Former Member
0 Kudos

Hi Abhishek,

Could you please help me with some sample code like how you solve your issue as I am also facing same sort of issue with ICCMP_BP_CP component.

I am working on enhanced component ICCMP_BP_CP/BuPaContactPersonCreate , i need to read the partner_guid from Customer context node in contactpersonaddress context node.

Could you please guid me how to achieve this? if possible, please explain me with some sample code.

i am trying this code in GET_FAXFAX method of contactpersonaddress-faxfax, but it is throwing me the type cast exception.

data: lr_entity type ref to cl_crm_bol_entity.

data: lv_test type string.

lr_entity ?= collection_wrapper->get_current( ).

lr_entity = lr_entity->get_related_entity( 'BuilContactPersonAddressRel' ).

Thanks in advance.

Regards,

Kamesh Bathla

Regards,

Kamesh

Answers (0)