SAP PP BAPI_MATERIAL_SAVEDATA 保存时碰到的一个坑

 今早碰到一个奇怪的现象。

调用 BAPI_MATERIAL_SAVEDATA  批量修改物料主数据。

发现

1、批量传入单条时,是正常的,即mm03查看已经修改了。

2、传入多条时,第一条正常修改,后面的都没有成功,也没有报错。

经过调试发现 ,两个extension(ct_extensionin 和ct_extensioninX) 没有clear。

猜想机制,相同的extension 结构,不同数据,且与指定抬头物料不相同 ,也没有报错 。这个extension的增强应该没有做物料的校验 。

ls_te_mara-zyxwlz01  = ls_zsmara-zyxwlz01.  "品牌
    ls_te_mara-zyxwlz02  = ls_zsmara-zyxwlz02.  "产业
    ls_te_mara-zyxwlz03  = ls_zsmara-zyxwlz03.  "产品线
    ls_te_mara-zyxwlz04  = ls_zsmara-zyxwlz04.  "产品档次
    ls_te_mara-zyxwlz05  = ls_zsmara-zyxwlz05.  "产品系列
    ls_te_mara-zyxwlz06  = ls_zsmara-zyxwlz06.  "型号组合
    ls_te_mara-zyxwlz07  = ls_zsmara-zyxwlz07.  "旋梭种类
    ls_te_mara-zyxwlz08  = ls_zsmara-zyxwlz08.  "电控种类
    ls_te_mara-zyxwlz09  = ls_zsmara-zyxwlz09.  "物联网
    ls_te_mara-zyxwlz10  = ls_zsmara-zyxwlz10.  "业务曲线
    ls_te_mara-zyxwlz11  = ls_zsmara-zyxwlz11.  "成品营销物料组11
    ls_te_mara-zyxwlz12  = ls_zsmara-zyxwlz12.  "成品营销物料组12
    ls_te_mara-zyxwlz13  = ls_zsmara-zyxwlz13.  "成品营销物料组13
    ls_te_mara-zyxwlz14  = ls_zsmara-zyxwlz14.  "成品营销物料组14
    ls_te_mara-zyxwlz15  = ls_zsmara-zyxwlz15.  "成品营销物料组15
    ls_te_mara-zyxwlz16  = ls_zsmara-zyxwlz16.  "成品营销物料组16
    ls_te_mara-zyxwlz17  = ls_zsmara-zyxwlz17.  "成品营销物料组17
    ls_te_mara-zyxwlz18  = ls_zsmara-zyxwlz18.  "成品营销物料组18
    ls_te_mara-zyxwlz19  = ls_zsmara-zyxwlz19.  "成品营销物料组19
    ls_te_mara-zyxwlz20  = ls_zsmara-zyxwlz20.  "成品营销物料组20
    ls_te_mara-material  = ls_material.
    lv_valuepart         = ls_te_mara.
    ls_extensionin-structure  = 'BAPI_TE_MARA'.
    ls_extensionin-valuepart1 = lv_valuepart(240).
    ls_extensionin-valuepart2 = lv_valuepart+240(240).
    ls_extensionin-valuepart3 = lv_valuepart+480(240).
    ls_extensionin-valuepart4 = lv_valuepart+720(240).
    APPEND ls_extensionin TO ct_extensionin.
    ls_te_marax-material  = ls_material.
    ls_te_marax-zyxwlz01  = 'X'.
    ls_te_marax-zyxwlz02  = 'X'.
    ls_te_marax-zyxwlz03  = 'X'.
    ls_te_marax-zyxwlz04  = 'X'.
    ls_te_marax-zyxwlz05  = 'X'.
    ls_te_marax-zyxwlz06  = 'X'.
    ls_te_marax-zyxwlz07  = 'X'.
    ls_te_marax-zyxwlz08  = 'X'.
    ls_te_marax-zyxwlz09  = 'X'.
    ls_te_marax-zyxwlz10  = 'X'.
    ls_te_marax-zyxwlz11  = 'X'.
    ls_te_marax-zyxwlz12  = 'X'.
    ls_te_marax-zyxwlz13  = 'X'.
    ls_te_marax-zyxwlz14  = 'X'.
    ls_te_marax-zyxwlz15  = 'X'.
    ls_te_marax-zyxwlz16  = 'X'.
    ls_te_marax-zyxwlz17  = 'X'.
    ls_te_marax-zyxwlz18  = 'X'.
    ls_te_marax-zyxwlz19  = 'X'.
    ls_te_marax-zyxwlz20  = 'X'.
    lv_valuepartx         = ls_te_marax.
    ls_extensioninx-structure  = 'BAPI_TE_MARAX'.
    ls_extensioninx-valuepart1 = lv_valuepartx(240).
    ls_extensioninx-valuepart2 = lv_valuepartx+240(240).
    ls_extensioninx-valuepart3 = lv_valuepartx+480(240).
    ls_extensioninx-valuepart4 = lv_valuepartx+720(240).
    APPEND ls_extensioninx TO ct_extensioninx.

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        headdata     = ls_headdata
      IMPORTING
        return       = ls_return
      TABLES
        extensionin  = ct_extensionin
        extensioninx = ct_extensioninx.

你可能感兴趣的:(ABAP,SAP,PP,经验分享,其他)