此博客为原创博客,都是个人工作经历所得,转载请注明出处

使用BAPI_MATERIAL_SAVEDATA无法写入扩展字段

 

1.目的: 导入MARC增强字段 ZZJYFS, ZZBLBM, ZZBLTXT

 

 

 

 

 



 

 

 2. BAPI结构已经加上了增强字段

 

 

 

 

 

 3. 程序代码

    IF bapi_te_marc IS NOT INITIAL.
      bapi_te_marc-plant  = plantdata-plant.
      bapi_te_marcx-plant = plantdata-plant.
      CLEAR: extensionin, lv_marc_value.
      lv_marc_value  = bapi_te_marc.
      extensionin-structure  = 'BAPI_TE_MARC'.
      extensionin-valuepart1 = lv_marc_value(240).
      extensionin-valuepart2 = lv_marc_value+240(240).
      extensionin-valuepart3 = lv_marc_value+480(240).
      extensionin-valuepart4 = lv_marc_value+720(240).
      APPEND extensionin.

      CLEAR: extensioninx, lv_marc_valuex.
      lv_marc_valuex = bapi_te_marcx.
      extensioninx-structure  = 'BAPI_TE_MARCX'.
      extensioninx-valuepart1 = lv_marc_valuex(240).
      extensioninx-valuepart2 = lv_marc_valuex+240(240).
      extensioninx-valuepart3 = lv_marc_valuex+480(240).
      extensioninx-valuepart4 = lv_marc_valuex+720(240).
      APPEND extensioninx.
    ENDIF.

***************"执行bapi*************************
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        headdata             = headdata
        clientdata           = clientdata
        clientdatax          = clientdatax
        plantdata            = plantdata
        plantdatax           = plantdatax
        forecastparameters   = forecastparameters
        forecastparametersx  = forecastparametersx
        planningdata         = planningdata
        planningdatax        = planningdatax
        storagelocationdata  = storagelocationdata
        storagelocationdatax = storagelocationdatax
        valuationdata        = valuationdata
        valuationdatax       = valuationdatax
        warehousenumberdata  = warehousenumberdata
        warehousenumberdatax = warehousenumberdatax
        salesdata            = salesdata
        salesdatax           = salesdatax
        storagetypedata      = storagetypedata
        storagetypedatax     = storagetypedatax
        flag_online          = ' '
        flag_cad_call        = ' '
        no_dequeue           = ' '
        no_rollback_work     = ' '
      IMPORTING
        return               = return
      TABLES
        materialdescription  = materialdescription
        unitsofmeasure       = unitsofmeasure
        unitsofmeasurex      = unitsofmeasurex
        internationalartnos  = internationalartnos
        materiallongtext     = materiallongtext
        taxclassifications   = taxclassifications
        returnmessages       = returnmessages
        prtdata              = prtdata
        prtdatax             = prtdatax
        extensionin          = extensionin
        extensioninx         = extensioninx.
    IF return-type = 'S' AND gv_test IS INITIAL."执行成功
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "提交该BAPI
        EXPORTING
          wait = 'X'.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    ENDIF.

导入数据:

 

 值已经写到扩展结构:

 

 

 

 

 

BAPI执行结果,不会去更新扩展字段值

 

 

 

 

posted @ 2021-06-22 12:37  Rainystuday  阅读(146)  评论(0编辑  收藏  举报