Thursday, 11 April 2019

Physical Inventory with respect to WM

Overview Guide For Physical Inventory


Considering you have basic understanding of the process as discussed above let us jump in to the functional and technical process of the same.

Physical Inventory process varies with respect to MM and WM, in the upcoming steps we will show the same cycle with respect to WM Module.

Please note that am running a basic cycle below to have clear understanding of the process, however based on the different business scenario the cycle may become complex. Being said that understanding this basic cycle is very important to handle different scenarios, this document is sufficient enough to equip yourself to handle complex scenarios.

The entire cycle will be discussed in both functional and technical perspective.

Functional Cycle:


Now let us discuss the same steps as above in the functional point of view.

Before getting into the process I would like to show you the stock of the materials with respect to Bin that will be considered for this process. Below screen shots will display the LX03 report of the two materials that are considered. The same report will be displayed again at the end of the document to show the differences registered through the physical inventory process.

LX03 a T-Code used to check the stock at Bin Level.


Initial Screen will be as below where in you will be displayed with all the materials of that bin, you have to double click on each bin to see the stock for each material with respect to bin.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

First Article LX03 Report:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Second Article LX03 Report:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

◈ Creating Physical Inventory Document:

T-Code: LI01/LI01N

This is the T-code which will create the physical Inventory Document, the document number will be used as the reference further with respect to all the materials/Bins in them. The initial screen of the t-code will be as below.

Unlike MM cycle in WM we have a storage type concept. To keep it short we can only create physical inventory documents for set of all materials that belongs to same storage type. Materials belong to different storage types cannot be clubbed together in a single storage type.

Unlike MM cycle where we input only materials to create physical inventory document here we have to input only the Bins to which the material belong to create the Inventory document number. Here both the materials that are considered is of storage type 003, hence I input the same in the selection screen. Remaining inputs are only the warehouse number that is under consideration and the current date as shown below.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Once you proceed to next screen you will be provided with the option of inputting the respective Bin Numbers. Now we have to input bin against which we have planned to count the materials.

Storage Types Vs Materials Concept:

In case of Storage Types of a ware house there are few strategies that is maintained. A Storage Type can be considered as a Fixed bin which means a bin can only accommodate those articles that are assigned to the respective Bin. If you want a bin to consider other articles as well then we have to configure the storage type as Open storage. We are not going to discuss the configuration part here. However if we want to know the storage concepts for the different storage types under consideration we can check in the table T331 (Storage Type Control), the field STEIN (Putaway Strategy) will give the required information. The below image will give the information on all the values that can be maintained with respect to storage types.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Coming back to our cycle am considering only one bin to explain the cycle. As seen below am inputting the single bin.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Similar to MM cycle once the Bin is inputted and we press enter the screen will be prompted for next Bin entry and first bin entered will disappear. Below screen shot will explain the same, we can cross verify using the item count at the left. The only condition here is all the bins that we enter must belong to same storage type. Also considering the performance the bin count can be up to 1000 in one document. Being said that our WM system will manage itself to create different inventory numbers based on the count of bins entered.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Once we are sure that all the required bins have been entered then we can save which leads to a confirmation message as below that inventory document is created at bottom.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

◈ Changing Physical Inventory Document:

T-Code: LI02/LI02N

Enter the Inventory document entered before and proceed onto the next screen as shown below.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

If you want to make any changes like either Adding/Deleting the entries in the document we can do the same.

Post making the change we need to activate the Document Number to make it eligible for the count, the below screen shot marks the icon for activation.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Once the inventory document is activated we will get an information message at the bottom.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

◈ Counting Physical Inventory Document:

Now we should be good to proceed ahead with counting as we are sure on the materials as part of the process. The T-code used for counting is LI11N.

Enter the inputs as per the screen shot below, and proceed ahead. Screen shots below for your reference.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Now if you see above screen although we input only the bin number, system itself has retrieved all the materials linked to the bin and brought back the entries to us for entering the quantity of the materials. Here our intention is to count only two materials in other words this is also intimating the system that we have only these two materials in the bin and remaining materials are not present in the bin now.

As discussed above this storage type is configured as an open storage hence it will allow other materials other than the linked materials.

Also to indicate the system that any material that is linked with the bin is not present now we have to check the Zero Indicator as marked in red below. For remaining materials we shall proceed to enter the quantity. If you see the below case since we do not find any material other than what we are intended to count we need not mark Zero Indicator.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

For adding any new entry other than the material linked click on New Item button (Marked in Green Above). You will be navigated to below screen. Before reaching this screen you will be asked to confirm the values entered before by intimating the differences between the book quantity and quantity entered as shown below. Confirm the same by clicking Enter and proceed.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Next you will be navigated to below screen.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Now enter the bin on which you want to add the material and the quantity, in our case am using the same bin. Remember this bin you enter must be of same storage type. You have to input following details for the new Entry.

1. Material Number
2. Quantity
3. Plant
4. GR Date

