cancel
Showing results for 
Search instead for 
Did you mean: 

How to put custom message before raise of the exception in the method.??

former_member182350
Active Contributor
0 Kudos

Hi Experts,

I am working on the checking the <b>lead duplicacy by implementing of the BADI: Order_save / check_before_save</b> method which has the exception<b> 'DO_NOT_SAVE'</b>.

My reqiurement is that <b>how to put/ collect an error message in the transaction error log or just throw the mesage (custom) before raising the exception</b>??

Can any body helps in this regard?? how and what r the FM/ ways to do this??

Thanks and Regards,,

Arjun,,,,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Arjun

For collecting the message in the error log you can make use of CRM_MESSAGE_COLLECT .

Regards

Ranjit

Answers (1)

Answers (1)

Former Member
0 Kudos

this may be of your help

here in this code i m using order_save badi FM CHECK_BEFORE_SAVE

if the opportunity has errors it should not let the user save it. see the code below also i think sending custome messages is not recommended in Bus txs.

DATA INFO_MSG TYPE CRMT_MSG_INFO_TAB.

CALL FUNCTION 'CRM_MESSAGES_SEARCH'

EXPORTING

  • IT_R_MSGID =

  • IT_R_MSGIDNO =

IV_REF_OBJECT = IV_GUID

  • IV_REF_KIND =

  • IV_CALLER_NAME =

  • IT_LOGICAL_KEYS =

  • IV_PROBCLASS =

  • IV_DETLEVEL =

  • IV_LOG_HANDLE =

  • IV_DOCNUMBER =

  • IV_FRAME_LOG = FALSE

  • IV_ONLY_ACTUAL_LEVEL = FALSE

  • IV_ONLY_ERRORS_ON_OBJECT = FALSE

  • IT_MSGH =

IMPORTING

  • ET_MSG_HANDLE =

ET_MSG_INFO = INFO_MSG

  • EXCEPTIONS

  • APPL_LOG_ERROR = 1

  • ERROR_OCCURRED = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF NOT INFO_MSG IS INITIAL.

CV_OWN_MESSAGE = 'X'.

sy-msgid = 'CRM_OPPORT_H'.

SY-MSGNO = '027'.

RAISE DO_NOT_SAVE.

endif.