Skip to Content

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.

You must be Logged on to comment or reply to a post.
  • 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!

  • 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!

  • 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

    • 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


  • 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






    • 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.

  • /
      • 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. 


    • 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 ?



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