cancel
Showing results for 
Search instead for 
Did you mean: 

Read attribute from context node BuilContact

Former Member
0 Kudos

Hi all,

I'm pulling my hair out here with something that looks very simple but I just don't manage to get this working.

I need to perform a check on an attribute in context node BuilContact. This attribute was created via the AET.

Some more information:

On the BP_CONT/ContactQuickCreate view we added the field "group flag" under the email address. At the moment the user hits the "back" button to return to the customer screen I need to perform a check to see if the group flag is ticked or not. In an other post here on SCN I was advised to perform the checks in BP_DATA/AccountContactViewset in the EH_ONDONE method.

The view holds a context node BuilContact and when I open up the attributes, the group flag is indeed there. Question now is how I need to read that attribute.

Could anyone shine some light on this very annoying problem please?

Current code

lr_entity_cont ?= me->typed_context->builcontact->collection_wrapper->get_current( ).
lr_col ?= lr_entity_cont->get_related_entity( iv_relation_name = 'GetHeaderForContactRel' ).
lr_status_it ?= lr_col->get_iterator( ).
lr_data_property = lr_iterator->get_first( ).
lv_group_email = lr_entity_cont->get_property_as_string( 'Group_email' ).

This gives an error the moment I try to do the Get_first( ) method because the Iterator contains no values. Iterator is bound.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

To be complete now

DATA: lr_entity_cont TYPE REF TO cl_crm_bol_entity,

lr_col              TYPE REF TO if_bol_entity_col,

lv_iterator type ref to IF_BOL_ENTITY_COL_ITERATOR.

lr_data_property            TYPE REF TO if_bol_bo_property_access.

lr_entity_cont ?= me->typed_context->builcontact->collection_wrapper->get_current( ).

lr_col ?= lr_entity_cont->get_related_entity( iv_relation_name = 'GetHeaderForContactRel' ).

lv_iterator ?= lr_col->get_iterator( ).

lr_data_property = lv_iterator->get_first( ).

lv_group_email = lr_entity_cont->get_property_as_string( 'ZZAFLD00000Z' ).

Former Member
0 Kudos

Don't get me wrong, it's still not solved.

anyone an idea what is wrong?

SudheerHarman
Advisor
Advisor
0 Kudos

Hi Tom

Please checkit once in GENIL_BOL_BROWSER.

Becase there is no relation called 'GetHeaderForContactRel' instead there is a relation "BuilGetHeaderforContactRel" from BuilContactPerson.

I hope this should solve your issue.

Regards

Sudheer

former_member202474
Contributor
0 Kudos

Hi Tom,

                The relationship name is incorrect in your code it should be 'BuilGetHeaderforContactRel'.

Also the code looks fine except the last line.It should be

lv_group_email = lr_data_propertty>get_property_as_string( 'ZZAFLD00000Z' ).

Hope this helps.

Regards,

Ruby.

Former Member
0 Kudos

i'm getting this error now when he tries to get the related entity. My lr_col is of type

if_bol_entity_col while the system expects a cl_crm_bol_entity. Problem is that the class cl_crm_bol_entity does not have a method get_iterator for the next step.

During a 'CAST' operation ('?=' oder 'MOVE ? TO')a type conflict occurred. The

source type '\CLASS=CL_CRM_BOL_ENTITY' is not compatible for assigning with the

target type '\INTERFACE=IF_BOL_ENTITY_COL'.

Current code:

lr_entity_cont ?= me->typed_context->builcontact->collection_wrapper->get_current( ).
lr_col ?= lr_entity_cont->get_related_entity( iv_relation_name = 'BuilGetHeaderforContactRel' ).
lv_iterator ?= lr_col->get_iterator( ).
lr_data_property = lv_iterator->get_first( ).
lv_group_email = lr_data_property->get_property_as_string( 'ZZAFLD00000Z' ).

Former Member
0 Kudos

wrong statement : lr_col ?= lr_entity_cont->get_related_entity( iv_relation_name ='BuilGetHeaderforContactRel' ).

you have to write lr_entity in the place of lr_col.

Former Member
0 Kudos

ok figured it out the get_related_entity replaced by get_related_entities did the trick.

issue now is that apparently the BuilGetHeaderforContactRel did not return the BuilHeader for the contact but from the customer...

How did that happen?

Former Member
0 Kudos

Anyone?

Former Member
0 Kudos

Hi Tom,

I am right, u are navigating from BuilContact node ( Root object - BuilContactPerson ).

Via the relationship "BuilGetHeaderforContactRel" you are determining the Header data i.e, BuilHeader, in other words the customer.

U already have the contact person in the BuilContactPerson node.

-

Anish

Former Member
0 Kudos

mmm ok. other approach then. The BuilContactPerson node, when i get the attributes from this one, I can see in debug that it is of type CRMST_CONTACT_PERSON_OBJ_BUIL. But the structure where my attribute is in is crmst_header_object_buil. How on earth do I get to that?

Former Member
0 Kudos

Hi Tom,

Please try with the value of one contact person number in genil_bol_browser.

I found that if you use the relationship "BuilGetPersonforContactRel" i am able to get details of the contact person.

The attribute structure is also just as you asked for, its CRMST_HEADER_OBJECT_BUIL.

Hope it helps.

-

Anish

Former Member
0 Kudos

Anish,

Thank you very much. Points granted!

Answers (3)

Answers (3)

Former Member
0 Kudos

Kumar,

When I try your code i get a dump

Relation GetHeaderForContactRel is not (yet) supported

any Ideas?

former_member188098
Active Contributor
0 Kudos

Hi Tom,

lr_status_it contains iterators value.Try to Fetch from that one with get_first( ).

But you are usin lr_iterator i think thats why u r getting error,

Regards,


kumar5
Active Contributor
0 Kudos

It should be like:

Data: lr_iterator type ref to IF_BOL_ENTITY_COL_ITERATOR.

lr_entity_cont ?= me->typed_context->builcontact->collection_wrapper->get_current( ).
lr_col ?= lr_entity_cont->get_related_entity( iv_relation_name = 'GetHeaderForContactRel' ).
lr_iterator ?= lr_col->get_iterator( ).
lr_data_property = lr_iterator->get_first( ).
lv_group_email = lr_entity_cont->get_property_as_string( 'Group_email' ).

Thanks

Kumar