我发现了两个函数,BAPI_PO_CREATE和BAPI_PO_CREATE1。由于CREATE1的修改日期较新,因此我认为这将是最好的修改日期。作为一个例子,我正在创建一个没有材料的相当简单的购买。
call function 'BAPI_PO_CREATE1'
exporting
poheader = po_header
poheaderx = po_header_x
testrun = abap_false
tables
return = returning
poitem = po_items
poitemx = po_items_x
poaccount = po_accounts
poaccountx = po_accounts_x
poschedule = po_schedule
poschedulex = po_schedule_x.因此,我使用G/L帐户和WBS元素作为成本对象:
append initial line to po_accounts assigning field-symbol(<po_account>).
<po_account>-po_item = current_position.
" Classes that call CONVERSION_EXIT
<po_account>-gl_account = /dim/cl_bonadm_exit=>int_saknr( <item>-gl_account ).
<po_account>-wbs_element = /dim/cl_bonadm_exit=>int_posnr( <item>-wbs_id ).
append initial line to po_accounts_x assigning field-symbol(<po_account_x>).
<po_account_x>-po_item = current_position.
<po_account_x>-po_itemx = abap_true.
<po_account_x>-gl_account = abap_true.
<po_account_x>-wbs_element = abap_true.但是,I仍然收到以下错误消息:
No instance of object type PurchaseOrder has been created. External reference:
Purchase order item 00010 still contains faulty account assignments
Can delivery date be met?
Account 475000 requires an assignment to a CO object情况不应该是这样的,当我在ME21n中填写相同的数据时,我仍然会收到交货日期警告,但不会收到采购订单项目上的错误。我遇到了两个不同的SAP注释,但它们都不能实现。同样,即使我从帐户中删除了WBS元素,我仍然收到错误消息。
我还尝试在BAPI结构的CO-object字段中填充WBS元素,但没有任何效果。我可以在BAPI中跟踪它抛出此错误消息的位置,但我找不到它发生的原因。
完整方法:http://hastebin.com/ufarisozav.xml
发布于 2016-11-02 17:07:51
您还需要填充表poaccountx (如函数模块的文档中所示),否则系统可能会忽略插入到poaccount表中的部分或全部数据。
https://stackoverflow.com/questions/40375493
复制相似问题