SAP Batch Management: User-exits and BAdIs

SAP Batch Management 1

In this article, we will discuss in detail the different methods to enhance the standard process in SAP Batch Management.

The list of SAP Batch Exit and BAdIs will be classified by Business functionalities:

Batch Master, Batch Classification, Batch Numbering, Internal and external, Batch Status, SLED Management, Batch Information Cockpit Exit, Derivation and Batch Determination User-Exit and BAdI’s.

Read also SAP Batch Management Tcodes, Tables and Customizing (SAP Batch Management).

SAP Batch Master User-Exists and BAdIs

BAdI BATCH_MASTER

BATCH_MASTER: Enhancements for Batch Master Transactions
It is called in MSC1N and MSC2N to validate user’s input.

There is 4 methods for BATCH_MASTER BAdI:

  • CHECK_DATA_BEFORE_SAVE Check Batch Data at Save
  • CHECK_CLASSIF_BEFORE_SAVE Batch Classification Check When Saving
  • SINGLE_FIELD_CONTROL Field Selection Control
  • LOCK_BATCH_MASTER_IN_MIGO Influence Lock of Batch Master Record in MIGO

EXIT_SAPLV01Z_013

It is called in Function Modules VB_CREATE_BATCH and VB_CHANGE_BATCH to set/change master data.

It is also called in transaction MIGO.

CALL FUNCTION 'EXIT_SAPLV01Z_013'
* EXPORTING
*   x_bncom =                   " bncom         Application Data from Business Transaction
*   mcha_old =                  " mcha          Original Batch Master Record
*   ref_material =              " mcha-matnr    Reference Material (for Information)
*   ref_batch =                 " mcha-charg    Source Batch (for Information)
*   ref_plant =                 " mcha-werks    Reference Plant (for Information)
* CHANGING
*   batch_master_data =         " mbcfc003      Modifiable Batch Master Record
*   batch_valuation_type =      " mcha-bwtar    Valuation Type of batch (if Split Valuation)

EXIT_SAPMM07M_003

It is called in MM coding (MB1A, MB1B, MB1C, etc) but only for new batches.

CALL FUNCTION 'EXIT_SAPMM07M_003'
  EXPORTING
    i_matnr =                   " mara-matnr    Material Number of New Batch
    i_charg =                   " mch1-charg    New Batch Number
*   i_werks =                   " mcha-werks    Plant
    i_mseg =                    " mseg          Material Document Item
    i_vm07m =                   " vm07m         Additional Data for Material Document Item
    i_dm07m =                   " dm07m         Additional Data for Material Document Item
    i_mkpf =                    " mkpf          Material Document Header
  CHANGING
    batch_master_data =         " mbcfc003      Modifiable Batch Master Record

Batch Classification

EXIT_SAPLV01Z_012

It is called in Function Modules VB_CREATE_BATCH and VB_CHANGE_BATCH to determine whether classification and exits should be executed.

In other words, it’s possible make the system ignore the classification routines. Just set the parameters TYPE_OF_CLASSIFYING and EXTENDED_CLASSIFYING accordingly.

CALL FUNCTION 'EXIT_SAPLV01Z_012'
* EXPORTING
*   x_bncom =                   " bncom         Application Data from Business Transaction
*   x_mcha =                    " mcha          Workarea of New Batch
*   ref_material =              " mcha-matnr    Reference Material (for Information)
*   ref_batch =                 " mcha-charg    Source Batch (for Information)
*   ref_plant =                 " mcha-werks    Reference Plant (for Information)
* CHANGING
*   type_of_classifying =       " t156-kzcla    Type of Classification
*   extended_classifying =      " t156-xkcfc    Extended Classification EXIT_SAPLV01Z_014
*   no_check_of_qm_char = SPACE  " am07m-xselk  No Check Against QM Characteristics

EXIT_SAPLV01Z_014

It’s called in VB_CREATE_BATCH and VB_CHANGE_BATCH to set/change?free characteristics.

Free characteristics are those that do not begin with ‘LOBM_’.

