LOCAL PROCEDURE CloseTracking@92(ReservEntry@1000 : Record 337;VAR SupplyInventoryProfile@1001 : Record 99000853;ToDate@1002 : Date) : Boolean;
VAR
xSupplyInventoryProfile@1003 : Record 99000853;
ReservationEngineMgt@1004 : Codeunit 99000831;
Closed@1005 : Boolean;
WITH ReservEntry DO BEGIN
IF "Reservation Status" <> "Reservation Status"::Tracking THEN
EXIT(FALSE);
xSupplyInventoryProfile.COPY(SupplyInventoryProfile);
Closed := FALSE;
IF ("Expected Receipt Date" <= ToDate) AND
("Shipment Date" > ToDate)
THEN BEGIN
// tracking exists with demand in future
SupplyInventoryProfile.SETCURRENTKEY(
"Source Type","Source Order Status","Source ID","Source Batch Name","Source Ref. No.","Source Prod. Order Line",IsSupply);
SupplyInventoryProfile.SETRANGE("Source Type","Source Type");
SupplyInventoryProfile.SETRANGE("Source Order Status","Source Subtype");
SupplyInventoryProfile.SETRANGE("Source ID","Source ID");
SupplyInventoryProfile.SETRANGE("Source Batch Name","Source Batch Name");
SupplyInventoryProfile.SETRANGE("Source Ref. No.","Source Ref. No.");
SupplyInventoryProfile.SETRANGE("Source Prod. Order Line","Source Prod. Order Line");
SupplyInventoryProfile.SETRANGE("Due Date",0D,ToDate);
IF NOT SupplyInventoryProfile.ISEMPTY THEN BEGIN
// demand is either deleted as well or will get Surplus status
ReservMgt.CloseReservEntry(ReservEntry,FALSE,FALSE);
Closed := TRUE;
END;
END;
END;
SupplyInventoryProfile.COPY(xSupplyInventoryProfile);
EXIT(Closed);