Microsoft Dynamics 365 Blog
First, lets review the foundation here … lets review what the “Supply Planning White Paper” mentions:
Demand is the common term used for any kind of gross demand, such as sales order and component need from a production order. In addition, the program allows more technical types of demand, such as negative inventory and purchase returns
Planning parameters and inventory levels are other types of demand …
Checking the CU 99000854, what is a demand for NAV planning engine?
a. Sales Orders
b. Service Orders
c. Planned Production consumption
d. Transfer orders
The actual code to find the data considered as demand can be found on the DemandToInvProfile procedure in CU 99000854.
As an example …
a. sales orders are being considered as demands by using this query:
SalesLine.SETCURRENTKEY(Type,”No.”,”Variant Code”,”Drop Shipment”,”Location Code”,”Document Type”,”Shipment Date”);
SalesLine.SETFILTER(“Document Type”,’%1|%2′,SalesLine.”Document Type”::Order,SalesLine.”Document Type”::”Return Order”);
Item.COPYFILTER(“Location Filter”,SalesLine.”Location Code”);
Item.COPYFILTER(“Variant Filter”,SalesLine.”Variant Code”);
SalesLine.SETFILTER(“Outstanding Qty. (Base)”,’<>0′);
SalesLine.SETFILTER(“Shipment Date”,’>%1&<=%2′,0D,ToDate);
b. service orders …

ServiceLine.SETCURRENTKEY(Type,”No.”,”Variant Code”,”Location Code”,”Posting Date”);
ServiceLine.SETRANGE(“Document Type”,ServiceLine.”Document Type”::Order);
Item.COPYFILTER(“Location Filter”,ServiceLine.”Location Code”);
Item.COPYFILTER(“Variant Filter”,ServiceLine.”Variant Code”);
ServiceLine.SETFILTER(“Outstanding Qty. (Base)”,’<>0′);
ServiceLine.SETFILTER(“Posting Date”,’>%1&<=%2′,0D,ToDate);
c. production order consumption …
ReqLine.SETCURRENTKEY(“Ref. Order Type”,”Ref. Order Status”,”Ref. Order No.”,”Ref. Line No.”);
ReqLine.SETRANGE(“Ref. Order Type”,ReqLine.”Ref. Order Type”::”Prod. Order”);
ProdOrderComp.SETCURRENTKEY(“Item No.”,”Variant Code”,”Location Code”,Status,”Due Date”);
ProdOrderComp.SETRANGE(“Item No.”,Item.”No.”);
Item.COPYFILTER(“Location Filter”,ProdOrderComp.”Location Code”);
Item.COPYFILTER(“Variant Filter”,ProdOrderComp.”Variant Code”);
ProdOrderComp.SETFILTER(“Due Date”,’>%1&<=%2′,0D,ToDate);
and so on with other type of demands like planned consumption (check DemandToInvProfile procedure).
For any of these “queries”, the exact filters used should be analyzed. For instance, sales line considered are those which have a shipment date equal or earlier than the planning ending date … regardless of the status in the sales order.

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!