Skip to Content

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

Report to update the emp responsible for different business transaction.

Hi All,

I have to mass update the emp responsible for the different business transactions.I tried but not getting appropriate result.however for test i written a code to update the single Object ID. It is working fine  without any dumps and giving the result  , but no actual update is processed.If i check the object ID then it remain assigned to same responsible person to whom it belongs before.

I am pasting my code for review . kindly  suggest the best approach and solution.

SELECTION-SCREEN BEGIN OF BLOCK sl WITH FRAME .

PARAMETERS :        p_type         TYPE      crmt_process_type_db.

SELECT-OPTIONS :    ob_id          FOR       crmd_orderadm_h-object_id.

PARAMETERS:         user_id        TYPE      bu_partner.

PARAMETERS :        p_func         TYPE      crmt_partner_fct.

SELECTION-SCREEN END OF BLOCK sl.

DATA: orderadm           TYPE TABLE OF        crmd_orderadm_h,

       orderadms          TYPE                 crmd_orderadm_h,

       ls_guid            TYPE                 crmt_object_guid,

       lt_save_guid       TYPE                 crmt_object_guid_tab,

       ls_save_guid       TYPE                 crmt_object_guid.

DATA: lt_saved_objects        TYPE        crmt_return_objects,

         ls_saved_objects      TYPE        crmt_return_objects_struc,

         lv_order_object_id    TYPE        crmt_object_id,

         lv_order_object_guid  TYPE        crmt_object_guid32.

TYPES : BEGIN OF ls_logical ,

         ref_partner_handle TYPE numc4,

         ref_partner_fct TYPE  comt_partner_fct,

         ref_partner_no  TYPE  comt_partner_number,

         ref_no_type     TYPE  comt_partner_no_type,

         ref_display_type  TYPE  comt_partner_display_type,

         END OF ls_logical.

*----------------------------------------------------------

****  Declaration for the partner

*----------------------------------------------------------

DATA : lt_partner         TYPE       crmt_partner_comt,

        ls_partner         TYPE       crmt_partner_com,

        lt_nametab         TYPE       crmt_input_field_names_tab,

        ls_nametab         TYPE       crmt_input_field_names ,

        lt_input_fields    TYPE       crmt_input_field_tab,

        ls_input_fields    TYPE       crmt_input_field ,

        ls_logical_key     TYPE       ls_logical ,

        lss_logical_key    TYPE       crmt_logical_key.

*----------------------------------------------------------

****  Declaration for Crm_order_read

*----------------------------------------------------------

DATA: lt_guid           TYPE        crmt_object_guid_tab,

       lt_r_partner      TYPE        crmt_partner_external_wrkt,

       ls_r_partner      TYPE        crmt_partner_external_wrk.

*IF p_type IS NOT INITIAL .

   SELECT SINGLE  * FROM crmd_orderadm_h INTO  orderadms WHERE object_id IN ob_id AND process_type = p_type AND object_type = 'BUS2000108'.

*ENDIF.

*LOOP AT orderadm INTO orderadms.

   ls_guid = orderadms-guid .

REFRESH lt_guid.

COLLECT ls_guid INTO lt_guid.

CALL FUNCTION 'CRM_ORDER_READ'

  EXPORTING

    it_header_guid                    lt_guid

  IMPORTING

    et_partner                        = lt_r_partner.

READ TABLE lt_r_partner INTO ls_r_partner WITH  KEY partner_fct = '00000014'.   "INDEX 1.

ls_r_partner-partner_no       =       user_id.

ls_r_partner-ref_partner_fct  =       p_func.

MOVE-CORRESPONDING ls_r_partner TO ls_partner.

INSERT ls_partner INTO TABLE lt_partner.

*----------------------------------------------------------

****  Partner Details

*----------------------------------------------------------

******** INPUT FIELDS FOR PARTNER FUNC

   ls_nametab-fieldname  = 'DISPLAY NAME'.

*  ls_nametab-changeable = 'X'.

   INSERT ls_nametab INTO TABLE lt_nametab.

   ls_nametab-fieldname  = 'KIND OF ENTRY'.

*  ls_nametab-changeable = 'X'.

   INSERT ls_nametab INTO TABLE lt_nametab.

   ls_nametab-fieldname  = 'NO TYPE'.

*  ls_nametab-changeable = 'X'.

   INSERT ls_nametab INTO TABLE lt_nametab.

   ls_nametab-fieldname  = 'PARTNER NO'.

*  ls_nametab-changeable = 'X'.

   INSERT ls_nametab INTO TABLE lt_nametab.

*  MOVE-CORRESPONDING ls_r_partner TO ls_logical_key.

  ls_logical_key-ref_partner_handle = ls_r_partner-ref_partner_handle.

  ls_logical_key-ref_partner_fct    = ls_r_partner-ref_partner_fct.

  ls_logical_key-ref_partner_no     = ls_r_partner-ref_partner_no.

  ls_logical_key-ref_no_type        = ls_r_partner-ref_no_type.

  ls_logical_key-ref_display_type   = ls_partner-ref_display_type.

   ls_input_fields-ref_guid      = ls_guid.

   ls_input_fields-ref_handle    = ls_r_partner-ref_handle.

   ls_input_fields-ref_kind      = 'A'.

   ls_input_fields-objectname    = 'PARTNER'.

   ls_input_fields-logical_key   = ls_logical_key.

   ls_input_fields-field_names[] = lt_nametab[].

   INSERT ls_input_fields INTO TABLE lt_input_fields.

   CLEAR : ls_nametab ,lt_nametab,ls_input_fields.

   CALL FUNCTION 'CRM_ORDER_MAINTAIN'

     EXPORTING

       it_partner      = lt_partner

     CHANGING

       ct_input_fields = lt_input_fields.

   ls_save_guid = ls_guid.

   APPEND ls_save_guid TO lt_save_guid.

   CALL FUNCTION 'CRM_ORDER_SAVE'

     EXPORTING

       it_objects_to_save = lt_save_guid

        iv_update_task_local       = 'X'

     IMPORTING

       et_saved_objects   = lt_saved_objects

    EXCEPTIONS

      document_not_saved         = 1

      OTHERS                     = 2 .

   READ TABLE lt_saved_objects INTO ls_saved_objects INDEX 1.

   lv_order_object_guid = ls_saved_objects-guid.

   lv_order_object_id   = ls_saved_objects-object_id.

   WRITE:/ lv_order_object_guid , lv_order_object_id .

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

*  ENDLOOP.


Thanks in advance .

Ravneet

Former Member
Not what you were looking for? View more on this topic or Ask a question