You are on page 1of 19

Stock and Batch Determination

Skip to end of metadata

Created by Haiko Emmerling, last modified by Fabio Almeida on Dec 11, 2015

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


Stck determation rule
Description

G001
R001
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

0001

0002

0001

0002

(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

Priority

Storage loc.

Valuation type
F

0001

0002

0001

0002

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

Vendor consignment in

170,000

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
Available quantity

Vendor

0001
170,000

determ.quan.
100,000

0002
80,000
0001
45,000

VEND1

0001
15,000

VEND2

b) Quantity = 200:
SLoc Batch
Val. Type
Available quantity

Vendor

determ.quan.

0001
170,000

170,000

0002
80,000

30,00

0001
45,000

VEND1

0001
15,000

VEND2

Vendor

c) Quantity = 300:
SLoc Batch
Val. Type
Available quantity
0001
170,000

determ.quan.
170,000

0002
80,000

80,00

0001
45,000

VEND1

45,00

0001
15,000

VEND2

5,00

(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.
det.is active

<- check if stock

This is the best place for a break-point


* Charge/Lagerort * bei Stcklisten (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

mseg-sobkz EQ E

OR

All other spec.stocks

LGORT=*
will
mseg-sobkz EQ Q

).

M7116.
MESSAGE E116.
ENDIF.
XLAUS = X.
DATA X_LGORT LIKE MSEG-LGORT.
X_LGORT = MSEG-LGORT.

Cause

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
EPRIO='G001'

-> EXAMPLE:-

NOT DM07M-RULES IS INITIAL AND


-RULES='R001'
MSEG-SHKZG = H AND
=>Only goods issues!!!

-> -SHKZG = H

( 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.
function 'BF_STOCK_DETERMINATION'

-> move data from

MOVE-CORRESPONDING YLGORT TO VM07M.


internal tables DM07M, VM07M, MSEG

to our 'well known'

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
==> Batch Search Procedure Definition

(3)

==> 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
batch

Movement type text S Special stock descr.

502

RE receipt w/o PO

Search Check
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
step 2)

(customizing

- 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.
det.is active

<- check if batch

This is the best place for a break-point


* Charge/Lagerort * bei Stcklisten (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

MSEG-SOBKZ EQ E

OR

MSEG-SOBKZ EQ Q

OR

MSEG-SOBKZ EQ K

OR ).

Cause M7116.

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.
function 'VB_BATCH_DETERMINATION'

-> move data from

MOVE-CORRESPONDING YLGORT TO VM07M.


internal tables DM07M, VM07M, MSEG

to our 'well known'

MOVE-CORRESPONDING YLGORT TO MSEG.

and later in FUSS

You might also like