Skip to Content
Author's profile photo Ibrahem Ahmed

Inventory Ageing ABAP report

Recently I came across the requirement to get inventory ageing directly from SAP ERP 6.0 instead of calculating it on excel sheets with batch isn’t configured.

As a prerequisite, the company is using the FIFO method for ageing. So I used T-Code: MB5B to get stock value and quantity on a specific date.

How MB5B works.

MB5B is calculating stock on a specific date by reversing the usual equation of stock calculation

Ending balance = Begining balance + Input – Output

Current stock is known by kept on MBEW-LBKUM and value on MBEW-SALK3 and Input and output is known by material documents so we are left with only one unknown variable “Begining Stock” which is equivalent to “Stock on earlier date”. so the stock equation will be

Stock on earlier date = Ending Balance ( Current Stock ) – In + Out

 

How is inventory ageing works

Based on the date in the selection, the ageing report will calculate the beginning date and end date for each interval and submit these parameters to MB5B along with material code and plant code, then the result will be retrieved to the ageing report and processed to be displayed in the ALV.

Report screenshots

How to create the report

The full illustration of how to create the report is available on the Github

 

 

Thanks for reading.

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Simone Milesi
      Simone Milesi

      Really nice work.

      In 14 years of experience, i always find customers developing this kind of reports for their specific needs  and your github project is a good start for further customization!

      Author's profile photo Norbert Jarzynka
      Norbert Jarzynka

      An incredible report! Thank you so much, saved us a ton of work. If you're still out there, is there a way to change this report so that it accepts the alphabetic characters? Our factory uses letters in some material codes of the finished product. I am not an ABAPer but I know how to alter the code, just need a pointer of where it is constrained. Any help would be greatly appreciated. Best regards from UK!

      Author's profile photo Ibrahem Ahmed
      Ibrahem Ahmed
      Blog Post Author

      Thank you for your feedback,

      Ideally, it should work without any error

      Author's profile photo Norbert Jarzynka
      Norbert Jarzynka

      Thank you muchly. Sorted it out with our consultant! Happy New Year Ibrahem.

      Author's profile photo Thennarasu Kandasamy
      Thennarasu Kandasamy

      Hi

      Sorry unable to understand the logic. Please tell me the logic if I want to calculate the stock which are above 3, 6 months and 12 Months .

      Is this formula work Stock on earlier date = Ending Balance ( Current Stock ) – In + Out

      Author's profile photo Ibrahem Ahmed
      Ibrahem Ahmed
      Blog Post Author

      Take for example below stock movement for one material code.

      Date Qty Balance Comment
      01.01.2020 100 100 In
      01.02.2020 -30 70 Out
      01.03.2020 -10 60 Out
      01.04.2020 60 120 In
      01.05.2020 -15 105 Out
      01.06.2020 -40 65 Out
      28.09.2020 -10 55 (Current Stock) Out

      applying the above formula to get the stock on 01.03.2020

      Stock on 01.03.2020 = Current stock – In + Out

      Stock on 01.03.2020 = 55 – 60 + 10 + 40 + 15 = 60

       

      Author's profile photo Thennarasu Kandasamy
      Thennarasu Kandasamy

      Great Buddy ! Thanks Lot!

      Author's profile photo SAPAMS BASIS
      SAPAMS BASIS

      Great job!!!!

      Author's profile photo Andrew victoria
      Andrew victoria

      Incredible idea!.

      Thanks for sharing ibrahim. Its very useful report.

      I am getting error while activating the program. Can you share your input,

      I have created following

       Report  ZMM_MAGE2

      INCLUDE ZMM_MAGE_TOP2.

      INCLUDE ZMM_MAGE_FORM2.

       

       

      Thanks.

      Author's profile photo Ibrahem Ahmed
      Ibrahem Ahmed
      Blog Post Author

      Hello Andrew,

      The P_EXTEND variable is defined in the TOP include.

      There was a naming mistake in the last commit and I've fixed it.

      Just rename the include ZMM_MAGE_TOP2  ZMM_MAGE_TOP and ZMM_MAGE_FORM2 to ZMM_MAGE_FORM and it will work just fine.

      Author's profile photo And V
      And V

      Thank you ibrahim. But still same error. Can you try from your end might help.

       

      Also i see another error. 

       

      Author's profile photo Ibrahem Ahmed
      Ibrahem Ahmed
      Blog Post Author

      What is the Netweaver version?

      Author's profile photo And V
      And V

      Thanks Ibrahem. Your reports meet exact my requirement . 

      Tried with another server. Looks fine.

      Need your advise, trying to change label same like your screenshot but could not. Can you give me any heads-up on this. 

      Current Screen in which i need to change S_MATNR to Material same like your screen below. 

       

      Author's profile photo Ibrahem Ahmed
      Ibrahem Ahmed
      Blog Post Author

      Hello,

       

      Goto -> Text Elements -> Selection Texts

       

      Author's profile photo And V
      And V

      Thank you ....

      Author's profile photo And V
      And V

      Hi Ahmed,

      Trying to fix this error, Netweaver version is 7.40 SP LEVEL 004.

       

      What is wrong with this line .

       

      One more thing i did noticed in MB5B ALV GRID is missing. Is this error pertains to ALV GRID ?

       

       

      Any idea ?

       

       

      Author's profile photo And V
      And V

      Team anyone else achieved the desired output with below Netweaver 7.40 version. Please share your input to debug the error.

      Author's profile photo Rajesh Rathi
      Rajesh Rathi

      I tried this report with my ABAPER , but qty & value not showing properly. value is not coming .. only qty is showing .. also if stock is 100 qty then it should display in day range but only some qty is showing in day range  .. please send me updated code.

      Author's profile photo Ibrahem Ahmed
      Ibrahem Ahmed
      Blog Post Author

      Ensure the order of the columns in the variant "/MAT_AGEING" is the same as the documentation in Github.