After input we will be asked to confirm the same, post which we will be navigated to the same screen as before (Shown Below for Reference). In case if any material added they will get displayed here as well. For our cycle we don’t add any material.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Once we are sure about the data entered save and proceed. This will confirm us that the inventory document is counted as shown below:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Thus we have completed the counting process of the cycle.

◈ Clearing the differences at WM Level:

T-Code: LI20

In this step we clear the differences between the book quantity and quantity entered. To understand this step in more detail please follow the steps.

1. The quantity counted against each material is first written into a temporary storage type.
2. In our case storage type used for this is 999.
3. Step “A” is performed once we write of using T-code LI20 as explained below.

Now input the below inputs in the initial screen of LI20 and proceed,

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Once you enter the next screen you will be displayed with all the articles that are part of the count, confirm by clicking the checkbox at left (Marked in Green Below) and proceed to write off (Marked in Red Below).

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Once you write off you will get a confirmation as shown below in the bottom.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

◈ Clearing the differences at Inventory Management Level:

T-Code: LI21

As discussed in above steps we have now cleared all the differences, at IM level now all these materials will be present at storage type 999.

Now by writing off the quantity we push the quantity from storage type 999 to the respective locations, this also ensures the financial postings are done at the same time.

Input your initial screen as shown below:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Please note above in place of storage bin you have to enter the inventory document number generated. In the next screen you will be displayed with all the line items and provision for write off (Marked in Red Below).

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Do not get confused with the above available stock, they just depict the difference between the existing stock and the stock that is counted now. In our case consider first material the value was 790 and we have entered as 500 so the difference is 790-500 which is 290. This is the value that is displayed above. The same is the case for second material.

Once the required line items are selected and written off we can see that the Write off has been done at IM level also and a Material document will be generated to display the Financial Postings. This also confirms that on the successful Financial postings and the quantity will now be reflecting in the system. Below screen shot shows the successful execution of the step.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Now we can check the system quantity through MMBE and MB5B reports as shown below.

First Article LX03 Report:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Second Article LX03 Report:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Technical Cycle:

Now since we have better understanding about the functional cycle, achieving the same requirement through technical program will be easy to understand.

If you follow above process, we did the entire cycle with just two articles. Hence forth the complete cycle can be completed in very short span. Consider if we have more than 50K Zones/Materials to count either within the same storage location or with different storage location or sometimes may be with different plants as well. In this completing the entire cycle as discussed above is going be a staggering task, none of us in our organization will be given that much time to complete this cycle through the process discussed above. Henceforth programming the entire cycle and bringing the process into the technical world is very important and also helps us in finishing the cycle real quick.

As discussed above the maximum time that will be taken during the cycle will be only during creation of physical inventory document and counting the same. The rest of process like clear off and postings can actually happen real quick since we can process all in the same screen as discussed above.

So in this technical discussion am going to elaborate to accomplish creating the inventory document and counting the same. One key factor here is just ensure you always input correct quantity to be posted just to avoid detour and save time.

The first step of the technical implementation is collecting the data into an internal table. This purely based on the business scenario. You can either collate the data in an excel and later you can convert into an internal table or you can record the data in a custom table pick it up from there directly into an internal table. Now considering the humongous data is there in our internal table let us discuss how we accomplish it through code.

We assume that we have below data in our initial Internal table:

◈ Materials
◈ Respective Bin Number
◈ Storage Type
◈ Quantity
◈ UOM

Pre-Requisites

◈ There should not be any open transfer orders, all the transfer orders must be cleared.
◈ In case of Fixed bins proper materials assignment must be made.
◈ Bin strategy must be properly planned

First step: Creating Physical Inventory Document Number (LI01)

Like MM Inventory Cycle we have any entries restriction for better performance and also the system has the capability itself to create distinct inventory documents based on the data that is being passed.

One Key Point we need to ensure is, similar to the functional cycle we need to ensure here that we enter all the bins that belong to same storage type. Hence technically we need to group data with respect to storage types, this is usually achieved by using control break statements on the storage type field (LGTYP) as shown below.

AT END OF lgtyp.

Technically this step of creating inventory document is achieved via BAPI as shown below:

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Now let us discuss on what needs to be fed to the BAPI for successful creation of Inventory document number.

Field Values 
IV_LGNUM   Warehouse number
IV_LGTYP   Storage Type 
IV_KZINV Inventory indicators 
IV_IRNUM   Inventory indicators 
IV_LIAKT   Activate inventory list immediately 
IV_UNAME  Name of Counter 
IV_PDATU   Planned date for inventory count 
IV_ANPLB Number of storage bins per inventory document 
IV_HNDLE   Application Log: Log Handle (Used for Handling Errors) 

Table IT_LAGP

Feed in the below values alone into the table IT_LAGP.

◈ Warehouse Number / Warehouse Complex
◈ Storage Type
◈ Storage Bin

When all the values as discussed above are passed successfully, immediately the BAPI creates Inventory Document and activates it as well. This covers our first two steps in functional cycle.

There are few concepts that we need to understand going forward which is very important before calling the count BAPI. Before calling the count bapi we need to fill in the data for that BAPI, this involves inputting the quantity value also we may be needing to add new material itself on special cases as explained below.

