on 10-09-2020 5:20 PM
Hello,
On SAP CRM, Cancellation of Service Confirmation cancels only items but not header. When I checked the code of event 'EH_ONCANCEL_CONF' I noticed that code only modifies items statuses to 'I1096' and 'I1095'. I know from the documents I read that if all items are cancelled that header gets cancelled too. Does anyone knows where headers cancelation occurs so I can check why only Items cancelled on my case?
Here s the code of 'EH_ONCANCEL_CONF'.
METHOD eh_oncancel_conf.
INCLUDE: crm_object_names_con,
crm_object_kinds_con,
crm_status_con,
crm_mode_con.
DATA: lr_tcc TYPE REF TO cl_bt117s_s_bspwdcomponen_impl,
lr_entity TYPE REF TO cl_crm_bol_entity,
lr_result TYPE REF TO if_bol_entity_col,
lr_msg_srv TYPE REF TO cl_bsp_wd_message_service,
ls_btorder TYPE crmst_guid_btil,
lt_req_objects TYPE crmt_object_name_tab,
lt_header_guid TYPE crmt_object_guid_tab,
lt_orderadm_i TYPE crmt_orderadm_i_wrkt,
ls_orderadm_i TYPE crmt_orderadm_i_wrk,
lt_status TYPE crmt_status_wrkt,
ls_status TYPE crmt_status_wrk,
lt_status_com TYPE crmt_status_comt,
ls_status_com TYPE crmt_status_com,
lt_input_fields TYPE crmt_input_field_tab,
ls_input_fields TYPE crmt_input_field,
lt_fieldname TYPE crmt_input_field_names_tab,
ls_fieldname TYPE crmt_input_field_names,
lv_error TYPE boolean.
lr_msg_srv = me->view_manager->get_message_service( ).
IF me->typed_context->btqrsrvcfm->selected_index = 0.
* no confirmation maked on list
lr_msg_srv->add_message( iv_msg_type = 'I'
iv_msg_id = 'CRMN_REPORT'
iv_msg_number = '108' ).
RETURN.
ENDIF.
lr_entity ?= me->typed_context->btqrsrvcfm->collection_wrapper->get_current( ).
CHECK lr_entity IS BOUND.
lr_tcc ?= me->comp_controller.
lr_entity ?= lr_tcc->create_bt_root( lr_entity ).
CHECK lr_entity IS BOUND.
CALL METHOD lr_entity->if_bol_bo_property_access~get_properties
IMPORTING
es_attributes = ls_btorder.
INSERT ls_btorder-crm_guid INTO TABLE lt_header_guid.
INSERT gc_object_name-orderadm_h INTO TABLE lt_req_objects.
INSERT gc_object_name-orderadm_i INTO TABLE lt_req_objects.
INSERT gc_object_name-status INTO TABLE lt_req_objects.
* read items and status
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_header_guid
iv_mode = gc_mode-change
it_requested_objects = lt_req_objects
IMPORTING
et_orderadm_i = lt_orderadm_i
et_status = lt_status
EXCEPTIONS
OTHERS = 1.
IF sy-subrc IS NOT INITIAL.
lr_msg_srv->add_message( iv_msg_type = sy-msgty
iv_msg_id = sy-msgid
iv_msg_number = sy-msgno
iv_msg_v1 = sy-msgv1
iv_msg_v2 = sy-msgv2
iv_msg_v3 = sy-msgv3 ).
RETURN.
ENDIF.
* check confirmation is completed
READ TABLE lt_status TRANSPORTING NO FIELDS
WITH KEY guid = ls_btorder-crm_guid
status = gc_status-completed
active = abap_true.
IF sy-subrc IS NOT INITIAL.
lr_msg_srv->add_message( iv_msg_type = 'W'
iv_msg_id = 'CRM_CONFIRM_SRV'
iv_msg_number = '109' ).
lv_error = abap_true.
ENDIF.
* check not already cancelled
READ TABLE lt_status TRANSPORTING NO FIELDS
WITH KEY guid = ls_btorder-crm_guid
status = gc_status-cancelled_conf_srv
active = abap_true.
IF sy-subrc IS INITIAL.
lr_msg_srv->add_message( iv_msg_type = 'W'
iv_msg_id = 'CRM_CONFIRM_SRV'
iv_msg_number = '108' ).
lv_error = abap_true.
ENDIF.
* build up working structure for api call
ls_fieldname-fieldname = 'ACTIVATE'.
INSERT ls_fieldname INTO TABLE lt_fieldname.
LOOP AT lt_orderadm_i INTO ls_orderadm_i.
CLEAR ls_status_com.
CLEAR ls_input_fields.
ls_status_com-ref_guid = ls_orderadm_i-guid.
ls_status_com-ref_kind = gc_object_ref_kind-orderadm_i.
ls_status_com-status = gc_status-cancelled_invoice.
ls_status_com-activate = abap_true.
INSERT ls_status_com INTO TABLE lt_status_com.
ls_input_fields-ref_guid = ls_orderadm_i-guid.
ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_i.
ls_input_fields-objectname = gc_object_name-status.
ls_input_fields-logical_key = ls_status_com-status.
ls_input_fields-field_names = lt_fieldname.
INSERT ls_input_fields INTO TABLE lt_input_fields.
ls_status_com-status = gc_status-cancelled_conf_srv.
INSERT ls_status_com INTO TABLE lt_status_com.
ls_input_fields-logical_key = ls_status_com-status.
INSERT ls_input_fields INTO TABLE lt_input_fields.
ENDLOOP.
* check items available
IF sy-subrc IS NOT INITIAL.
lr_msg_srv->add_message( iv_msg_type = 'W'
iv_msg_id = 'CRM_LEASING_CANCEL'
iv_msg_number = '008' ).
lv_error = abap_true.
ENDIF.
* cancel all items
IF lv_error = abap_false.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_status = lt_status_com
CHANGING
ct_input_fields = lt_input_fields
EXCEPTIONS
OTHERS = 1.
IF sy-subrc IS INITIAL.
* save confirmation
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_header_guid
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
IF sy-subrc IS INITIAL.
* call commit
COMMIT WORK AND WAIT.
lr_msg_srv->add_message( iv_msg_type = 'S'
iv_msg_id = 'CRMN_REPORT'
iv_msg_number = '121' ).
ELSE.
* error during save
lr_msg_srv->add_message( iv_msg_type = sy-msgty
iv_msg_id = sy-msgid
iv_msg_number = sy-msgno
iv_msg_v1 = sy-msgv1
iv_msg_v2 = sy-msgv2
iv_msg_v3 = sy-msgv3 ).
ENDIF.
ELSE.
* error during maintain
lr_msg_srv->add_message( iv_msg_type = sy-msgty
iv_msg_id = sy-msgid
iv_msg_number = sy-msgno
iv_msg_v1 = sy-msgv1
iv_msg_v2 = sy-msgv2
iv_msg_v3 = sy-msgv3 ).
ENDIF.
ENDIF.
* init and unlock
CALL FUNCTION 'CRM_ORDER_INITIALIZE'
EXPORTING
it_guids_to_init = lt_header_guid
EXCEPTIONS
OTHERS = 0.
ENDMETHOD.
Thank you,
Best Regards.
Hi Mehmet,
I think the note 1389839 - "Cancel completed confirmation on item level" and the SAP Help documentation for topic "Statuses in the Service Confirmation"
can help.
Best Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gerhard,
This note covers where you want to cancel only selected items rather than all items. But my problem is cancelation of header. On some cases header does not get system status "I1096". On code I send all items getting canceled but I want to know where header gets cancelled.
Thank you,
Best Regards.
User | Count |
---|---|
5 | |
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.