Skip to Content
0
Feb 03, 2010 at 08:45 AM

BADI to check and limit the Completed Status of Complaint with message...

62 Views

METHOD if_ex_crm_order_status~before_change.

CONSTANTS: true TYPE crmt_boolean VALUE 'X'.

CONSTANTS: c_bt_complaint TYPE crmv_proc_type-process_type VALUE 'YRMC'.

DATA:lv_guid TYPE crmt_object_guid.

DATA: lt_guids TYPE crmt_object_guid_tab.

DATA: lt_orderadm_h TYPE crmt_orderadm_h_wrkt,

ls_orderadm_h TYPE crmt_orderadm_h_wrk.

DATA: l_crmt_partner_external_wrkt TYPE crmt_partner_external_wrkt.

DATA: ls_crmt_partner_external_wrkt LIKE LINE OF l_crmt_partner_external_wrkt.

DATA: ls_but000 TYPE but000.

DATA: l_partner TYPE bu_partner.

DATA: l_uname TYPE syuname.

DATA: ls_idno TYPE bal_s_idno,

lr_idno TYPE bal_r_idno.

DATA: l_user_flag TYPE flag.

CLEAR: lt_guids, lv_guid.

lv_guid = is_status_wrk-guid.

ls_idno-low-msgid = 'Z08S1_OSS'.

ls_idno-high-msgid = 'Z08S1_OSS'.

ls_idno-low-msgno = '001'.

ls_idno-high-msgno = '001'.

ls_idno-sign = 'I'.

ls_idno-option = 'BT'.

APPEND ls_idno TO lr_idno.

CALL FUNCTION 'CRM_MESSAGES_DELETE'

EXPORTING

it_r_msgidno = lr_idno

iv_ref_object = lv_guid

iv_ref_kind = 'A'

iv_caller_name = 'PARTNER'

EXCEPTIONS

appl_log_error = 1

OTHERS = 2

.

CALL FUNCTION 'CRM_MESSAGE_COLLECT'

EXPORTING

iv_caller_name = 'PARTNER'

iv_ref_object = lv_guid

iv_ref_kind = 'A'

iv_msgno = '001'

iv_msgid = 'Z08S1_OSS'

iv_msgty = 'I'

EXCEPTIONS

not_found = 1

appl_log_error = 2

OTHERS = 3

.

IF sy-subrc <> 0.

ENDIF.

INSERT lv_guid INTO TABLE lt_guids.

CLEAR: lt_orderadm_h.

CLEAR: lt_orderadm_h[].

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_guids

iv_no_auth_check = true

IMPORTING

et_orderadm_h = lt_orderadm_h

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.

IF NOT lt_orderadm_h IS INITIAL.

READ TABLE lt_orderadm_h INTO ls_orderadm_h INDEX 1.

IF sy-subrc = 0.

IF ls_orderadm_h-process_type = c_bt_complaint.

IF ls_orderadm_h-created_by <> sy-uname.

l_user_flag = 'X'.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

IF l_user_flag = 'X'.

IF is_status_wrk-check_only EQ 'X'.

RAISE not_allowed.

ENDIF.

ENDIF.

ENDMETHOD.

Dear experts,

We have the following requirement:

The complaint (Transaction type: ) is to be checked for the creator & if the creator matches with the logon user then only the complaint can be set to Completed Status. For this we have used following:

Definition Name: CRM_ORDER_STATUS ; Interface: BEFORE_CHANGE. Status profile: CRMCOMPL: Status: E0005

Also we need to display a message "Only Complaint creator can close it by setting to Completed Status." when any user accesses the complaint either in display / edit mode.

The code is indicated as above.

Now The problem is that the message is getting diaplayed only in display mode and not in edit mode.

can anyone suggest.

Best Regards, Murugesh