When all the Bin Numbers are passed the BAPI return all the Materials linked with each bin in the Internal Table LT_LINV_VB. Similar to what we discussed in the above functional cycle they return back all the materials linked with the bins however we may also be needing to add other materials as well which are not linked with Bin. In those cases considering the concept “Storage Types Vs Materials Concept” as discussed above we need to explicitly add those materials provided the bin is not a Fixed Bin. If the Bin is fixed we cannot any other material other than the linked materials in the bin.

For all other entries where in the BAPI itself returned with the Materials we just need to update with the respective quantity.

Second step: Counting Physical Inventory Document Number (LI11)

Before counting the materials with respect to the bins we need to consider few points while coding. Below is the bapi that is called for counting.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

Below are the Key points that must be considered for coding:

◈ I_COMMIT parameter must be always true which will enable our counted inventory document active and stop system to create any other inventory document for the same data under process.

◈ The Field ALLE_IVNUM will be holding the newly generated inventory Number value if count is successful.

◈ The table LT_LINVX will be the one where we pass the materials along with quantity value.

◈ Basically all the values retrieved from internal table LT_LINV_VB in step one must be passed on to the table LT_LINVX with the quantity value for the respective material.

◈ In addition to materials from LT_LINV_VB we must also add if there are any materials in our initial internal table other than the entries retrieved from step 1 while creating inventory number.

◈ While adding entries to LT_LINVX do remember below key points:

◈ Feed the below field values for each entry into the table LT_LINVX.

- Materials
- Plant
- Batch (If there is any)
- Quantity
- Counted UOM
- Storage Location
- Username
- Material again in field MATNR_LONG

◈ Below screen shot is given for reference

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

◈ We must also pass on certain date fields like GR data (WDATU) and Expiration date (VFDAT). These field values like Dates and Batch value can be taken from table LQUA.

◈ Either if the material is empty or the zone itself is entry the we need to populate the field KZNUL as X. Screen shot below for reference when quantity is Zero we are marking KZNUL field as X.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Guides

◈ There can be scenarios where in there are no materials linked with the Bin inputted also there are no materials in our initial internal table as well. In these cases we must input the bin number along with the field KZNUL marked as X into the table LT_LINVX.

◈ There can be a case where our Step 1 Bapi would have returned the bin without any material linked to it but we may have material entries in our initial internal table to be added to the same Bin. In those cases do not mark the Field KZNUL as X for that bin and proceed to add the entry from our initial internal table to the table LT_LINVX.

◈ Considering the storage bin as open Bin as discussed in “Storage Types Vs Materials Concept” above, system will understand that we are trying to add new materials to the bin even though there are no linked materials to the bin.

◈ Even in cases where the Bins posses materials linked with it and we have additional materials in our initial internal table to be added, the same “Storage Types Vs Materials Concept” will be used and the additional materials can be added to the same bins.

Considering all the above key points has been covered successfully we may now feed the data into the count BAPI and check the status. Once the data is successfully processed our inventory number has passed through the counting phase of the cycle successfully.

We are now only left with WM Write Off (LI20) and IM Write off (LI21) as discussed above in the functional cycle.

During this process there are few issues that are very common returned by BAPI. I would like to highlight those and their remedies. This would aid you during your implementation.

◈ Material Lock Issue: Ensure that the material is not in use in any other transaction, this would stop us from creating the inventory document.

◈ Material Does not Exist with respect to storage Location: This error occurs when the materials are not extended to the subjective storage location. You have to ensure the storage location is extended.

◈ Few Master Data Errors with Respect UOMs and other parameters.

◈ An inventory Document already exist: This Happens when there are certain inventory documents already existing for the same Bins that we are processing now. The former inventory documents must be cleared first before processing the current data.

The issues discussed above are common issues that can be handled easily.

Thus we complete the WM Inventory cycle both through Functional cycle and Technical cycle. Hope this document helps to understand the concepts better.

Few Important T-codes For Quick Reference:

LI01/LI01N –> Creation/Activation of Physical Inventory Document
LI02/LI02N –> Changing/Activating Physical Inventory Document
LI11/LI11N –> Counting Physical Inventory Document
LI12/LI12N –> Changing Physical Inventory Document Count
LI20            –> Clearing Difference in WM Level
LI21            –> Clearing Difference in IM Level
LX03          –> Bin Level Stock Report
LS26          –> Stock overview
LS03          –> Storage Bin Details
LS24          –> Stock Per Material
LX20          –> Bins Report with respect to Ware House

Important Tables:

LAGP –> Storage bins

LINK  –> Inventory document header in WM

LINP  –> Inventory document item in WM

LINV  –> Inventory data per quant

LQUA  –> Quants

LTAK  –> WM Transfer Order Header

LTAP  –> Transfer Order Item

T331  –> Storage Type Control

T303  –> WM Storage Bin Types

T343  –> Storage Bin Structure for Automatic Creation of Storage Bins

No comments:

Post a Comment