Hello all,
I've created a report for finished goods in the Item table. I also need to get the average of the next six months of the Forecast Quantity field in the Production Forecast Entry table, not counting the current month.
Since it is December the average for one month would be for the months January - June. On January 1st, the average should automatically calculate the average for February - July automatically when the report is run.
Can anyone help with that code snippet? I've worked on this quite a bit with limited success. Thanks much for any help.
0
Answers
Thanks
This is assuming you use the item table. But you would change the fields to the production forecaste table.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
SETRANGE("Forecast Date",CALCDATE('+7M-CM-1D',WORKDATE),CALCDATE('+1M-CM',WORKDATE));
AverageQty := ROUND("Forecast Quantity" / 6);
Thanks - Chris
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
I have not created a total like this...
Check out how to use the REPEAT loop in this forum or in the C/Side help.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
I may be screwed up with my dataitems too...Right now I have the Item dataitem at the top level with Production Forecast Entry linked by the Item No. Maybe it would be wise to use integer and create record variables?
No worries if there are no replies, you learn more through being stumped.
Nonetheless, please check out the C/Side Application Designer's guide to gain more familiarity with NAV development.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
I figured out where I was going wrong...the following date filter was suggested:
SETRANGE("Date Filter",CALCDATE('+7M-CM-1D',WORKDATE),CALCDATE('+1M-CM',WORKDATE);
I didn't notice how the start/end dates were...I swapped the CALCDATES and coded something like the following that worked great.
ProdForecastEntry.RESET;
ProdForecastEntry.SETRANGE("Item No.","No.");
ProdForecastEntry.SETRANGE("Forecast Date",CALCDATE('+1M-CM',WORKDATE),CALCDATE('+7M-CM-1D',WORKDATE));
IF ProdForecastEntry.FINDSET THEN BEGIN
REPEAT
AverageQty := AverageQty + ProdForecastEntry."Forecast Quantity"
UNTIL ProdForecastEntry.NEXT = 0;
AverageQtyDivided := AverageQty/6; //etc, etc, etc
I apologize for any confusion and am happy with the end result. Thanks for your help, I will put solved in the title.
Happy New Year! Chris