CALL FUNCTION 'EXIT_SAPLV01Z_014'
* EXPORTING
*   x_bncom =                   " bncom         Application Data from Business Transaction
*   ref_material =              " mcha-matnr    Reference Material (for Information)
*   ref_batch =                 " mcha-charg    Source Batch (for Information)
*   ref_plant =                 " mcha-werks    Reference Plant (for Information)
* TABLES
*   characters =                " api_char      Attributes of Batch
*   attributes =                " api_ch_att    Attributes of Characteristics
*   max_values =                " api_val_i     Value Ranges of Characteristics
*   values =                    " api_val_i     Values of Characteristics

Check this scn thread aboutEXIT_SAPLV01Z_014. Changing characteristic values at Batch creation.

EXIT_SAPMM07M_004

It is used to fill the classification data in MM transactions.

CALL FUNCTION 'EXIT_SAPMM07M_004'
  EXPORTING
    i_mseg =                    " mseg          Material Document Item
    i_vm07m =                   " vm07m         Additional Data for Material Document Item
    i_dm07m =                   " dm07m         Additional Data for Material Document Item
    i_mkpf =                    " mkpf          Material Document Header
  TABLES
    characters =                " api_char      Attributes of Batch
    attributes =                " api_ch_att    Attributes of Characteristics
    max_values =                " api_val_i     Value Ranges of Characteristics
    values =                    " api_val_i     Values of Characteristics

Batch Numbering – Internal

EXIT_SAPLV01Z_001

Replacement of the number range, decision for internal or external numbering.

For more information, check the help.sap.com page aboutFurther information and examples for EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002

CALL FUNCTION 'EXIT_SAPLV01Z_001'
* EXPORTING
*   x_bncom =                   " bncom         Application Data from Business Transaction
  IMPORTING
    cust_no_internal =          "               Suppress Internal Number Assignment
* CHANGING
*   nr_range_nr = '01'          " inri-nrrangenr  Number Range Number
*   object = 'BATCH_CLT'        " inri-object   Name of Number Range Object
*   subobject = SPACE           " inri-subobject  Value of Subobject of Number Range Object
*   toyear = '0000'             " inri-toyear   To Fiscal Year
*   message_when_auto = SPACE   " am07m-xselk   Sending a Confirmation Prompt

EXIT_SAPLV01Z_002

Assignment of customer-specific batch number. Also used to assign an existing batch (allow_existing_batch) via VB_CREATE_BATCH.

Further information and examples for EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002

CALL FUNCTION 'EXIT_SAPLV01Z_002'
* EXPORTING
*   x_bncom =                   " bncom         Application Data from Business Transaction
  CHANGING
    new_charg =                 "               New Batch Number Assigned During Internal Number Assignment
  EXCEPTIONS
    CANCELLED = 1               "               Canceled

EXIT_SAPMM07M_010

Called in MM coding to assign existing batches.

CALL FUNCTION 'EXIT_SAPMM07M_010'
  EXPORTING
    i_mseg =                    " mseg          Document Segment: Material
    i_vm07m =                   " vm07m         Fields: Update Control of Module Pool SAPMM07M
    i_dm07m =                   " dm07m         Dialog Control Fields for Module Pool SAPMM07M
    i_mkpf =                    " mkpf          Header: Material Document
    i_transfer =                " dm07m-kzuml   Stock Transfer/Transfer Posting
  IMPORTING
    e_charg =                   " mcha-charg    Batch Number

Batch numbering – External

EXIT_SAPLV01Z_003

Replacement of the number range, decision customer-specific check.

CALL FUNCTION 'EXIT_SAPLV01Z_003'
* EXPORTING
*   new_charg =                 " mcha-charg    Batch Numbers to Be Checked
*   x_bncom =                   " bncom         Application Data from Business Transaction
* CHANGING
*   nr_range_nr = '02'          " inri-nrrangenr  Number Range Number
*   object = 'BATCH_CLT'        " inri-object   Name of Number Range Object
*   subobject = SPACE           " inri-subobject  Value of Subobject of Number Range Object
*   toyear = '0000'             " inri-toyear   To Fiscal Year
*   cust_no_check = ' '         "               Suppress Check Against Number Range

EXIT_SAPLV01Z_004

Check of batch number based on customer rules.

CALL FUNCTION 'EXIT_SAPLV01Z_004'
  EXPORTING
    new_charg =                 " mcha-charg    Batch Numbers to Be Checked
