Quantcast
Channel: SCN: Message List - SAP CRM: Webclient UI - Framework
Viewing all articles
Browse latest Browse all 7775

Re: Auto fill the Sales employee on save of Contact person

$
0
0

Solved the problem myself.

I added following code to the DO_PREPARE_OUTPUT method of view Salesemployee

 

 

 

  CALL METHOD SUPER->DO_PREPARE_OUTPUT

    EXPORTING

      IV_FIRST_TIME = ABAP_FALSE.





  DATA: lr_entity type REF TO cl_crm_bol_entity,

         lv_sales_emp TYPE string,

         lv_emp type bu_partner,

          lv_account type bu_partner,

          lv_account_int type bu_partner,

          lr_core type ref to cl_crm_bol_core,

          lr_account      TYPE REF TO cl_crm_bol_entity,

          LV_TRANSACTION TYPE REF TO if_bol_transaction_context.

  DATA: lv_descr     TYPE bu_descrip.



  lr_core = cl_Crm_bol_core=>get_instance( ).



*get the customer number

  try.

      lr_entity ?= me->typed_context->salesemployee->collection_wrapper->get_current( ).

    catch cx_root.

  endtry.

  lv_account = lr_entity->get_property_as_string( 'BP_NUMBER' ).

  lv_sales_emp = lr_entity->get_property_as_string( 'SALESEMPLOYEE' ).



  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

      INPUT  = lv_account

    IMPORTING

      OUTPUT = lv_account_int.

  if lv_sales_emp is INITIAL.

    lr_entity->switch_to_change_mode( ).



*Get the Sales employee from the customer

    Select partner2 into lv_emp from but050

            where partner1 = lv_account_int and reltyp = 'BUR011'.

    endselect.

*Set the sales employee



    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        INPUT  = lv_emp

      IMPORTING

        OUTPUT = lv_emp.



    lr_entity->set_property( iv_attr_name = 'SALESEMPLOYEE' iv_value = lv_emp ).



    CALL FUNCTION 'CRM_BUPA_DESCRIPTION_READ'

      EXPORTING

        iv_partner          = lv_emp

      IMPORTING

        ev_description_name = lv_descr

      EXCEPTIONS

        OTHERS              = 0.

    IF lv_descr IS NOT INITIAL.

      lr_entity->set_property( iv_attr_name = 'EMPLOYEE_NAME'

                                 iv_value = lv_descr ).

      me->typed_context->salesemployee->collection_wrapper->publish_current( ).

      lr_core->modify( ).

      LV_TRANSACTION = lr_core->get_transaction( ).

      LV_TRANSACTION->save( ).

      LV_TRANSACTION->commit( ).



    ENDIF.



  endif.

endmethod.


Viewing all articles
Browse latest Browse all 7775

Trending Articles



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