cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent status change when the Order has an error

Former Member
0 Kudos

Hi Experts,

If the CRM ORDER has an error in the document, the drop down box for CRM has status COMPLETED. I want to prevent Completed Status until all the error has been cleared from the document. Currently this is happening for status Released. How can I implement the same for status COMPLETED. Please suggest a way to do this?

Thanks

Mani.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Experts,

Thanks for all your support. This has been resolved by using the FM CRM_MESSAGES_CHECK_FOR_ERRORS which catches the errors at runtime and use this FM in BADI CRM_ORDER_STATUS method IF_EX_CRM_ORDER_STATUS~BEFORE_CHANGE. The below code resoklved the issue.

CALL FUNCTION 'CRM_MESSAGES_CHECK_FOR_ERRORS'

EXPORTING

iv_ref_object = is_status_wrk-guid

iv_ref_kind = 'A'

  • IV_CALLER_NAME =

EXCEPTIONS

ERRORS_EXIST = 1

OTHERS = 2.

IF sy-subrc ne 0.

RAISE not_allowed.

ENDIF.

Thanks

Mani.

rb
Active Participant
0 Kudos

I think also, that the Badi is the right way to do it. You can use the function CRM_MESSAGES_CHECK_HEADER_ERR to check for Erros.

Former Member
0 Kudos

Ramakanth,

Thanks for the sugestion . I tried the BADI and it works fine only after saving. For example, if the order has an error, the COMPLETED status is not visible. So when I clear the error and moving to status tab immediately before saving, still the COMPLETED status is not visible. this is logically not good. But after I save the dcoument and coming to status tab, the COMPLETED status exist. I need some FM whcih reads the error at runtime and so I can prevent the status.

Please suggest.

Thanks

Mani.

Former Member
0 Kudos

You can use the BADI CRM_ORDER_STATUS, this is a filter dependent, please use the Completed status code to trigger this.

In the method BEFORE_CHANGE of the BADI you check if the transaction has any errors if yes then raise the exception NOT_ALLOWED. The status completed will not be set until there are no errors.

Regards,

Ramakanth

Former Member
0 Kudos

Hi,

You can control this using CALL BACK events i.e., TCODE CRMV_EVENT. Here you need to create a Function Module and configure so that it triggers before status change.

There is a Blog in the CRM area on this functionality in SDN. Please search for it.

Regards,

Masood Imrani S.