on 2013 Nov 01 1:08 PM
Can any body provide information about this badi: CRM_ORDER_STATUS
And also pls provide how to implement with some example….
Thanks in advance
Purpose: BAdI for Status Management - You can use this Business Add-In (BAdI) for the following purposes within the framework of business transactions:
You can find details in the documentation for the assigned interface IF_EX_CRM_ORDER_STATUS.
The BAdI is filter-dependent. A combination of the technical status with the status profile is used as a filter. You can use the same implementation for several statuses. Several different active implementations for the same status can also exist. All these are then executed, although the call sequence is undefined.
Example: The system status 'Open' has the filter value 'I1002'. The user status 'E0002' from the CRMACTIV status profile has the filter filter value 'E0002CRMACTIV'. You can select filter values with the F4 help.
When calling the methods, the current work structure IS_STATUS_WRK is transferred. (Description of fields in the work work structure: See documentation Structure CRMT_STATUS_WRK ).
Source Code:(Refer sap delivered implementation- CMS_ORDER_STATUS : Contract Status - Validations on Award)
METHOD if_ex_crm_order_status~after_change .
INCLUDE cms_iph_constants.
* DATA : ls_orderadm_h TYPE crmt_orderadm_h_wrk.
DATA : lv_object_id TYPE crmt_object_id.
CHECK is_status_wrk-active = 'X' AND
is_status_wrk-user_stat_proc = 'CMSCON01' AND
( is_status_wrk-status = 'E0003' OR is_status_wrk-status =
'E0004' ).
IF is_status_wrk-kind = gc_object_kind-orderadm_h.
* header
* CLEAR ls_orderadm_h.
* CALL FUNCTION 'CRM_ORDERADM_H_READ_OB'
* EXPORTING
* iv_guid = is_status_wrk-guid
* IMPORTING
* es_orderadm_h_wrk = ls_orderadm_h.
* Save the contract in registry everytime once it is awarded
CALL FUNCTION 'CMS_CASCADE_REG_ORDER'
EXPORTING
iv_guid = is_status_wrk-guid
iv_object_kind = is_status_wrk-kind
IMPORTING
ev_object_id = lv_object_id.
ENDIF.
ENDMETHOD.
METHOD if_ex_crm_order_status~before_change .
INCLUDE cms_iph_constants.
DATA: ls_orderadm_h TYPE crmt_orderadm_h_wrk,
ls_orderadm_i TYPE crmt_orderadm_i_wrk,
lt_orderadm_h_wrk TYPE crmt_orderadm_h_wrkt,
lt_orderadm_i_wrk TYPE crmt_orderadm_i_wrkt.
DATA: ls_appointment_wrk TYPE crmt_appointment_wrk,
lt_appointment TYPE crmt_appointment_wrkt,
ls_date_wrk TYPE crmt_date_wrk,
lt_date_wrkt TYPE crmt_date_wrkt,
ls_price_agreements_crm TYPE crmt_price_agreements_crm_wrk,
lt_price_agreements_crm TYPE crmt_price_agreements_crm_wrkt,
lt_partner_wrk TYPE comt_partner_wrkt,
ls_partner_control TYPE crmt_partner_control.
DATA: ls_ref_object TYPE crmt_inherit_guid_struc,
lt_ref_objects TYPE crmt_inherit_guid_struc_tab.
DATA: lv_date_error TYPE crmt_boolean,
lv_partner_error TYPE crmt_boolean,
lv_price_error TYPE crmt_boolean,
lv_constart_date TYPE crmt_date,
lv_object_id TYPE crmt_object_id.
DATA: lt_docu_rel TYPE TABLE OF cmsc_docu_rel.
CHECK is_status_wrk-active_old = 'X' AND
is_status_wrk-user_stat_proc = 'CMSCON01' AND
( is_status_wrk-status = 'E0003' OR is_status_wrk-status =
'E0004' ).
CLEAR : ls_appointment_wrk,
ls_date_wrk,
ls_price_agreements_crm,
ls_ref_object.
REFRESH : lt_appointment,
lt_date_wrkt,
lt_price_agreements_crm,
lt_ref_objects.
CLEAR : lv_price_error,
lv_partner_error,
lv_date_error.
IF is_status_wrk-kind = gc_object_kind-orderadm_h.
* header
CLEAR ls_orderadm_h.
CALL FUNCTION 'CRM_ORDERADM_H_READ_OB'
EXPORTING
iv_guid = is_status_wrk-guid
IMPORTING
es_orderadm_h_wrk = ls_orderadm_h.
CALL FUNCTION 'CRM_ORDERADM_I_READ_OB'
EXPORTING
iv_header = is_status_wrk-guid
IMPORTING
et_orderadm_i_wrk = lt_orderadm_i_wrk
EXCEPTIONS
OTHERS = 0.
ELSEIF is_status_wrk-kind = gc_object_kind-orderadm_i.
* item
CLEAR ls_orderadm_i.
CALL FUNCTION 'CRM_ORDERADM_I_READ_OB'
EXPORTING
iv_guid = is_status_wrk-guid
IMPORTING
es_orderadm_i_wrk = ls_orderadm_i.
INSERT ls_orderadm_i INTO TABLE lt_orderadm_i_wrk.
* header
CLEAR ls_orderadm_h.
CALL FUNCTION 'CRM_ORDERADM_H_READ_OB'
EXPORTING
iv_guid = ls_orderadm_i-header
IMPORTING
es_orderadm_h_wrk = ls_orderadm_h.
ENDIF.
CALL FUNCTION 'CMS_CASCADE_REL_READ'
EXPORTING
iv_appl = gc_kappl-contract
iv_rel_flag = gc_rel-docu
TABLES
et_docu_rel = lt_docu_rel.
READ TABLE lt_docu_rel
WITH KEY kappl = gc_kappl-contract
tran_type = ls_orderadm_h-process_type
TRANSPORTING NO FIELDS.
** not relevant for validation,hence eject
IF sy-subrc NE 0.
EXIT.
ENDIF.
** Complete the header level checks
IF is_status_wrk-kind = gc_object_kind-orderadm_h.
REFRESH: lt_date_wrkt,
lt_partner_wrk,
lt_ref_objects.
** read appointments
CALL FUNCTION 'CRM_DATES_READ_SINGLE_OW'
EXPORTING
iv_ref_guid = is_status_wrk-guid
iv_ref_kind = is_status_wrk-kind
IMPORTING
et_date_wrk = lt_date_wrkt
EXCEPTIONS
link_does_not_exist = 1
entry_does_not_exist = 1
OTHERS = 2.
** check for dates
LOOP AT lt_date_wrkt INTO ls_date_wrk.
CALL FUNCTION 'CMS_1O_DATE_CHECK_ON_AWARD'
EXPORTING
iv_ref_guid = is_status_wrk-guid
iv_ref_kind = is_status_wrk-kind
is_date_wrk = ls_date_wrk
IMPORTING
ev_date_error = lv_date_error
EXCEPTIONS
errors_occured = 1
OTHERS = 2.
ENDLOOP.
** Get contract start date
READ TABLE lt_date_wrkt INTO ls_date_wrk WITH KEY
appt_type = gc_dates-cntr_start_date.
IF sy-subrc = 0.
CALL FUNCTION 'CMS_TIMESTAMP_TO_DATE'
EXPORTING
iv_timestamp = ls_date_wrk-timestamp_from
iv_timezone = ls_date_wrk-timezone_from
IMPORTING
ev_date = lv_constart_date.
ENDIF.
** check for partner
CLEAR ls_ref_object.
MOVE is_status_wrk-guid TO ls_ref_object-guid.
INSERT ls_ref_object INTO TABLE lt_ref_objects.
** Read Partners
CALL FUNCTION 'CRM_PARTNER_READ_MULTI_OB'
EXPORTING
it_ref_objects = lt_ref_objects
IMPORTING
et_wrk = lt_partner_wrk.
CALL FUNCTION 'CRM_PARTNER_GET_CONTROL_INF_OW'
EXPORTING
iv_ref_guid = is_status_wrk-guid
iv_ref_kind = is_status_wrk-kind
IMPORTING
es_partner_control = ls_partner_control
EXCEPTIONS
OTHERS = 0.
CALL FUNCTION 'CMS_1O_PARTNER_CHECK_ON_SAVE'
EXPORTING
is_orderadm_h = ls_orderadm_h
it_partner_wrk = lt_partner_wrk
ls_partner_control = ls_partner_control
IMPORTING
ev_partner_error = lv_partner_error
EXCEPTIONS
errors_occured = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
** Complete the item level checks now
LOOP AT lt_orderadm_i_wrk INTO ls_orderadm_i.
REFRESH : lt_date_wrkt,
lt_price_agreements_crm.
** read appointments
CALL FUNCTION 'CRM_DATES_READ_SINGLE_OW'
EXPORTING
iv_ref_guid = ls_orderadm_i-guid
iv_ref_kind = gc_object_kind-orderadm_i
IMPORTING
et_date_wrk = lt_date_wrkt
EXCEPTIONS
link_does_not_exist = 1
entry_does_not_exist = 1
OTHERS = 2.
** check for dates at item level
LOOP AT lt_date_wrkt INTO ls_date_wrk.
CALL FUNCTION 'CMS_1O_DATE_CHECK_ON_AWARD'
EXPORTING
iv_ref_guid = ls_orderadm_i-guid
iv_ref_kind = gc_object_kind-orderadm_i
is_date_wrk = ls_date_wrk
IMPORTING
ev_date_error = lv_date_error
EXCEPTIONS
errors_occured = 1
OTHERS = 2.
ENDLOOP.
IF lv_constart_date IS INITIAL.
** Get contract start date
READ TABLE lt_date_wrkt INTO ls_date_wrk WITH KEY
appt_type = gc_dates-cntr_start_date.
IF sy-subrc = 0.
CALL FUNCTION 'CMS_TIMESTAMP_TO_DATE'
EXPORTING
iv_timestamp = ls_date_wrk-timestamp_from
iv_timezone = ls_date_wrk-timezone_from
IMPORTING
ev_date = lv_constart_date.
ENDIF.
ENDIF.
**** This check is not relevant anymore as in Pharma scenario we generate conditions at a later stage so this check
**** will always fail here.
*** Read Price agreement
* CALL FUNCTION 'CRM_PRICE_AGRMNTS_READ_OW'
* EXPORTING
* iv_ref_guid = ls_orderadm_i-guid
* iv_ref_kind = gc_object_kind-orderadm_i
* IMPORTING
* es_price_agreements_crm_wrk = ls_price_agreements_crm
* EXCEPTIONS
* not_found = 1
* OTHERS = 2.
*
*** Necessary to check, if price agreement itself not maintained
* INSERT ls_price_agreements_crm
* INTO TABLE lt_price_agreements_crm.
*
*** check for prices at item level
* CALL FUNCTION 'CMS_1O_PRICE_CHECK_ON_AWARD'
* EXPORTING
* iv_ref_guid = ls_orderadm_i-guid
* iv_ref_kind = gc_object_kind-orderadm_i
* iv_constart_date = lv_constart_date
* it_price_agreements_crm = lt_price_agreements_crm
* IMPORTING
* ev_price_error = lv_price_error
* EXCEPTIONS
* errors_occured = 1
* OTHERS = 2.
ENDLOOP.
IF lv_price_error = gc_x OR
lv_partner_error = gc_x OR
lv_date_error = gc_x.
RAISE not_allowed.
ELSE.
IF is_status_wrk-kind = gc_object_kind-orderadm_h.
CALL FUNCTION 'CMS_CASCADE_REG_ORDER'
EXPORTING
iv_guid = is_status_wrk-guid
iv_object_kind = is_status_wrk-kind
IMPORTING
ev_object_id = lv_object_id.
ENDIF.
ENDIF.
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Crm order status is an status change badi, when ever the transaction status is getting changed this badi used to trigger, basically it is an filter based,This will be implemented for the transaction status profile and the status combination.
After change - will be called after the status change is done.
Before change - will be called before the status change.there you can do your validation and raise the exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravichand,
You can use that badi to apply some business logic to check if a status is allowed or not.
Example: You have a business transaction status set to 'Resolved', and you only want allow a status change to 'Close' after three days after last status change. In status configuration you will configure 'Close' status after 'Resolved', but you'll control if it is selectable or not with this BADI.
Kind regards,
Garcia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
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.