以下为正文

最近一个开发,在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.


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

【ABAP系列】ABAP CL_ABAP_CONV_IN_CE