Supply Chain Management Blogs by SAP
Expand your SAP SCM knowledge and stay informed about supply chain management technology and solutions with blog posts by SAP. Follow and stay connected.
cancel
Showing results for 
Search instead for 
Did you mean: 
Berthold_vH
Product and Topic Expert
Product and Topic Expert
0 Kudos

A user wants to send an Event Message. In your process you have e.g. defined that this message can just be processed if another message was sent earlier. Within a preprocess function it is possible to prevent the processing of the Event Message. But without the additional coding you would get an error page on the web screen like that.

With some additional coding an error message is returned which can even tell the user what is the problem.To give back this message you have to add this additional coding to a preprocess function. Here is an example how to do this:

DATA: lt_return         TYPE STANDARD TABLE OF bapiret2,
        ls_return         LIKE bapiret2,
        ls_msg            TYPE bal_s_msg,
        lr_log            TYPE REF TO /saptrx/cl_eh_app_log,
        lv_ext_num        TYPE balnrext,
        lv_numlines.
* own coding to check different things like authoristation
* In case an error occur don't send an Event Message
* enter a message class
  ls_return-type   = 'E'.
  ls_return-id     = 'Z_EM_MESSAGE'.  "example create your own
  ls_return-number = '004'.
  MESSAGE ID     ls_return-id
          TYPE   ls_return-type
          NUMBER ls_return-number
          INTO   ls_return-message.
  APPEND ls_return TO lt_return.
* create entry in log (if you want)
  DESCRIBE TABLE lt_return LINES lv_numlines.
  IF lv_numlines > 0 .
    lr_log = /saptrx/cl_eh_app_log=>create_evm_log(
                             i_extnumber = lv_ext_num ) .
* log messages
    LOOP AT lt_return INTO ls_return.
      CLEAR ls_msg.
      ls_msg-msgid = ls_return-id .
      ls_msg-msgty = ls_return-type.
      ls_msg-msgno = ls_return-number.
      lr_log->add_message(
            i_msgty = ls_msg-msgty
            i_msgno = ls_msg-msgno
            i_msgid = ls_msg-msgid ).
    ENDLOOP.
    CALL METHOD lr_log->save_log.
    APPEND LINES OF lt_return TO et_return.
  ENDIF.
* set to fatal error => another log entry is created outside
  ev_fatal_error = 'X'.
* delete the message (if more than one message is send on the same time
* delete with Event Message Guid)
CLEAR es_evm_tables.

So with this additonal coding you can give the user detailed information why this Event Message is not processed in SAP EM system.