*   x_bncom =                   " bncom         Application Data from Business Transaction
  IMPORTING
    cust_not_allowed =          "               Batch Number Is not Valid

SAP Batch Management Status

The SAP Batch Management Status exis EXIT_SAPLV01D_001 is used for Determination of the initial status of a batch.

SLED (shelf life expiration date)

SAP Batch Management BAdI VB_SLED_MANAGEMENT

VB_SLED_MANAGEMENT: Control of Shelf Life Expiration Date Processing

It’s used to set VFDAT/HSDAT and switch off SLED management
(method:?MAINTAIN_SLED_PARAMETERS:?Change Parameters of Minimum Shelf Life Processing)

SAP Batch Management SLED EXIT_SAPLVBMD_001 Userexit

It is typically based on similar functionality as BAdI VB_SLED_MANAGEMENT

CALL FUNCTION 'EXIT_SAPLVBMD_001'
* EXPORTING
*   i_bncom =                   " bncom         Batch Number Allocation: Communication Block (Dialog)
* CHANGING
*   c_bezdt =                   " mcha-vfdat    Shelf Life Expiration Date
*   c_iprkz_hbd =               " mara-iprkz    Period Indicator for Shelf Life Expiration Date
*   c_iprkz_rlz =               " mara-iprkz    Period Indicator for Shelf Life Expiration Date
*   c_rdmhd =                   " mara-rdmhd    Rounding Rule for Calculation of SLED
*   c_geshb =                   " mara-mhdhb    Total Shelf Life
*   c_rstlz =                   " mara-mhdrz    Minimum Remaining Shelf Life
*   c_mhdat =                   " mcha-vfdat    Shelf Life Expiration Date
*   c_hsdat =                   " mcha-vfdat    Shelf Life Expiration Date

Batch Information Cockpit

SAP Batch Management BIC_ADDITIONAL_DATA

BIC_ADDITIONAL_DATA: BAdI: Batch Information Cockpit – Additional Data/Columns

Add additional columns to selection result master and selection result stock.

You will find the following methods :

  • MASTER_COLUMNS_ADD Add Columns for Additional Data for Selection Result:Batches
  • STOCK_COLUMNS_ADD Add Columns for Additional Data for Selection Result: Stock
  • MASTER_ADD_DATA_FILL_IN Add Additional Data to Selection Result: Batches
  • STOCK_ADD_DATA_FILL_IN Add Additional Data to Selection Result: Stock
  • MASTER_ADD_DATA_SELECT Select Additional Data for Selection Result: Batches
  • STOCK_ADD_DATA_SELECT Select Additional Data for Selection Result: Stock

BIC_FOLLOW_UP_ACTION

BIC_FOLLOW_UP_ACTION: Follow-On Actions in the Batch Information Cockpit

Allows defining actions for SAP Batch Management in the selection result (for example, change of batch status):

  • PASS_BATCHES_FOR_ACTION Transfers selected batches to follow-up actions
  • BUILD_LOG_PROFILE Constructs the field catalog for the application log
  • ADD_MSG_TO_LOG Adds a message to the application log
  • SAVE_LOG_TO_DB Saves the application log to the database

BIC_SELECTION

BIC_SELECTION: Selection Enhancement in the SAP Batch Management Information Cockpit

Definition of custom selection screen and selection logic.

The Methods of?BIC_SELECTION Batch BaDi are:

  • DEFINE_SUBSCREEN Definition of a free selection tab page
  • CHECK_SUBSCREEN_FOR_INPUT Checks free selection tab pages for user entries
  • RESET_SUBSCREEN Resets the selection criteria for the selection tab page
  • PRESELECT_BATCHES Customer-specific preselection of batches
  • REFINE_SELECTION_RESULT Deletes entries from the ‘Selection Results Batches’
  • ENRICH_MASTER_RESULT More details for the ‘Selection Results Batches’
  • ACTION_WITH_INFO_OBJECT Executes an action for a customer-specific info object
  • GET_SELID_FOR_ENHANCEMENT Procures ID of Selection Enhancement from Customizing
  • GET_SELID_FOR_ENHANCEMENT Procures ID of Selection Enhancement from Customizing
  • CHECK_FOR_OBLIGATORY_INPUT Check on Mandatory Entries for “Execute Selection”

Batch Where-Used List

BAdI VB_BWUL_EXPLOSION

Allows fine-tuning the selection for each object (batch, PO, production order).

The BADi BAdI VB_BWUL_EXPLOSION offers 5 methods :

  • BWUL_REF_TO_ORDER_MAINTAIN Process Batch Where-Used Records with Reference to Order
  • BWUL_REF_TO_PO_MAINTAIN Process Batch Where-Used Records with Ref. to Purchase Order
  • BWUL_REF_TO_BATCH_MAINTAIN Process Batch Where-Used Records with Reference to Batch
  • SELECTION_PARAMETER_ACTIVATE Activate Parameters for Extended Selection
  • COMPLETE_BWUL_MAINTAIN Process Complete Batch Where-Used List

BAdI VB_GET_POS_PLANT

Pre-determines plant for the selection screen of BWUL.
VB_GET_POS_PLANT: Enhancement of Automatic Plant Determination in transaction CodeMB56.

The unique method for the BAdI VB_GET_POS_PLANT isGET_PLANT.

The signature of VB_GET_POS_PLANT->GET_PLANT is

  • I_EXPTP TYPE EXPTP Expansion category f. batch where-used list display
  • I_MATNR TYPE MATNR Material Number
  • I_CHARG TYPE CHARG_D Batch Numbervalue
  • ( E_WERKS ) TYPE WERKS_D Plant

BAdI VB_GET_EXT_BATCHES

VB_GET_EXT_BATCHES: Access to Customer-Specific Batch Usage Data
Allows reading external batches for a subcontracting process.

In this BADi VB_GET_BATCHES, there is 3 differents methods:

  • GET_BATCH_USAGE_A: Determine Batch Usage for Order
  • GET_BATCH_USAGE_B: Determine Batch Usage for Purchase Order
  • GET_BATCH_USAGE_C: Determine Batch Usage for Batch

EXIT_SAPLCHVW_001

Allows filling additional columns into Batch Where-Used List.

CALL FUNCTION 'EXIT_SAPLCHVW_001'
  TABLES
    t_shadow =                  " chvwshadow
    .  "  EXIT_SAPLCHVW_001

SAP Batch Determination BADis and Exit

BAdI VB_BD_SELECTION

VB_BD_SELECTION: Preselection of Batches Within Batch Determination within SAP Batch Management

Can be used instead of the standard selection to select batches from stock. It?s important to point out that the standard batch selection won?t work after the BAdI activation.

You can use depending on your requirement one of these methods:

  • PRESELECT_BATCHES Preselection of Batches
  • PRESELECT_BATCHES Preselection of Batches
  • PRESELECT_STOCKS Preselection of Batch Stock Records
  • RESTRICT_CONF_CHARS Restrict Characteristics of Configuration
  • SET_CHAR_EXCLUDING Characteristic to Be Interpreted Exclusively

BAdI VB_BD_SELECTION_CRITERIA

VB_BD_SELECTION_CRITERIA: SAP Batch Management: Batch Determination Selection Criteria

It is used to change the selection criteria (it will generate a new CUOBJ) using the method

  • SEL_CRIT_CHANGE Change Selection Criteria for Batch Determination in SAP Batch Management

EXIT_SAPLV01F_001

It is used to change the selection criteria (will generate a new CUOBJ)

CALL FUNCTION 'EXIT_SAPLV01F_001'
  TABLES
    characters =                " api_char      Characteristics of Selection Class
    values =                    " api_val_i     Valuation of Characteristics

EXIT_SAPLV01F_002

Allows changing the communication structures BDCOM, KOMKH, KOMPH used in function module VB_BATCH_DETERMINATION. For more information you can access document

CALL FUNCTION 'EXIT_SAPLV01F_002'
  CHANGING
    c_bdcom =                   " bdcom         Batch Determination Communication Structure
    c_komkh =                   " komkh         Batch Determination Communication Block Header
    c_komph =                   " komph         Batch Determination: Communication Record for Item

Source:Userexits and BAdIs – Batch Management