要将增强字段一并append到如下四个表/结构中:
如果增强字段在销售订单抬头(vbak)上
- VBAKKOZ
- VBAKKOZX
- BAPE_VBAK
- BAPE_VBAKX
在行项目(vbap)上:
- VBAPKOZ
- VBAPKOZX
- BAPE_VBAP
- BAPE_VBAPX
在运货计划行(VBEP)上:
- VBEPKOZ
- BEPKOZX
- BAPE_VBEP
- BAPE_VBEPX
11-08今天做了一个测试,实际操作了一下append进去ABAP中,然后通过BAPI去修改字段
TABLE VBAP
vbap append构造STR BVPE_VBAP
BVPE_VBAP append构造STR BVPE_VBAPX
BVPE_VBAPX append构造STR VBAPKOZ
VBAPKOZ append构造STR VBAPKOZX
VBAPKOZX append构造代码如下
DATA:
LV_SALESDOCUMENT TYPE BAPIVBELN-VBELN,
LW_ORDER_HEADER_IN TYPE BAPISDH1,
LW_ORDER_HEADER_INX TYPE BAPISDH1X,
LIT_ORDER_ITEM_IN TYPE STANDARD TABLE OF BAPISDITM,
LW_ORDER_ITEM_IN TYPE BAPISDITM,
LIT_ORDER_ITEM_INX TYPE STANDARD TABLE OF BAPISDITMX,
LW_ORDER_ITEM_INX TYPE BAPISDITMX,
LIT_EXTENSIONIN TYPE STANDARD TABLE OF BAPIPAREX,
LW_EXTENSIONIN TYPE BAPIPAREX,
LW_BAPE_VBAP TYPE BAPE_VBAP, "BAPI インタフェース: テーブル VBAP 拡張
LW_BAPE_VBAPX TYPE BAPE_VBAPX, "BAPI チェックボックス: テーブル VBAP 拡張
LIT_RETURN TYPE STANDARD TABLE OF BAPIRET2.
************** SO ORDER*********************
LV_SALESDOCUMENT = LV_VBELN.
************** HEADER *********************
*LW_ORDER_HEADER_IN-DOC_DATE = '20191106'.
************** HEADERX ********************
LW_ORDER_HEADER_INX-UPDATEFLAG = 'U'.
*LW_ORDER_HEADER_INX-DOC_DATE = ABAP_TRUE.
************** ITEM_IN *********************
LW_ORDER_ITEM_IN-ITM_NUMBER = LV_POSNR.
LW_ORDER_ITEM_IN-TARGET_QTY = '2'.
LW_ORDER_ITEM_IN-PYMT_METH = '3'.
APPEND LW_ORDER_ITEM_IN TO LIT_ORDER_ITEM_IN.
************** ITEM_INX ********************
LW_ORDER_ITEM_INX-ITM_NUMBER = LV_POSNR.
LW_ORDER_ITEM_INX-UPDATEFLAG = 'U'.
LW_ORDER_ITEM_INX-TARGET_QTY = ABAP_TRUE.
LW_ORDER_ITEM_INX-PYMT_METH = ABAP_TRUE.
APPEND LW_ORDER_ITEM_INX TO LIT_ORDER_ITEM_INX.
LW_BAPE_VBAP-VBELN = LV_VBELN.
LW_BAPE_VBAP-POSNR = LV_POSNR.
LW_BAPE_VBAP-ZNNZZ = '123456'.
LW_BAPE_VBAP-ZNSZZ = 'ZNSZZ'.
LW_BAPE_VBAP-ZORZZ = '001'.
LW_BAPE_VBAPX-VBELN = LV_VBELN.
LW_BAPE_VBAPX-POSNR = LV_POSNR.
LW_BAPE_VBAPX-ZNNZZ = ABAP_TRUE.
LW_BAPE_VBAPX-ZNSZZ = ABAP_TRUE.
LW_BAPE_VBAPX-ZORZZ = ABAP_TRUE.
*LW_BAPE_VBAPX-FSH_SEASON_YEAR = ABAP_TRUE.
CALL METHOD CL_EEWA_CONVERT=>CONVERT_BAPIPAREX_IN
EXPORTING
PAR_STRUCTNAME = 'BAPE_VBAP'
PAR_DATA = LW_BAPE_VBAP
CHANGING
PAR_BAPIPAREXTAB = LIT_EXTENSIONIN.
CALL METHOD CL_EEWA_CONVERT=>CONVERT_BAPIPAREX_IN
EXPORTING
PAR_STRUCTNAME = 'BAPE_VBAPX'
PAR_DATA = LW_BAPE_VBAPX
CHANGING
PAR_BAPIPAREXTAB = LIT_EXTENSIONIN.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = LV_SALESDOCUMENT
ORDER_HEADER_IN = LW_ORDER_HEADER_IN
ORDER_HEADER_INX = LW_ORDER_HEADER_INX
TABLES
RETURN = LIT_RETURN
ORDER_ITEM_IN = LIT_ORDER_ITEM_IN
ORDER_ITEM_INX = LIT_ORDER_ITEM_INX
EXTENSIONIN = LIT_EXTENSIONIN.
LOOP AT LIT_RETURN ASSIGNING FIELD-SYMBOL(<LW_RETURN>).
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
image.png这次还遇到了一个非常有意思的问题。刚开始没办法修改成功(return的东message都是成功),最后通过查找资料发现,构造VBAPKOZX的类型必须使用char1去定义,如果和其他一样用char,长度1,没法识别。
https://answers.sap.com/questions/1691488/bapisalesorderchange-extensionin-not-working.html
网友评论