Not sure if you are familiar with this. But, I believe it worths covering it …
During NAV planning, the logic goes through different steps in the planning cycle: StartOver, MatchDates, MatchQty, CreateSupply, ReduceSupply, CloseDemand, CloseSupply, CloseLoop. All these steps are being performed on the PlanItem procedure from CU99000854. The way planning goes through each of these steps depends on the reordering policy. But basically:
First state is StartOver which determines if there is any demand to plan for. If so, it try to determines if there is any supply. If this is the case, next state would be MatchDates. If no supply exists, next state would be CreateSupply. If there is no other demand to plan for, next state would be ReduceSupply (if any exists) or CloseLoop (to finalize the loop through all states).
MatchDates state. This is about matching demand and supply dates to make sure that both can be plan together (ie. supply can be used to meet demand). If cannot be met, next state would be CreateSupply (another supply needs to be created). If it can, the existing untracked quantity in the supply needs to be reduced and state would be ReduceSupply.
MatchQty state. If supply quantity is not enough, it needs to be closed (no more available) through CloseSupply state. If this is a supply where quantity can be increased, then CloseDemand state can be next.
CreateSupply state. This is the step where supply will be created depending on the policy.
ReduceSupply state. Here, the untracked (unnecessary) quantity will be reduced from the supply. Next state would be to close the supply.
CloseDemand state. In here, the demand will be closed which means that demand has been planned for. The next thing (state) to do here would be StartOver to start the planning of another demand.
CloseSupply state. This is similar than CloseDemand state but from the supply perspective. If supply has been entirely planned, another supply needs to be considered and StartOver state will be next.
CloseLoop state. This is where planning finalizes. Before doing that, it will determine if ROP has been crossed. If so, it will be planned for again by going through the StartOver state.
Hopefully someone finds the above info useful. Think about a sequence of steps before plan can be considered as finalized. These sequences of steps are being done in the PlanItem procedure through a WHILE loop until plan is done.
This is not to use it but to test it. Yeap, this is a disclaimer so reader knows that testing should always be done.
What I would like to cover here is how to integrate MRP with Jobs so material required for jobs create action messages. Before that, lets see how CU99000854 determines where the demands are coming from. This is done on function DemandToInvProfile. Here it goes through the different types of demand (Service, Sales, Production, …) and make planning aware of them.
Back to our case, this same function is where we need to add code so MRP is aware that Job Planning Lines carry demands (material requirements). As an example, the piece of code we could consider is the following:
JobPlanningLine.SETCURRENTKEY(Type,”No.”,”Variant Code”,”Location Code”,”Planning Date”);
Item.COPYFILTER(“Location Filter”,JobPlanningLine.”Location Code”);
Item.COPYFILTER(“Variant Filter”,JobPlanningLine.”Variant Code”);
IF JobPlanningLine.FIND('-') THEN
InventoryProfile."Line No." := NextLineNo;
IF InventoryProfile.IsSupply THEN
UNTIL JobPlanningLine.NEXT = 0;
What we are doing above is using the job planning lines of type "Item" to be considered as demand and use the planning date as due date for the demand.
Going forward, reader could take it from here to finalize the development.
This is a frequent question from out there: how could I determine if Average cost is correct? How NAV calculates this average?
The simple answer is: average cost is determine by the following formula through value entry table: (sum of actual cost + sum of expected costs) / (sum of item ledger entry quantity). This will provide the average cost (unit cost) when Adjust cost is run.
And, how NAV calculates this average cost for a specific date? This is done by ordering the value entries by valuation date. This date is when entry is valued. Thus, we need to order the entries how they are valued. Once this is done, next order to consider is: inbound entries first, outbound entries next. In other words: we calculate the average cost by using the positive entries and we then deduct the value of the outbound entries to find out the final average cost on that given date
(ItemJnlLine.Amount + ItemJnlLine."Discount Amount") / "Invoiced Quantity",
GLSetup."Unit-Amount Rounding Precision");
b. CU5804 (proc. UpdateUnitCost). This updates "Unit Cost" and "Last Direct Cost" in item card. Here, we could determine how/when to update this.
IF ("Unit Cost" = 0) OR ((InvoicedQty > 0) AND (LastDirectCost <> 0)) THEN BEGIN
CALCFIELDS("Net Invoiced Qty.");
IF ("Net Invoiced Qty." > 0) AND ("Net Invoiced Qty." <= InvoicedQty) THEN
"Unit Cost" := LastDirectCost;