ABAP更新批次分类对象中的值

2020-01-10  本文已影响0人  JayDragon

首先,根据物料、批次及工厂获取批次分类对象:

  CALL FUNCTION 'VB_BATCH_2_CLASS_OBJECT'
    EXPORTING
      I_MATNR = U_ITEM-MATNR
      I_CHARG = U_ITEM-CHARG
      I_WERKS = U_ITEM-WERKS
    IMPORTING
      E_OBJEK = L_OBJEK
      E_OBTAB = L_OBTAB
      E_KLART = L_KLART
      E_CLASS = L_CLASS.

其次获取批次特性值:

  CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
    EXPORTING
      OBJECTKEY       = L_OBJEK
      OBJECTTABLE     = L_OBTAB
      CLASSNUM        = L_CLASS
      CLASSTYPE       = L_KLART
    TABLES
      ALLOCVALUESNUM  = LT_NUM
      ALLOCVALUESCHAR = LT_CHAR
      ALLOCVALUESCURR = LT_CURR
      RETURN          = LT_RETURN.

然后,想更新已有批次特性或新增批次特性类似下面处理:

  READ TABLE LT_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
  IF SY-SUBRC <> 0.

    LT_NUMNEW = LT_NUM.
    LS_NUMNEW-CHARACT = 'Z_PO_SF'.
    LS_NUMNEW-VALUE_FROM = U_ITEM-JCBGSF.
    LS_NUMNEW-VALUE_RELATION = 1.
    APPEND LS_NUMNEW TO LT_NUMNEW.

    LT_CHARNEW = LT_CHAR.
    LT_CURRNEW = LT_CURR.
  ENDIF.

最后,再调用BAPI进行更新:

  CALL FUNCTION 'BAPI_OBJCL_CHANGE'
    EXPORTING
      OBJECTKEY          = L_OBJEK
      OBJECTTABLE        = L_OBTAB
      CLASSNUM           = L_CLASS
      CLASSTYPE          = L_KLART
    TABLES
      ALLOCVALUESNUMNEW  = LT_NUMNEW
      ALLOCVALUESCHARNEW = LT_CHARNEW
      ALLOCVALUESCURRNEW = LT_CURRNEW
      RETURN             = LT_RETURN.

PS:查看物料是否维护批次分类对象

  SELECT SINGLE * INTO LS_INOB
      FROM INOB
      WHERE KLART = '023' "物料批次分类
        AND OBTAB = 'MARA' 
        AND OBJEK = U_ITEM-MATNR.
  IF SY-SUBRC <> 0.
    MESSAGE E047(ZNHZH) WITH U_ITEM-MATNR.
  ENDIF.
上一篇 下一篇

猜你喜欢

热点阅读