Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Apr 13, 2016 at 03:21 PM

    Hello All,

    I have solved this and it is working. there is one new issue that when i pass the value for emp responsible in form of BP like number value (eg 7001245) it is working fine , however if i pass the value of emp responsible in form of name like (adam) then the report works fine and it shows updated successfully however when i try to recheck by going to particular object id than it shows emp responsible with the name which was entered and there is message in brackets ( user doesnt exist) however user do exist.

    kindly help me to solve this .

    Thanks

    Ravneet

    Add comment
    10|10000 characters needed characters exceeded