Skip to Content

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

CRM CICO - Automatically complete follow on activities

Hi all,

In tcode CIC0 to automatically complete the activities I am trying to use BAPI BAPI_ACTIVITYCRM_CHANGEMULTI. I am forwarding the whole program too. Can anyone please tell me why the progrm si not working ?

REPORT z_crmorderread.

DATA : lt_header_guid TYPE crmt_object_guid_tab,

wa_header_guid TYPE crmt_object_guid,

wac TYPE crmt_object_guid,

lt_doc_flow TYPE crmt_doc_flow_wrkt,

wa_doc_flow TYPE crmt_doc_flow_wrk,

lt_status TYPE crmt_status_wrkt,

lt_save TYPE TABLE OF bapibus20001_guid_dis,

wa_save TYPE bapibus20001_guid_dis,

h_header TYPE TABLE OF bapibus2000110_header_ins,

wah_header TYPE bapibus2000110_header_ins, " work area

hx_header TYPE TABLE OF bapibus2000110_header_insx,

wahx_header TYPE bapibus2000110_header_insx, " work area

s_status TYPE TABLE OF bapibus20001_status_ins,

was_status TYPE bapibus20001_status_ins, " work area

lt_input_fields type table of BAPIBUS20001_INPUT_FIELDS,

wa_input_fields type BAPIBUS20001_INPUT_FIELDS,

sx_status TYPE TABLE OF bapibus20001_status_insx,

wasx_status TYPE bapibus20001_status_insx. " work area

DATA : return TYPE TABLE OF bapiret2,

vc_log_handle TYPE balloghndl, " log_handle

saved_objects TYPE TABLE OF bapibus20001_object_id,

return2 TYPE TABLE OF bapiret2.

*---- Here I am hardcoding the GUID of the complaint.

wa_header_guid = '44401B7FCBF1016C00000000888DE646'.

APPEND wa_header_guid TO lt_header_guid.

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_header_guid

IMPORTING

et_status = lt_status

et_doc_flow = lt_doc_flow

CHANGING

cv_log_handle = vc_log_handle

  • EXCEPTIONS

  • DOCUMENT_NOT_FOUND = 1

  • ERROR_OCCURRED = 2

  • DOCUMENT_LOCKED = 3

  • NO_CHANGE_AUTHORITY = 4

  • NO_DISPLAY_AUTHORITY = 5

  • NO_CHANGE_ALLOWED = 6

  • OTHERS = 7

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE lt_doc_flow INTO wa_doc_flow INDEX 1.

wah_header-guid = wa_doc_flow-objkey_b.

wa_input_fields-REF_GUID = wa_doc_flow-objkey_b.

append wa_input_fields to lt_input_fields.

was_status-ref_guid = wa_doc_flow-objkey_b.

wac = wa_doc_flow-objkey_a.

wa_save-guid = wa_doc_flow-objkey_b.

APPEND wah_header TO h_header.

wahx_header-guid = 'X'.

APPEND wahx_header TO hx_header.

was_status-status = 'E0005'.

APPEND was_status TO s_status.

wasx_status-ref_guid = 'X'.

wasx_status-status = 'X'.

APPEND wasx_status TO sx_status.

CALL FUNCTION 'BAPI_ACTIVITYCRM_CHANGEMULTI'

TABLES

header = h_header

headerx = hx_header

status = s_status

statusx = sx_status

  • input_fields = lt_input_fields

return = return.

APPEND wa_save TO lt_save.

**commit work.

CALL FUNCTION 'BAPI_ACTIVITYCRM_SAVE'

  • EXPORTING

  • UPDATE_TASK_LOCAL = 'X' "update_task_local

  • SAVE_FRAME_LOG = 'X' "save_frame_log

IMPORTING

log_handle = vc_log_handle

TABLES

objects_to_save = lt_save

saved_objects = saved_objects

return = return2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

COMMIT WORK.

break-point.

The contents of both return tables are :

Return :

W |CRM_ORDER |004 |Referenced object type (STATUS) not allowed

S |CRM_MESSAGES |006 |Start of processing 'Individual receipt'

Return2

E |CRM_ORDER |037 |The document could not be saved

Regards and thanks in advance,

Varun.

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