Sunteți pe pagina 1din 13

2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki

  Getting Started Newsletters Store

Welcome, Guest  Login  Register Search the Community


 

Products Services & Support About SCN Downloads

Industries Training & Education Partnership Developer Center

Lines of Business University Alliances Events & Webinars Innovation

ERP SCM / … /  Goods Issue Processing
 
Stock and Batch Determination
Added by Haiko Emmerling, last edited by Haiko Emmerling on Apr 30, 2009

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. 

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)

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 1/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
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.

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

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 2/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
­ 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' 

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 3/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki

     

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

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 4/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
                  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   

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 5/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
0001                                   VEND1      K                         45,00                               45,000   
0001                                   VEND2      K                           5,00                               15,000

(the consignment price for vendor VEND1 is cheaper)
  

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

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 6/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
               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
http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 7/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
                                                  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.

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 8/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
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 

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 9/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki

Overview
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
http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 10/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
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 ).

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 11/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
              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.
http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 12/13
2/24/2015 Stock and Batch Determination ­ ERP SCM ­ SCN Wiki
          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
... 

 
No labels

Contact Us   SAP Help Portal
Privacy   Terms of Use   Legal Disclosure   Copyright         Follow SCN

http://wiki.scn.sap.com/wiki/display/ERPSCM/Stock+and+Batch+Determination 13/13

S-ar putea să vă placă și