【ABAP系列】SAP ABAP BAPI_REQUISITION_CREATE创建采购申请

人盡茶涼 提交于 2019-12-05 19:21:32
公众号:SAP Technical
本文作者:matinal
 

 

前言部分

大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。

正文部分

最近一个开发,在eban里追加了字段,

调用bapi赋值总是赋不进去

后来发现找的结构名称不对,

是:BAPI_TE_REQUISITION_ITEM 不是BAPI_TE_MEREQITEM

实例代码如下:

REPORT zlm_pr_create.

DATA: pr_item LIKE TABLE OF bapiebanc WITH HEADER LINE,
pr_account LIKE TABLE OF bapiebkn WITH HEADER LINE,
pr_item_id LIKE TABLE OF bapiebantx WITH HEADER LINE,
pr_return LIKE TABLE OF bapireturn WITH HEADER LINE.
DATA: l_return LIKE pr_return.
DATA: extensionin TYPE TABLE OF bapiparex WITH HEADER LINE .
DATA: lw_itm TYPE bapi_te_requisition_item.
DATA: matnr TYPE matnr.
DATA: pr_no TYPE bapiebanc-preq_no.

START-OF-SELECTION.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = '500000004'
IMPORTING
output = matnr.

pr_item-doc_type = 'NB'. "凭证类型
pr_item-preq_item = '00010'. "项目
pr_item-material = matnr. "商品代码
pr_item-quantity = 1. "数量
pr_item-deliv_date = '20130819'. "交货日期
pr_item-plant = 'BA01'. "工厂
pr_item-pur_group = 'B02'. "采购组
pr_item-c_amt_bapi = 100. "评估价格

APPEND pr_item.
CLEAR pr_item.

 

lw_itm-csid = '991'.
lw_itm-preq_item = '00010'.
extensionin-structure = 'BAPI_TE_REQUISITION_ITEM'.
extensionin-valuepart1 = lw_itm.

APPEND extensionin.

CALL FUNCTION 'BAPI_REQUISITION_CREATE'
IMPORTING
number = pr_no
TABLES
requisition_items = pr_item
requisition_account_assignment = pr_account
requisition_item_text = pr_item_id
return = pr_return
extensionin = extensionin[].

LOOP AT pr_return WHERE type = 'E' OR type = 'A'.
ENDLOOP.

FREE pr_item.
FREE pr_account.
FREE pr_item_id.
FREE pr_return.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!