Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2796

Need to default the Sales Org for Account in BP_HEAD Save

$
0
0

Hi,

 

When we create an Account/Company, we need to default the Sales Org on SAVE.

So we have written the following code in EH_ONSAVE of the BP_HEAD/BPHEADOverview of BP_HEAD component where we are trying to created the related entity - 'BuilSalesArrangementRel' and then setting it:

 

lr_core = cl_crm_bol_core=>get_instance( ).

  lr_comp_controller ?= me->comp_controller.

  IF lr_comp_controller IS BOUND.

    lr_entity ?= lr_comp_controller->typed_context->partner->collection_wrapper->get_current( ).

  ENDIF.

 

TRY.

        lr_salesorg ?= lr_entity->get_related_entity( iv_relation_name = 'BuilSalesArrangementRel' ).

      CATCH cx_crm_genil_model_error.                   "#EC NO_HANDLER

      CATCH cx_sy_ref_is_initial.                       "#EC NO_HANDLER

ENDTRY.

lv_region = '220'.

    TRY.

        IF lr_salesorg IS NOT BOUND.

          lr_entity->create_related_entity( iv_relation_name = 'BuilSalesArrangementRel' ).

          lr_salesorg ?= lr_entity->get_related_entity( iv_relation_name = 'BuilSalesArrangementRel' ).

        ENDIF.

       

            IF lr_salesorg->is_changeable( ) NE abap_true.

              lr_salesorg->switch_to_change_mode( ).

            ENDIF.

            ls_sales_area-sales_org = 'O 50000057'

            ls_sales_area-channel = '01'.

            ls_sales_area-division = '01'.

            CALL FUNCTION 'CRM_BUPA_GET_SALES_AREA_PROPS'

              EXPORTING

                is_sales_area_keys = ls_sales_area

              IMPORTING

                es_sales_area      = ls_assigned_sales_areas_new.

            MOVE-CORRESPONDING ls_assigned_sales_areas_new TO ls_sales_area_il  .

            lr_salesorg->set_properties( EXPORTING is_attributes = ls_sales_area_il  ).

 

      CATCH cx_crm_genil_model_error.                   "#EC NO_HANDLER

      CATCH cx_sy_ref_is_initial.                       "#EC NO_HANDLER

    ENDTRY.

 

 

    lr_core->modify( ).

CALL METHOD super->eh_onsave

    EXPORTING

      htmlb_event    = htmlb_event

      htmlb_event_ex = htmlb_event_ex

    IMPORTING

      ev_success     = ev_success.

 

In the debug mode, I can see that lr_entity has the related entity - ' BuilSalesArrangementRel'  and it has the sales org data in it.

 

However, Once the SAVE happens and Company is created, when I go to GENIL_BOL_BROWSER and try to view the entities, I see that ' BuilSalesArrangementRel'  has no entries in it whatsoever.

 

Is there something I am missing.

I also tried with the snippet :

 

    lv_transaction = lr_core->get_transaction( ).

    lv_transaction->save( ).

   lv_transaction->commit( ).

 

However, this did not work either. Kindly help.

 

Regards,

Nisha


Viewing all articles
Browse latest Browse all 2796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>