Skip to Content
avatar image
Former Member

Enhancement at PO creation

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 !

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • 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


    Add comment
    10|10000 characters needed characters exceeded

  • Nov 24, 2016 at 09:23 PM

    Hi Adrein

    Can you try via BADI ME_PROCESS_PO_CUST

    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



    Add comment
    10|10000 characters needed characters exceeded

  • 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

    Add comment
    10|10000 characters needed 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 !

    Add comment
    10|10000 characters needed characters exceeded