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.
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!
Thank you for your feedback,
Ideally, it should work without any error
Thank you muchly. Sorted it out with our consultant! Happy New Year Ibrahem.
In 28/12/2020 how did you know total stock show in 91-120 v field? Please tell me the logic.
The column 91-120v value is getting calculated by calling report MB5B with intervals from 28.09.2022 to 28.08.2022
The below piece of code is executing the logic In include: ZMM_MAGE_FORM
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.
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
Great Buddy ! Thanks Lot!
Great job!!!!
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.
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.
Thank you ibrahim. But still same error. Can you try from your end might help.
Also i see another error.
What is the Netweaver version?
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.
Hello,
Goto -> Text Elements -> Selection Texts
Thank you ....
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.
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.
Ensure the order of the columns in the variant "/MAT_AGEING" is the same as the documentation in Github.
The characters for the decimal points are in wrong place ( , . ) This causes the report to show quantity of 100 pc as 100000 pc.
I found a solution. Temporary change of settings for user in SU3 parameters. Scripted to change, run report and change back.
Thank you for sharing this. this is of great help!
I am facing error - "ERROR IN PERIOD CHECK YOUR ABAP CODE" & unable to figure out the issue area.
Your guidance will be appreciated alot!
Thank you! Ibrahem Ahmed
Thank you Sweta Vishwakarma for your positive feedback
Check the content of table IT_CTRL, It should have one of the below values
00_30
31_60
61_90
91_120
121_150
151_180
181_360
thank you Ibrahem Ahmed for prompt response. Issue is resolved by changing when loop 181_366 to 181_360.
I am new in ABAP development, hence need your guidance to understand below set of code-
IF S_MATNR-LOW IS NOT INITIAL.
LOOP AT S_MATNR.
IS_RSPAR-SELNAME = 'MATNR'.
IS_RSPAR-KIND = 'S'.
IS_RSPAR-LOW = S_MATNR-LOW."'1000'.
IS_RSPAR-HIGH = S_MATNR-HIGH."'1000'.
IS_RSPAR-SIGN = S_MATNR-SIGN."'I'.
IS_RSPAR-OPTION = S_MATNR-OPTION."'EQ'.
append IS_RSPAR to IT_RSPAR.
clear : IS_RSPAR.
ENDLOOP.
ELSE.
IS_RSPAR-SELNAME = 'MATNR'.
IS_RSPAR-KIND = 'S'.
IS_RSPAR-LOW = '00000000000001'.
IS_RSPAR-HIGH = '99999999999999'.
IS_RSPAR-SIGN = 'I'.
IS_RSPAR-OPTION = 'BT'.
append IS_RSPAR to IT_RSPAR.
clear : IS_RSPAR.
ENDIF.
LOOP AT S_WERKS.
IS_RSPAR-SELNAME = 'WERKS'.
IS_RSPAR-KIND = 'S'.
IS_RSPAR-LOW = S_WERKS-LOW."'1000'.
IS_RSPAR-HIGH = S_WERKS-HIGH."'1000'.
IS_RSPAR-SIGN = S_WERKS-SIGN."'I'.
IS_RSPAR-OPTION = S_WERKS-OPTION."'EQ'.
append IS_RSPAR to IT_RSPAR.
clear : IS_RSPAR.
ENDLOOP.
if possible please explain the logic.
Thank you so much