on 04-17-2006 8:12 PM
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.
Hi
You should set a break-point in function module crm_order_maintain and manually close a follow on. By doing this you will see exactly what values you need to pass to the function module. You will also see that this function module will get fired a few times, depending on what processing you do to the follow up.
Here is the code I use for closing an interaction record, I hope it helps...
DATA:
ls_input_field TYPE crmt_input_field,
lt_input_field TYPE crmt_input_field_tab,
ls_input_names TYPE crmt_input_field_names,
lt_input_names TYPE crmt_input_field_names_tab,
lt_orderadm_h TYPE crmt_orderadm_h_wrkt,
ls_orderadm_h TYPE crmt_orderadm_h_wrk,
et_status TYPE crmt_status_comt,
es_status TYPE crmt_status_com,
wa_status type crmt_status_wrk.
es_status-ref_guid = iv_guid.
es_status-ref_kind = 'A'.
es_status-status = 'E0003'.
if ls_orderadm_h-process_type = 'Z001'.
es_status-user_stat_proc = 'ZINTREC'.
else.
es_status-user_stat_proc = 'ZCALLIST'.
endif.
es_status-activate = 'X'.
append es_status to et_status.
ls_input_field-REF_GUID = iv_guid.
ls_input_field-REF_KIND = 'A'.
ls_input_field-OBJECTNAME = 'STATUS'.
if ls_orderadm_h-process_type = 'Z001'.
ls_input_field-LOGICAL_KEY = 'E0003ZINTREC'.
else.
ls_input_field-LOGICAL_KEY = 'E0003ZCALLIST'.
endif.
clear ls_input_names.
ls_input_names-FIELDNAME = 'ACTIVATE'.
append ls_input_names to gt_field_names.
ls_input_field-field_names = gt_field_names[].
append ls_input_field to lt_input_field.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_status = et_status
CHANGING
ct_orderadm_h = it_orderadm_h
ct_input_fields = lt_input_field
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_status = et_status
CHANGING
ct_orderadm_h = it_orderadm_h
ct_input_fields = lt_input_field
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
CALL FUNCTION 'BAPI_ACTIVITYCRM_SAVE'
TABLES
objects_to_save = lt_save
saved_objects = saved_objects
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
COMMIT WORK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.