Skip to Content

In standard SAP EM the design tries to play it safe and forces serialization of all postings belonging to one BPT.

What if you want to have several queues process for one BPT and maintain integrity of the solution? You need to make sure that all documents that relate to your EH resolve to the same queue name. E.g.. If you choose the sales order number as your queue name and the delivery is also part of the process included in your sales order EH then I would have the delivery also go in to the sales order queue.

How do you accomplish queuing?
By copying the standard BAdI implementation to your own implementation (e.g.. class /SAPTRX/CL_IM_MM_PURCHORD, method IF_EX_ME_PURCHDOC_POSTED~POSTED) you may (for example) decide to rely only on serialization of data belonging to the last digit of the document number. In our example we choose to have 5 queues in parallel.

In this implementation you would NOT provide the EM application interface with the default queue name (‘EM_DEFAULT_QUEUE’), but with a generic queue name based on the document number (e.g.’Z_ORDER_A’).
You have to make sure though, that there are no dependencies of document changes of different document numbers, if you want to go this way.

An example of the code:
*** CHANGE QUEUE NAME FOR OUTBOUND COMMUNICATION TO EVENT MANAGER ***
  v_last_digit = ebeln+9(1).

  case v_last_digit.
    when 1 or 2.
      concatenate ‘Z_ORDER’ ‘A’ into v_queue.
    when 3 or 4.
      concatenate ‘Z_ORDER’ ‘B’ into v_queue.
    when 5 or 6.
      concatenate ‘Z_ORDER’ ‘C’ into v_queue.
    when 7 or 8.
      concatenate ‘Z_ORDER’ ‘D’ into v_queue.
    when 9 or 0.
      concatenate ‘Z_ORDER’ ‘E’ into v_queue.
  endcase.

  condense v_queue.

  call function ‘TRFC_SET_QUEUE_NAME’
    exporting
      qname                    = v_queue
   exceptions
     invalid_queue_name       = 1
     others                   = 2 .

If you are using parallel queues with calling a BAPI to add an event then use this code:
* Get tracking servers
  select * from /saptrx/trxserv into table lt_trxserv.
  if sy-subrc <> 0.
    message w021(/saptrx/asc).
  endif.

  loop at lt_trxserv into lw_trxserv.

    if not lt_bapi_evm_header[] is initial.

      call function ‘/SAPTRX/BAPI_EH_ADDEVENTMSG_02’
        in background task
        destination lw_trxserv-rfcdest
        exporting
          simulate           = space
          synchronous        = space
          eh_generation_mode = ‘N’
        tables
          trackingheader     = lt_bapi_evm_header
          return             = lt_bapireturn.

* Set queue for the Commit as well
      call function ‘TRFC_SET_QUEUE_NAME’
        exporting
          qname                    = v_queue
       exceptions
         invalid_queue_name       = 1
         others                   = 2 .

      if sy-subrc <> 0.
    Message i999(b1) with ‘Failed to change queue name!’.
      endif.

      call function ‘BAPI_TRANSACTION_COMMIT’
        in background task
        destination lw_trxserv-rfcdest.
    endif.

    refresh lt_bapi_evm_header.
    refresh lt_bapireturn.

  endloop.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply