Downtime Announcement: Please note the SAP Community Wiki will be unavailable due to a system upgrade on Thursday, September 24th between 6 and 7 AM CEST
Skip to end of metadata
Go to start of metadata

Purpose

The purpose of this page is to stock and batch determination can be used and activated and to provide some technical information about both topics.

Overview

The first section provides an overview about the stock determination, including a short summary of how this function can be used and how it can be activated, the affected application components are listed and the source code is available. The second section provides the same information about the batch determination.

Stock Determination

Use

Stock determination enables you to implement various strategies to withdraw materials for goods issues and stock transfers. You configure these strategies in Customizing. Based on the material requirements entered, the system determines how and when the material should be withdrawn, and from which storage locations and stocks.
Based on the stock determination strategy you predefine, the system makes decisions on material withdrawal depending on the material, plant, and the business process.
You can use stock determination for the following stocks:

  • unrestricted-use stock
  • vendor consignment stock (K)
  • pipeline material (P)
  • sales order stock (E)
  • project stock (Q)

To trigger stock determination for a goods movement in the older MB* transactions enter an asterisk  ( * ) in the storage location field, in transaction MIGO the stock determination icon should be used.

 
Activate Stock Determination

 

  • In Customizing for the application you are using, assign a stock determination rule to the business transaction/event.
  • Assign a stock determination group to the material in the material master record.

Customizing
Where to find in Customizing:
  ==> Materials Management
         ==> Inventory management and Physical Inventory
                 ==> Stock Determination:
                        ==> Define Strategies for Stock Determination                                   (1)
                         ==> Assign Stock Determination Rule in the Applications 
                                   ==> Inventory Management                                                   (2)

In order to work with stock determination, you must configure the following:

1.) Define Strategies for Stock Determination
You determine a strategy at plant level using the stock determination group and the stock determionation rule. The stock determination group is assigned to the material in the material master record.

EXAMPLE:
- Create stock determination group G001 for plant 0001 using button  'New Entries'
- Create stock determination rule  R001 using button 'New Entries'
- Create entry in stock determination header table using button 'New Entries':
Plant                              0001                                           
Stock determ. group       G001                                           
Stck determation rule      R001                                           
Description                     first header entry                             

You can set up the
- Sorting for: Item table, Price, Qty (in EXAMPLE: Ascending for all the alternatives)
- Quantity distribution
- Other settings: WM-processing, stock determination online (it is useful to set this parameter during testing), pipeline withdrawal, user exit for item table

- Create entry in stock determination item table using button 'New Entries':       
S         Storage location        Priority
F                  0001                    1
F                  0002                    2
K                 0001                    3
K                 0002                    4

(S= Indicates the stock that stock determination should suggest for withdrawal:

  • K = consignment stock
  • F = unrestricted stock
  • empty (blank) = consignment and unrestricted-use stock

2.) Assign Stock Determination Rule in Inventory Management 
Assign a stock determination rule to each movement type for which you want to allow automatic stock determination. You can only establish one stock determination rule for each movement type.
EXAMPLE:
MvT             Movement type text          Stck determation rule        
502             RE receipt w/o PO              R001                 

Material Master
Assign the stock determination group to the required materials in the MRP 2 or Plant data/storage 2 screen of the material master record.
EXAMPLE:  Group G001 assigned to material DUHN.

Overview

Customizing:
1. Stock determination group:                   G001, plant 0001
2. Stock determination rule:                      R001
3. Stock determination header table:          G001, plant 0001, R001
                                                               Stock determination item table:  
                                                               (for G001, plant 0001, R001)
                                                              Special stock          Storage loc.         Priority    Valuation type
                                                                    F                         0001                  1 
                                                                    F                         0002                  2
                                                                    K                         0001                  3
                                                                    K                         0002                  4
4. Stock determination rule in MM-IM: movement type 502, rule R001

Material Master:    maintain Group 2 (in screen 'MRP2' or 'Plant data/storage 2') for testmaterial 'DUHN'

     

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Goods Movement

EXAMPLE:
1) Before goods movement:
MMBE:
Plant      0001                                              250,000  
             Storage loc.                      0001                                   170,000  
             Vendor consignment  in     0001                                    60,000  
                  Vendor  vend1                                                                        45,000
                  Vendor  vend2                                                                        15,000
             Storage loc.                      0002                                     80,000  
                                           

2.) Post a goods receipt reversal for material DUHN with movement type 502.
The stock determination will find:
a) Quantity = 100:
SLoc Batch        Val. Type    Vendor     S                 determ.quan.                     Available quantity  
0001                                                                       100,000                             170,000   
0002                                                                                                                 80,000   
0001                                   VEND1    K                                                              45,000   
0001                                   VEND2    K                                                              15,000   

b) Quantity = 200:
SLoc Batch       Val. Type    Vendor      S                     determ.quan.                   Available quantity  
0001                                                                           170,000                             170,000   
0002                                                                           30,00                                  80,000   
0001                                   VEND1      K                                                                45,000   
0001                                   VEND2      K                                                                15,000

c) Quantity = 300:
SLoc Batch       Val. Type     Vendor      S                     determ.quan.                 Available quantity  
0001                                                                            170,000                           170,000   
0002                                                                              80,00                               80,000   
0001                                   VEND1      K                         45,00                               45,000   
0001                                   VEND2      K                           5,00                               15,000

(the consignment price for vendor VEND1 is cheaper)
 

Integration

Stock determination functions are of significance to the integration of the ERP system as a whole, and can be used in several ERP application components. You can use stock determination in the following application components:

  • MM - IM (Inventory Management)
  • LE - WM (Warehouse Management)
  • PP - SFC (Production Orders)
  • PP - REM (Repetitive Manufacturing)
  • PP - KAB (Kanban)
  • LO - BM (Batch Management)
  • SD (Sales and Distribution)

In Customizing, you can define how stock determination interacts with the settings of the Warehouse Management System and Batch Determination.

ATTENTION:  The applications LE - WM , PP - SFC, PP - REM, PP - KAB and SD use the function MB_CREATE_GOODS_MOVEMENT to post a goods movement. This function is not able to do a stock determination, therefore the calling application is responsible for a correct stock determination. This logic also applies to the BAPI BAPI_GOODSMVT_CREATE, refer to note 520813 for more information.

Source Code

The most important include is MM07MFL0_LAGERORTDATEN:
 

*---------------------------------------------------------------------*
*       FORM LAGERORTDATEN                                            *
*---------------------------------------------------------------------*
*       Die Daten auf Lagerort- und Chargenebene des Materials        *
*       werden geprueft und ins Segment uebernommnen.                 *
*---------------------------------------------------------------------*
FORM LAGERORTDATEN.
...
* @vsa_cd ende
      IF MSEG-CHARG CA STERN OR MSEG-LGORT CA STERN.    <- check if stock det.is active
           This is the best place for a break-point
* Charge/Lagerort * bei Stücklisten (Leihgut,..) und value added service
* nicht erlaubt
        IF NOT DM07M-UPVOR IS INITIAL OR
           ( NOT DM07M-UEBPO IS INITIAL AND DM07M-UPTYP CA '234' ) OR
           NOT DM07M-XVASH IS INITIAL.
          MESSAGE E116.
        ELSE.                                             "NOTE 180691
           PERFORM RETAIL_ARTICLE_SPLIT_CHECK.            "NOTE 180691
        ENDIF.
        IF MSEG-CHARG CA STERN.
          IF DM07M-KZECH IS INITIAL.
            IF NOT ( MSEG-SOBKZ EQ SPACE OR
                     MSEG-SOBKZ EQ O     OR
                     MSEG-SOBKZ EQ V     OR
                     MSEG-SOBKZ EQ W     OR
                     MSEG-SOBKZ EQ E     OR
                     MSEG-SOBKZ EQ Q     OR
                     MSEG-SOBKZ EQ K     OR ).
              MESSAGE E116.
            ENDIF.
            IF DM07M-CHSMM IS INITIAL AND NOT MSEG-SOBKZ IS INITIAL
               AND DM07M-RULES IS INITIAL.
              MESSAGE E116.
            ENDIF.
          ENDIF.
        ELSEIF NOT ( mseg-sobkz EQ space OR                     <- these special stocks are
                     mseg-sobkz EQ K     OR                                        allowed for LGORT=*
                     mseg-sobkz EQ E     OR                                 All other spec.stocks will
                     mseg-sobkz EQ Q        ).                                                   Cause M7116.
          MESSAGE E116.
        ENDIF.
        XLAUS = X.
        DATA X_LGORT LIKE MSEG-LGORT.
        X_LGORT = MSEG-LGORT.
        IF X_LGORT CA STERN.
          CLEAR MSEG-LGORT.
        ENDIF.
        IF NOT DM07M-EPRIO IS INITIAL AND DM07M-FAUSW+13(1) = MINUS.
          DM07M-FAUSW+13(1) = PUNKT.
        ENDIF.
*------ Chargenfindung über L_IM_BATCH_DETERMINATION_INT
        IF MSEG-CHARG CA STERN AND DM07M-KZECH EQ STERN
                               AND NOT VM07M-XCHPF IS INITIAL.
          PERFORM CHARGENBESTIMMUNG_WM_PP.
*------ Chargenfindung über VB_BATCH_DETERMINATION
        ELSEIF MSEG-CHARG CA STERN AND NOT DM07M-CHSMM IS INITIAL
                                   AND NOT VM07M-XCHPF IS INITIAL.
          PERFORM CHARGENFINDUNG USING F.
*------ Bestandsfindung über BF_STOCK_DETERMINATION
        ELSEIF NOT DM07M-EPRIO IS INITIAL AND                          -> EXAMPLE:-EPRIO='G001'
               NOT DM07M-RULES IS INITIAL AND                                                 -RULES='R001'
               MSEG-SHKZG = H AND                                                -> -SHKZG = H =>Only goods issues!!!
               ( X_LGORT CA STERN OR ( MSEG-CHARG CA STERN AND
               ( NOT DM07M-XCHAR IS INITIAL OR MSEG-SOBKZ = O ) ) ).
          PERFORM BESTANDSFINDUNG.
        ELSE.
*-------- Storage location selection: No special stock allowed
          IF MSEG-SOBKZ <> SPACE.
            MESSAGE E116.
          ENDIF.
*------   alte Chargenfindung
          MOVE-CORRESPONDING DM07M TO MBEFU.
          MOVE-CORRESPONDING VM07M TO MBEFU.
          MOVE-CORRESPONDING MSEG TO MBEFU.
          PERFORM LAGERORTAUSWAHL(SAPFM07M) USING MSEG-MATNR
                                                  MSEG-WERKS
                                                  MSEG-SOBKZ
                                                  MSEG-LGORT
                                                  MSEG-SHKZG
                                                  MSEG-WERTU
                                                  MSEG-MENGU
                                                  FUSS-XNEPO.
...


refer to the code above  'PERFORM BESTANDSFINDUNG.'
 

... MM07MFL0_LAGERORTDATEN

LOOP AT YLGORT WHERE NOT XSELP IS INITIAL.    
               INDEX_Z = INDEX_Z + 1.                      
               IF INDEX_Z = 1.                             
                 LIFNR = MSEG-LIFNR.                       
                 SOBKZ = MSEG-SOBKZ.                       
                 MOVE-CORRESPONDING YLGORT TO DM07M.        -> move data from function 'BF_STOCK_DETERMINATION'
                 MOVE-CORRESPONDING YLGORT TO VM07M.         to our 'well known' internal tables DM07M, VM07M, MSEG    
                 MOVE-CORRESPONDING YLGORT TO MSEG.          and later in FUSS
...

Batch Determination

Use

Purpose
A posting is required for all goods movements in Inventory Management in order to record changes to the quantity and value of stock. You can only use batch determination for goods issues. Below, you will find some business transactions during which a goods issue takes place:

  • Withdrawal for production/process order
  • Internal material provision
  • Return delivery to supplier
  • Scrapping/sampling
  • Transfer posting

To trigger batch determination for goods issues in the older MB* transactions, enter an asterisk ( * ) in field Batch. In the transaction MIGO the stock determination icon should be used.

ATTENTION:  A lot of applications use the function MB_CREATE_GOODS_MOVEMENT to post a goods movement in the background. This function is not able to do a batch determination, therefore the calling application is responsible for a correct batch determination. This logic also applies to the BAPI BAPI_GOODSMVT_CREATE, refer to note 520813 for more information.

Activate Batch Determination

Customizing
You have to make the settings for Batch Determination in Customizing for Batch Management.

==> Logistics General
         ==> Batch Management
                ==> Batch Determination and Batch Check
                       ==> Condition Tables  
                               ==> Define Inventory Management Condition Tables    (1)
                       ==> Access Sequences  
                               ==> Define Inventory Management Acess Sequences   (2)
                       ==> Strategy Types  
                               ==> Define Inventory Management Strategy Types      (3)
                       ==> Batch Search Procedure Definition
                               ==> Define Inventory Management Search Procedure   (4)
                       ==> Batch Search Procedure Allocation and Check Activation
                               ==> Allocate IM Search Procedure/Activate Check        (5)

1.) Define Inventory Management Condition Tables
The system contains the following condition tables for batch determination in Inventory Management:

  • 020 Movement type
  • 021 Movement type/plant
  • 022 Movement type/material
  • 023 Plant/material
  • 024 Movement type/plant/material
  • 025 Plant

If you wish to use the plant and the material as selection criteria for batch determination, you should work with 023.
SAP Recommendation: Customer should not change the condition tables contained in the standard version.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In this step, you allocate batch search procedures to those Inventory Management movement types for which batch determination is to be carried out, and activate batch checking.

MvT            Movement type text  S Special stock descr.                 Search Check batch      
502             RE receipt w/o PO                                                     ME0001


 

Summary

Movement type 502
    ==> Search procedure ME0001                                                                     (customizing step 5)
    ==> Strategy type ME01 for search procedure ME0001                                    (customizing step 4)
                Step 10 (in this example only one step, but you can define more)
                ==> Access sequence for ME01                                                         (customizing step 2)
                       10   24 Movement Type/Plant/Material                                      
                       20   23 Plant/Material                                                    
                       30   22 Movement Type/Material                                            
                       40   21 Movement Type/Plant    
                       50   21 Movement Type                                        
=> The batch determination will start with the movement type/plant/material entries.

Material Master

First of all you have to create a material with batch management.
After that, you have to create a batch search strategy (transaction MBC1) for this material:
EXAMPLE:
Enter ME01 for strategy type. After that you will get a Popup with all the access sequences:
       - Movement Type/Plant/Material                                                  (customizing step 2)                       
       - Plant/Material                                                 
       - Movement Type/Material                                         
       - Movement Type/Plant                                            
       - Movement Type   
You have to choose one of these access sequences. In our example, we choose 'Movement Type/Plant/Material'. On the next screen you have to enter:
- movement type
- plant
- material
After ENTER all customized data for strategy type ME01 will be displayed. (customizing step 3)

TIP:
If you use a material with classification, you should use the button 'Selection criteria'. You get a Popup where you can enter the class and afterwards the values for the class characteristic. During a goods movement, the batch determination will determine only batches with these class characteristic values.                                               

(MBC1: create search strategy, MBC2: change search strategy, MBC3: display search strategy)

The result would be:
 If you use batch = '*' in a MBxx-Transaction the batch determination is looking the search strategy for the entered movement type / plant / material. If it was maintained within MBC1, it will use this strategy.

Source Code

The most important include is MM07MFL0_LAGERORTDATEN:

*---------------------------------------------------------------------*
*       FORM LAGERORTDATEN                                            *
*---------------------------------------------------------------------*
*       Die Daten auf Lagerort- und Chargenebene des Materials        *
*       werden geprueft und ins Segment uebernommnen.                 *
*---------------------------------------------------------------------*
FORM LAGERORTDATEN.
...
* @vsa_cd ende
      IF MSEG-CHARG CA STERN OR MSEG-LGORT CA STERN.    <- check if batch det.is active
           This is the best place for a break-point
* Charge/Lagerort * bei Stücklisten (Leihgut,..) und value added service
* nicht erlaubt
        IF NOT DM07M-UPVOR IS INITIAL OR
           ( NOT DM07M-UEBPO IS INITIAL AND DM07M-UPTYP CA '234' ) OR
           NOT DM07M-XVASH IS INITIAL.
          MESSAGE E116.
        ELSE.                                             "NOTE 180691
           PERFORM RETAIL_ARTICLE_SPLIT_CHECK.            "NOTE 180691
        ENDIF.
        IF MSEG-CHARG CA STERN.
          IF DM07M-KZECH IS INITIAL.
            IF NOT ( MSEG-SOBKZ EQ SPACE OR                 <- these special stocks are
                     MSEG-SOBKZ EQ O     OR                              allowed for BATCH=*
                     MSEG-SOBKZ EQ V     OR                               All other spec.stocks will
                     MSEG-SOBKZ EQ W     OR                              Cause M7116.
                     MSEG-SOBKZ EQ E     OR
                     MSEG-SOBKZ EQ Q     OR
                     MSEG-SOBKZ EQ K     OR ).
              MESSAGE E116.
            ENDIF.
            IF DM07M-CHSMM IS INITIAL AND NOT MSEG-SOBKZ IS INITIAL
               AND DM07M-RULES IS INITIAL.
              MESSAGE E116.
            ENDIF.
          ENDIF.
        ELSEIF NOT ( mseg-sobkz EQ space OR    
                     mseg-sobkz EQ K     OR    
                     mseg-sobkz EQ E     OR   
                     mseg-sobkz EQ Q        ).   
          MESSAGE E116.
        ENDIF.
        XLAUS = X.
        DATA X_LGORT LIKE MSEG-LGORT.
        X_LGORT = MSEG-LGORT.
        IF X_LGORT CA STERN.
          CLEAR MSEG-LGORT.
        ENDIF.
        IF NOT DM07M-EPRIO IS INITIAL AND DM07M-FAUSW+13(1) = MINUS.
          DM07M-FAUSW+13(1) = PUNKT.
        ENDIF.
*------ Chargenfindung über L_IM_BATCH_DETERMINATION_INT
        IF MSEG-CHARG CA STERN AND DM07M-KZECH EQ STERN
                               AND NOT VM07M-XCHPF IS INITIAL.
          PERFORM CHARGENBESTIMMUNG_WM_PP.
*------ Chargenfindung über VB_BATCH_DETERMINATION
        ELSEIF MSEG-CHARG CA STERN AND NOT DM07M-CHSMM IS INITIAL -> EXAMPLE:-CHSMM='ME0001'
                                   AND NOT VM07M-XCHPF IS INITIAL.     -XCHPF='X'
          PERFORM CHARGENFINDUNG USING F.
*------ Bestandsfindung über BF_STOCK_DETERMINATION
        ELSEIF NOT DM07M-EPRIO IS INITIAL AND       
               NOT DM07M-RULES IS INITIAL AND     
               MSEG-SHKZG = H AND    
               ( X_LGORT CA STERN OR ( MSEG-CHARG CA STERN AND
               ( NOT DM07M-XCHAR IS INITIAL OR MSEG-SOBKZ = O ) ) ).
          PERFORM BESTANDSFINDUNG.
        ELSE.
*-------- Storage location selection: No special stock allowed
          IF MSEG-SOBKZ <> SPACE.
            MESSAGE E116.
          ENDIF.
*------   alte Chargenfindung
          MOVE-CORRESPONDING DM07M TO MBEFU.
          MOVE-CORRESPONDING VM07M TO MBEFU.
          MOVE-CORRESPONDING MSEG TO MBEFU.
          PERFORM LAGERORTAUSWAHL(SAPFM07M) USING MSEG-MATNR
                                                  MSEG-WERKS
                                                  MSEG-SOBKZ
                                                  MSEG-LGORT
                                                  MSEG-SHKZG
                                                  MSEG-WERTU
                                                  MSEG-MENGU
                                                  FUSS-XNEPO.
...

refer to above code "PERFORM CHARGENFINDUNG USING F."

                                                              

