...
SalesLine.SETCURRENTKEY("Document Type","Blanket Order No.","Blanket Order Line No.");
SalesLine.SETRANGE("Blanket Order No.",BlanketOrderSalesLine."Document No.");
SalesLine.SETRANGE("Blanket Order Line No.",BlanketOrderSalesLine."Line No.");
QuantityOnOrders := 0;
IF SalesLine.FINDSET THEN
REPEAT
...
...
SalesLine.SETCURRENTKEY("Document Type","Blanket Order No.","Blanket Order Line No.");
SalesLine.SETRANGE("Blanket Order No.",BlanketOrderSalesLine."Document No.");
SalesLine.SETRANGE("Blanket Order Line No.",BlanketOrderSalesLine."Line No.");
SalesLine.SETFILTER(
"Document Type",'<>%1&<>%2', SalesLine."Document Type"::Invoice,
SalesLine."Document Type"::"Credit Memo");
QuantityOnOrders := 0;
IF SalesLine.FINDSET THEN
REPEAT
...
...
QuantityOnOrders := 0;
IF SalesLine.FINDSET THEN
REPEAT
IF SalesLine."Document Type" IN
[SalesLine."Document Type"::"Return Order",
SalesLine."Document Type"::"Credit Memo"]
THEN
QuantityOnOrders := QuantityOnOrders - SalesLine."Outstanding Qty. (Base)"
ELSE
QuantityOnOrders := QuantityOnOrders + SalesLine."Outstanding Qty. (Base)";
...
...
QuantityOnOrders := 0;
IF SalesLine.FINDSET THEN
REPEAT
IF SalesLine."Document Type" = SalesLine."Document Type"::"Return Order" THEN
QuantityOnOrders := QuantityOnOrders - SalesLine."Outstanding Qty. (Base)"
ELSE
QuantityOnOrders := QuantityOnOrders + SalesLine."Outstanding Qty. (Base)";
...