如何使用BADI修改PO

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用BADI修改PO相关的知识,希望对你有一定的参考价值。

参考技术A 您好,很高兴能帮助您
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.
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.

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 =
.
你的采纳是我前进的动力,
记得好评和采纳,答题不易,互相帮助,

abap bapi badi 有啥区别?怎样查找?怎样使用? 标准程序自建增强点怎么做?

BAPI 是函数,你可以输入T-code:BAPI,查找系统里的bapi函数。比如采购申请的审批的勾打上,就可以调用bapi函数来实现。
BADI 是abap的一种增强,他的调用方式是CALL METHOD (instance),(相关的TCODE是SE18和SE19),你可以通过EXIT_HANDLER这个单词查找BADI。
创建增强有多种方法,用CMOD可以创建,用spro也可以创建。也正在学习中。

网上有这段:
针对BADI的增强

1、badi对象的信息存储在SXS_INTER, SXC_EXIT, SXC_CLASS 和SXC_ATTR 这四个表中。

2、sap程序都会调用cl_exithandler=>get_instance来判断对象是否存在,并返回实例;其实get_instance就是对上述几个表和他们的视图(V_EXT_IMP 和 V_EXT_ACT)进行查询和搜索。

3、基于这个机理,我查用ST05来监控一个TCODE来跟踪,然后选择查找有关上述几个表和视图的操作,就可获得相关BADI。

4、se18 查找接口,se19 实现接口就可以实现用户增强。
参考技术A ABAP 是SAP的底层编程语言,BAPI是ABAP中的批输入函数,BADI是增强,SE19创建。 参考技术B 回答的不错

以上是关于如何使用BADI修改PO的主要内容,如果未能解决你的问题,请参考以下文章

SAP模块常用增强总结{转载}

20170520 BADI增强学习

SAP中我用BADI增强XD01一个字段,但不能更新数据,请教应如何才能更新数据?

abap bapi badi 有啥区别?怎样查找?怎样使用? 标准程序自建增强点怎么做?

如何使用 poedit 从 js 文件生成 po 文件

如何使用 .po 文件翻译帖子或页面的 Wordpress 内容[关闭]