Skip to Content
0
Former Member
Jul 14, 2008 at 03:39 PM

BAPI to update batch characteristics

2026 Views

Hi,

We have a requirement to update batch characteristics in SAP. I used the VB_BATCH_CHANGE to update the batch characteristics. Below is my code. After the call, I don't get any error from this BAPI/RFC, but batch chararacteristcis values are not updated. Any ideas?

FUNCTION Z_VB_CHANGE_BATCH.
*"----------------------------------------------------------------------
*"*"Global Interface:
*"  IMPORTING
*"     VALUE(YMCHA) LIKE  MCHA STRUCTURE  MCHA
*"     VALUE(YUPDMCHA) LIKE  UPDMCHA STRUCTURE  UPDMCHA OPTIONAL
*"     VALUE(CHANGE_LGORT) LIKE  MCHB-LGORT OPTIONAL
*"     VALUE(BYPASS_LOCK) LIKE  AM07M-XSELK DEFAULT SPACE
*"     VALUE(BYPASS_POST) LIKE  AM07M-XSELK DEFAULT SPACE
*"     VALUE(X_BNCOM) LIKE  BNCOM STRUCTURE  BNCOM OPTIONAL
*"     VALUE(KZCLA) LIKE  T156-KZCLA OPTIONAL
*"     VALUE(XKCFC) LIKE  T156-XKCFC OPTIONAL
*"     VALUE(CLASS) LIKE  KLAH-CLASS OPTIONAL
*"     VALUE(NO_CHECK_OF_QM_CHAR) LIKE  AM07M-XSELK DEFAULT SPACE
*"     VALUE(REF_MATNR) LIKE  MCHA-MATNR OPTIONAL
*"     VALUE(REF_CHARG) LIKE  MCHA-CHARG OPTIONAL
*"     VALUE(REF_WERKS) LIKE  MCHA-WERKS OPTIONAL
*"     VALUE(SET_OLD_BATCH) LIKE  AM07M-XSELK DEFAULT 'X'
*"     VALUE(BUFFER_REFRESH) LIKE  AM07M-XSELK OPTIONAL
*"     VALUE(NO_CHANGE_DOCUMENT) LIKE  AM07M-XSELK DEFAULT SPACE
*"     VALUE(GRUND) LIKE  MSEG-GRUND DEFAULT SPACE
*"     VALUE(NO_CFC_CALLS) LIKE  AM07M-XSELK DEFAULT SPACE
*"     VALUE(BATCH_DEL_FLAGS) LIKE  BATCHDELFLG STRUCTURE  BATCHDELFLG
*"       DEFAULT SPACE
*"     VALUE(SEND_SYS) TYPE  LOGSYS DEFAULT SPACE
*"  EXPORTING
*"     VALUE(YMCHA) LIKE  MCHA STRUCTURE  MCHA
*"     VALUE(EMKPF) LIKE  EMKPF STRUCTURE  EMKPF
*"  TABLES
*"      CHAR_OF_BATCH STRUCTURE  CLBATCH OPTIONAL
*"      CHANGED_BATCH STRUCTURE  MCHA OPTIONAL
*"      ZIMSEG STRUCTURE  IMSEG OPTIONAL
*"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"  EXCEPTIONS
*"      NO_MATERIAL
*"      NO_BATCH
*"      NO_PLANT
*"      MATERIAL_NOT_FOUND
*"      PLANT_NOT_FOUND
*"      LOCK_ON_MATERIAL
*"      LOCK_ON_PLANT
*"      LOCK_ON_BATCH
*"      LOCK_SYSTEM_ERROR
*"      NO_AUTHORITY
*"      BATCH_NOT_EXIST
*"      NO_CLASS
*"      ERROR_IN_CLASSIFICATION
*"      ERROR_IN_VALUATION_CHANGE
*"----------------------------------------------------------------------
  DATA: F_TRANSACTION_ID           LIKE ARFCTID.

  CALL FUNCTION 'TRANSACTION_BEGIN'
    IMPORTING
      TRANSACTION_ID = F_TRANSACTION_ID.

  CALL FUNCTION 'VB_CHANGE_BATCH'
    EXPORTING
      YMCHA                     = YMCHA
      YUPDMCHA                  = YUPDMCHA
      CHANGE_LGORT              = CHANGE_LGORT
      BYPASS_LOCK               = BYPASS_LOCK
      BYPASS_POST               = BYPASS_POST
      X_BNCOM                   = X_BNCOM
      KZCLA                     = KZCLA
      XKCFC                     = XKCFC
      CLASS                     = CLASS
      NO_CHECK_OF_QM_CHAR       = NO_CHECK_OF_QM_CHAR
      REF_MATNR                 = REF_MATNR
      REF_CHARG                 = REF_CHARG
      REF_WERKS                 = REF_WERKS
      SET_OLD_BATCH             = SET_OLD_BATCH
      BUFFER_REFRESH            = BUFFER_REFRESH
      NO_CHANGE_DOCUMENT        = NO_CHANGE_DOCUMENT
      GRUND                     = GRUND
      NO_CFC_CALLS              = NO_CFC_CALLS
      BATCH_DEL_FLAGS           = BATCH_DEL_FLAGS
      SEND_SYS                  = SEND_SYS
    IMPORTING
      YMCHA                     = YMCHA
      EMKPF                     = EMKPF
    TABLES
      CHAR_OF_BATCH             = CHAR_OF_BATCH
      CHANGED_BATCH             = CHANGED_BATCH
      ZIMSEG                    = ZIMSEG
    EXCEPTIONS
      NO_MATERIAL               = 1
      NO_BATCH                  = 2
      NO_PLANT                  = 3
      MATERIAL_NOT_FOUND        = 4
      PLANT_NOT_FOUND           = 5
      LOCK_ON_MATERIAL          = 6
      LOCK_ON_PLANT             = 7
      LOCK_ON_BATCH             = 8
      LOCK_SYSTEM_ERROR         = 9
      NO_AUTHORITY              = 10
      BATCH_NOT_EXIST           = 11
      NO_CLASS                  = 12
      ERROR_IN_CLASSIFICATION   = 13
      ERROR_IN_VALUATION_CHANGE = 14
      OTHERS                    = 15.

  IF SY-SUBRC IS INITIAL.
    CALL FUNCTION 'TRANSACTION_END'
      EXPORTING
        TRANSACTION_ID = F_TRANSACTION_ID
      EXCEPTIONS
        OTHERS         = 1.
  ELSE.
    CALL FUNCTION 'BALW_BAPIRETURN_GET2'
      EXPORTING
        TYPE   = SY-MSGTY
        CL     = SY-MSGID
        NUMBER = SY-MSGNO
        PAR1   = SY-MSGV1
        PAR2   = SY-MSGV2
        PAR3   = SY-MSGV3
        PAR4   = SY-MSGV4
      IMPORTING
        RETURN = RETURN.
    APPEND RETURN.

    CALL FUNCTION 'TRANSACTION_ABORT'
      EXPORTING
        TRANSACTION_ID = F_TRANSACTION_ID
      EXCEPTIONS
        OTHERS         = 1.
    EXIT.
  ENDIF.

ENDFUNCTION.

Thanks,

Sara