Skip to Content

Enhancement at PO creation

Nov 24, 2016 at 04:34 PM


avatar image
Former Member

Hello gurus,

I'm currently working at Purchase Order creation. I need to trigger a small ABAP code when a Purchase order is created (ME21N) or modified (ME22N).

I currently do this in EXIT_SAPMM06E_13 in enhencement MM06E005 but this trigger my code before the PO is created in the system. And so when I launch BAPI_PO_GETDETAIL1, it retrieves no data.

I would like to set my code just after PO data are set in SAP tables so that I can retrieve data from the PO.

To sum-up, my requirement should be an equivalent of USEREXIT_REFRESH_DOCUMENT (launched at Sales order creation) but on the Purchase Order. Does anyone know if it exists ?

Thank you !

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Raymond Giuseppi
Nov 25, 2016 at 06:58 AM

Schedule your code in ME_PROCESS_PO_CUST->IF_EX_ME_PROCESS_PO_CUST~POST, wrap your code in a RFC enabled FM and call it in background task so will be executed after end of update tasks.

Also you have already access to the whole data of the PO in this method (thru some call of get_items/get_data methods) so no need to use some read data BAPI...

* Sample
method if_ex_me_process_po_cust~post .
  data: lt_items type purchase_order_items,
        ls_items type purchase_order_item,
        ls_item type mepoitem,
        ls_item_old type mepoitem.
  " always on PO number
  call function 'Z_XXXXX1' in update task
      i_ebeln = im_ebeln.
  lt_items = im_header->get_items( ).
  loop at lt_items into ls_items.
    ls_items-item->get_data( receiving re_data = ls_item ).
    ls_items-item->get_persistent_data( importing ex_data = ls_item_old exceptions no_data = 1 others  = 2 ).
    " new/changed lines
    if sy-subrc ne 0 or ls_item ne ls_item_old.
      call function 'Z_XXXXX2' in background task
        destination 'YYYYY'
          i_ebeln = ls_item-ebeln
          i_ebelp = ls_item-ebelp.
endmethod.                    "IF_EX_ME_PROCESS_PO_CUST~POST


Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Raymond,

Thank you for your response !

I have tried to set a break point in the Post method (IF_EX_ME_PROCESS_PO_CUST~POST). But the breakpoint is not reached when I try to save my PO (at creation or modification)...

So nothing will happen if I put my code here.

Can you explain my when this code will be launched or If I have to do something for this code to be launched ? (The method is well active).

Thank you,



If the BAdI is not implemented, it's not triggered and the break point cannot be reached.


It's my fault, I didn't write the word 'BAdI' in my answer...

Vinita Kasliwal Nov 24, 2016 at 09:23 PM

Hi Adrein


and for User exit it will be a bit if hit and trial for you depending on what field value you are trying to change

EXIT_SAPMM06E_004 part of MM06E004

EXIT_SAPMM06E_006 , 007 or 008

But go to SMOD and see the description which will help you select the one you are looking for .

The thread below had the SMOD list pasted

Let me know if that helps



10 |10000 characters needed characters left characters exceeded
Rob Dielemans Nov 25, 2016 at 09:30 AM


Are you using workflow in the release strategy? With this you can easily control if things need to be executed after a create or a change.

Kind regards, Rob Dielemans

10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 05, 2016 at 11:27 AM

Hello all and thank you for your responses,

I have found a way to do what I wanted to do.

In "EXIT_SAPMM06E_013", I launch a parallel task with "STARTING NEW TASK". In this task I test the completeness of the data in the EKKO table. While, in this parallel task, the test on the table return an error (it means the table is not completed for the PO at stake), we wait.

Like this, the process of the creation of the entry in the table is done BEFORE we try to retrieve the data.

Thank you !

10 |10000 characters needed characters left characters exceeded