I wanted to do a follow up to this. Setting the Reserve field to "Optional" (as I documented below) addressed the majority of my issues in this situation.
But I also found that if Reservation Entries were made against a Sales Order, and then the Order Qty was increased to exceed the Available Inventory calculation for the item, it made (or kept) a partial Reservation (which we do not want). Only 100% of the Order Qty can be Reserved, or nothing should be Reserved.
So I needed to come up with a way to Cancel the Reservations that were partial. Simply deleting the Reservation Entry (demand) records for the Sales Order line was not working, since it was orphaning the related Supply entries (e.g., Item Ledger Entries). This was causing OnHand availability issues, as the supply record still existed when the demand record was deleted.
What I found was there is a CodeUnit "Reservation Engine Mgt." (99000831) that handles the "Cancel Reservation" functionality in the Reservation Worksheet. More specifically, the procedure "CancelReservation" does all the work.
All I had to do in my SalesOrderSubForm page was to add the following code, which calls the CodeUnit & procedure:
procedure CancelReservationEntries()
var
SOReservEntry: Record "Reservation Entry";
ReservEntry: Record "Reservation Entry";
EntryNo: Integer;
begin
SOReservEntry.SetRange("Source ID", Rec."Document No.");
SOReservEntry.SetRange("Source Ref. No.", Rec."Line No.");
if SOReservEntry.FindSet() then
repeat
EntryNo := SOReservEntry."Entry No.";
ReservEntry.SetRange("Entry No.", SOReservEntry."Entry No.");
if ReservEntry.Find('-') then
repeat
ReservEntry.TestField("Reservation Status", ReservEntry."Reservation Status"::Reservation);
ReservEntry.TestField("Disallow Cancellation", false);
begin
ReservEngineMgt.CancelReservation(ReservEntry);
Commit();
end;
until ReservEntry.Next() = 0;
until SOReservEntry.Next() = 0;
end;
protected var
ReservEngineMgt: Codeunit "Reservation Engine Mgt.";
I call this procedure when the Order Line encounters a partial Reservation, and both the supply and demand reservations get cancelled. This approach seems to work for me.