http://blog.csdn.net/CompassButton/archive/2006/10/21/1344686.aspx
Requirement:
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 ].
Processing:
This is an example to show - how to achieve post-processing [ follow-on processing ] functionality using BADIs [ Business Add-inn ] or user-exits.
method IF_EX_ME_PURCHDOC_POSTED~POSTED .
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.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CHANGE' IN BACKGROUND TASK
EXPORTING
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'
* IMPORTING
* EXPHEADER =
* EXPPOEXPIMPHEADER =
TABLES
RETURN = lt_return
POITEM = lt_po_item
POITEMX = lt_po_itemx
* POADDRDELIVERY =
* POSCHEDULE =
* POSCHEDULEX =
* POACCOUNT =
* POACCOUNTPROFITSEGMENT =
* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
.
endmethod.