[Badi] How to Use Badi to modify Po (processing to me21n) (from Jack Wu)

Source: Internet
Author: User

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 shocould 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.

    • 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 CILS. 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.

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.