For the opening stock we cannot use apply from entry as it only looks up negative (shipped) ILE lines which are open. When we enter opening stock thats a positve adjustment and here we are increasing stock from a return. Only thing I can think of is use a standalone credit . heres the filter on the field
local procedure SelectItemEntry(CurrentFieldNo: Integer)
var
ItemLedgEntry: Record "Item Ledger Entry";
SalesLine3: Record "Sales Line";
begin
ItemLedgEntry.SetRange("Item No.", "No.");
if "Location Code" <> '' then
ItemLedgEntry.SetRange("Location Code", "Location Code");
ItemLedgEntry.SetRange("Variant Code", "Variant Code");
if CurrentFieldNo = FieldNo("Appl.-to Item Entry") then begin
ItemLedgEntry.SetCurrentKey("Item No.", Open);
ItemLedgEntry.SetRange(Positive, true);
ItemLedgEntry.SetRange(Open, true);
end else begin
ItemLedgEntry.SetCurrentKey("Item No.", Positive);
ItemLedgEntry.SetRange(Positive, false);
ItemLedgEntry.SetFilter("Shipped Qty. Not Returned", '<0');
end;
OnSelectItemEntryOnAfterSetFilters(ItemLedgEntry, Rec, CurrFieldNo);
if PAGE.RunModal(PAGE::"Item Ledger Entries", ItemLedgEntry) = ACTION::LookupOK then begin
SalesLine3 := Rec;
if CurrentFieldNo = FieldNo("Appl.-to Item Entry") then
SalesLine3.Validate("Appl.-to Item Entry", ItemLedgEntry."Entry No.")
else
SalesLine3.Validate("Appl.-from Item Entry", ItemLedgEntry."Entry No.");
CheckItemAvailable(CurrentFieldNo);
Rec := SalesLine3;
end;
end;