... (MM07MFL0)
LOOP AT YLGORT WHERE NOT XSELP IS INITIAL.    
               INDEX_Z = INDEX_Z + 1.                      
               IF INDEX_Z = 1.                             
                 LIFNR = MSEG-LIFNR.                       
                 SOBKZ = MSEG-SOBKZ.                       
                 MOVE-CORRESPONDING YLGORT TO DM07M.        -> move data from function 'VB_BATCH_DETERMINATION'
                 MOVE-CORRESPONDING YLGORT TO VM07M.         to our 'well known' internal tables DM07M, VM07M, MSEG    
                 MOVE-CORRESPONDING YLGORT TO MSEG.          and later in FUSS
...

6 Comments

  1. Former Member

    @Fabio Almeida    @Haiko Emmerling

     

    Great post!

    I have a question about the code as follows

    IF MSEG-CHARG CA STERN OR MSEG-LGORT CA STERN.<- check if stock det.is active

    Is it means that if the MSEG-LGORT = *,the system will run the aotumatic stock determination procedure? if the MSEG-LGORT = 1000 or other,the system will NOT run the aotumatic stock determination procedure?


    We are using the SAP Retail solution,the POS Inbound Profile have defined a storage location 1000,and the MSEG-LGORT = 1000,takes from the POS Inbound Profile. 

    thus 1000 NOT CA *,the system don't run the aotumatic stock determination procedure  'PERFORM BESTANDSFINDUNG.'


    How to let the system run the 'PERFORM BESTANDSFINDUNG.' in my scenario?

    thanks.

     



    1. Hello Bei Tao!

      This code only applies to the old MBxx transactions, where the Stock / Batch Determination is triggered by entering a "*" in the Storage Location / Batch field.

      This does not apply to other transactions like MIGO, where the Stock Determination is triggered with an icon.

      You can set a breakpoint in BF_STOCK_DETERMINATION and see the different calls, depending on if the stock determination is made in MB1A with Storage location = * or in MIGO_GI with the icon.

      If you already send the Storage Location "0001" to the MM-IM interface, the Stock determination will not run, as there is nothing to be determined.

      I hope this helps a bit!

      Esther.

      1. Former Member

        hello Esther Hernanz! Thanks very much for you reply.

        I have found the souce code that running the automatic stock determination procedurein my scenario.

        it's  POS_CSGMT_IN,maybe it wil help who have problems in retail consignment process.

  2. Former Member

    Dear Haiko Emmerling,and Fabio Almeida,
    I need your help.I am a MM consultant,and thank you for looking at my comment.

    I am using the batch determination,bellow is my setting and steps:
    1.Access Sequences is ME01,and I prepare to use Condition Tables 021 Movement type/plant.
    2.The illustration is the configuration of strategy type ZYK1.


    3.I allocate strategy type ZYK1 to Search Procedure and to MVT 201.
    4.I create a batch search strategy (transaction MBC1) ,and I choose Movement Type/Plant.
    5.I allocate the batch class to the material EA1-012.
    6.When I use tcode MB1A to determine the batch,

    I get a message"No batches/stocks were found - (Batch) determination is performed online Message no. LB025",then I click the button "Selection criteria...",and I see the window like this,

    click Yes,

    then I click button "Bakc F3",and then I can get the correct batch result like this.


    7.If I choose "024 Movement type/plant/material" in the batch search strategy,there is no problem like step 6 said,and I can get the right result after entry "*" and click Enter.

    So why is there this problem choosing "021 Movement type/plant"?
    And we wouldn't like to allocte MBC1 to every material.

    Thanks very much.

     

    1. Hello Jack,

      The Stock / Batch Determination is triggered by entering a "*" in the Storage Location and also Batch field.

       

      If it is not happening properly, please implement the following notes:

      1770094 - Batch determination does not determine enough/any batches

      1829573 - Batch determination: Incorrect batches are determined

       

      If it does mot help you, please open a discussion in our SAP Comunnity or an incident to SAP under the component LO-BM.

      Kind Regards, Fábio Almeida - MM Consultant

      1. Former Member

        Hi Fabio Almeida,

        Thank you for your reply, I have found the reason of the problem.

        I missed the assignment of the selection criterial to the batch search strategy in MBC1, so I have to choose the criterial manually evrytime when issuing.

        I repaired the entry of Batch Search Strategy ZYK1, and assigned the Selection, and now I get the correct result which I want.


        thank you Fabio, forgive me for my carelessness.