SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BADI to change a Purchase Order - Post-processing to ME21N

Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message

Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Sep 08, 2007 7:17 pm    Post subject: BADI to change a Purchase Order - Post-processing to ME21N Reply with quote

Populate EVERS [ Shipping Point ] at the time of purchase order ceration. Shipping point should be derivated from the shipping point on sales order [ if PO created from in reference to a sales order ].

This is an example to show - how to achieve post-processing [ follow-on processing ] functionality using BADIs [ Business Add-inn ] or user-exits.

Find the relevant BADI using transaction SE18. In this case BADI ME_PURCHDOC_POSTED is used.
Further, implement the BADI using transaction SE19.
In Attributes section of BADI, define a STATIC attribute as PO_NUMBER. Static means the attribute will keep its value between the calls. This will be checked to ensure that same PO will not be processed twice. Also these kind of user-exits and BADIs might get called recursively and get caught into an infinite loop, if not coded properly. Rememeber that this BADI is at the time of PO save and then you are again trying to change & save the Purchase Order from within the BADI.
BAPI to change Purchase Order 'BAPI_PO_CHANGE' will be called IN BACKGROUND TASK to ensure that it will be called when COMMIT WORK is encountered.
Don't forget to activate the BADI implementation in SE19.

Sample ABAP Code:


DATA: wa_ekpo like line of IM_EKPO,
      lt_po_item type standard table of BAPIMEPOITEM,
      lt_po_itemx type standard table of BAPIMEPOITEMX,
      wa_po_item type BAPIMEPOITEM,
      wa_po_itemx type BAPIMEPOITEMX,
      lt_return type standard table of BAPIRET2.

*data: ls_ebeln type BAPIMEPOHEADER-PO_NUMBER.

check im_ekko-ebeln ne PO_NUMBER.

PO_NUMBER = im_ekko-ebeln.

LOOP AT IM_EKPO into wa_ekpo.

  wa_po_item-PO_ITEM = wa_ekpo-ebelp.
* EVERS to be derived
  wa_po_item-SHIPPING = 'C'.
  APPEND wa_po_item to lt_po_item .

  wa_po_itemx-PO_ITEM = wa_ekpo-ebelp.
  wa_po_itemx-SHIPPING = 'X'.
  APPEND wa_po_itemx to lt_po_itemx.

     purchaseorder                = PO_NUMBER
*    POHEADER                     =
*    POHEADERX                    =
*    POADDRVENDOR                 =
*    TESTRUN                      =
*    MEMORY_UNCOMPLETE            =
*    MEMORY_COMPLETE              =
*    POEXPIMPHEADER               =
*    POEXPIMPHEADERX              =
*    VERSIONS                     =
    NO_MESSAGING                 = 'X'
    NO_MESSAGE_REQ               = 'X'
    NO_AUTHORITY                 = 'X'
    NO_PRICE_FROM_PO             = 'X'
*    EXPHEADER                    =
*    EXPPOEXPIMPHEADER            =
     RETURN                       = lt_return
     POITEM                       = lt_po_item
     POITEMX                      = lt_po_itemx
*    POADDRDELIVERY               =
*    POSCHEDULE                   =
*    POSCHEDULEX                  =
*    POACCOUNT                    =
*    POACCOUNTX                   =
*    POCONDHEADER                 =
*    POCONDHEADERX                =
*    POCOND                       =
*    POCONDX                      =
*    POLIMITS                     =
*    POCONTRACTLIMITS             =
*    POSERVICES                   =
*    POSRVACCESSVALUES            =
*    POSERVICESTEXT               =
*    EXTENSIONIN                  =
*    EXTENSIONOUT                 =
*    POEXPIMPITEM                 =
*    POEXPIMPITEMX                =
*    POTEXTHEADER                 =
*    POTEXTITEM                   =
*    ALLVERSIONS                  =
*    POPARTNER                    =
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.