其他分享
首页 > 其他分享> > SAP BAPI_MATERIAL_SAVEDATA保存自定义字段(包括保存自定义字段失败的解决方法)

SAP BAPI_MATERIAL_SAVEDATA保存自定义字段(包括保存自定义字段失败的解决方法)

作者:互联网

Step1. 增强MARA表

1

Step2. 增强结构BAPI_TE_MARA BAPI_TE_MARAX

2
3

Step3. 事务代码:OMSR 指派屏幕字段

4
5

Step4. BAPI_MATERIAL_SAVEDATA调用

DATA:
LS_HEADER  TYPE BAPIMATHEAD,
LS_PLANT   TYPE BAPI_MARC,
LS_PLANTX  TYPE BAPI_MARCX,
LS_MESSAGE TYPE BAPIRET2.

DATA: ls_bapi_te_mara  TYPE bapi_te_mara,
    ls_bapi_te_marax TYPE bapi_te_marax.

DATA: lt_extensionin  TYPE TABLE OF  bapiparex WITH HEADER LINE,
    lt_extensioninx TYPE TABLE OF  bapiparexx WITH HEADER LINE.

*   MARA
LS_HEADER-MATERIAL      = GS_RB06-MATNR.         "物料号
LS_HEADER-MATERIAL_LONG = GS_RB06-MATNR.
ls_header-basic_view = 'X'.                      "增强字段在哪个视图的主数据表,必须设置View更新标准;否则extension字段不更新          

*   MARC
LS_PLANT-PLANT       = '1100'.                   "工厂
LS_PLANTX-PLANT      = '1100'.                   "工厂
LS_PLANT-QM_AUTHGRP  = GS_RB06-QMATA.
LS_PLANTX-QM_AUTHGRP = 'X'.

"结构赋值,可不用位置偏移(SY-DAUTM+0(4))
ls_bapi_te_mara-material = gs_rb06-matnr.
ls_bapi_te_mara-zupid    = '00000001'

ls_bapi_te_marax-material = gs_rb06-matnr.
ls_bapi_te_marax-zupid = 'X'.

"将结构值append到extension表
lt_extensionin-STRUCTURE = 'BAPI_TE_MARA'.
lt_extensionin-valuepart1 = ls_bapi_te_mara.
APPEND lt_extensionin.
lt_extensioninx-STRUCTURE = 'BAPI_TE_MARAX'.
lt_extensioninx-valuepart1 = ls_bapi_te_marax.
APPEND lt_extensioninx.



*   物料导入
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    HEADDATA   = LS_HEADER
    PLANTDATA  = LS_PLANT
    PLANTDATAX = LS_PLANTX
  IMPORTING
    RETURN     = LS_MESSAGE
TABLES
  extensionin        = lt_extensionin[]
  extensioninx       = lt_extensioninx[].

标签:bapi,自定义,BAPI,保存,lt,LS,te,ls
来源: https://blog.csdn.net/qq_30797051/article/details/122244646