Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Default the ROLE based on account type

Hi experts,

        I have a requirement to default the ROLE field(drop down) based on account type like

Contact should be created with default role "Contact"

Prospectus should be created with Default BP Role “ Prospect” in  Individual account

Competitor should be created with competitor role "Competitor"

Corporate should be created with role as "corporate"

Please help me with this objects with possible solutions

Thanks in advance.


Hello Shiva,

You can enhance the event EH_ONSAVE of the component BP_HEAD, View BP_HEAD/BPHEADOverview.

You can maintain a z table with the account type and the default role, and then, validate the account type and use this piece of code (this is an example for the role "Prospect":


       lr_header TYPE REF TO if_bol_bo_property_access,

        lr_entity TYPE REF TO cl_crm_bol_entity,

        lr_boprol TYPE REF TO if_bol_entity_col,

        lr_core_tmp           TYPE REF TO cl_crm_bol_core.

    lr_header  ?= me->ztyped_context->builheader->collection_wrapper->get_current( ).

     IF lr_header IS BOUND.

       lr_entity ?= lr_header.

       lr_boprol ?= lr_entity->get_related_entities( iv_relation_name = 'BuilRolesRel').

       IF lr_boprol IS BOUND.

         CALL METHOD cl_crm_uiu_bp_tools=>add_role


             ir_header       = lr_entity

             iv_rolecategory = 'BUP002'..

         lr_core_tmp = cl_crm_bol_core=>get_instance( ).

         lr_core_tmp->modify( ).



And finally invoke the super eh_onsave.

call method super->eh_onsave


       htmlb_event    = htmlb_event

       htmlb_event_ex = htmlb_event_ex


       ev_success     = ev_success.

Best regards,


1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question