Lot No does not work when it is generated by code in transfer lines

MuazDeyabMuazDeyab Member Posts: 1
I am creating transfer order by code and it works but i want to assign lot no also i wrote this code

procedure AssignLotNO(transLine: Record "Transfer Line")

var
EntryNo: Integer;

begin

if LastTRackingSPecs.FindLast() then
EntryNo := LastTRackingSPecs."Entry No." + 1;


GetItem(transLine."Item No.");

TRackingSpecs.InitFromTransLine(transLine, transLine."Shipment Date", Direction::Outbound);
TRackingSpecs.Validate("Quantity Handled (Base)", 0);
TRackingSpecs.Validate("Quantity Invoiced (Base)", 0);
AssignNewLotNo(TRackingSpecs);
TRackingSpecs."Qty. Rounding Precision (Base)" := 1;
TRackingSpecs.Validate("Quantity (Base)", transLine.Quantity);
TRackingSpecs."Entry No." := EntryNo;
TRackingSpecs.Insert();
TRackingSpecs."Qty. per Unit of Measure" := 1;
TempItemTrackLineInsert.TransferFields(TRackingSpecs);
TempItemTrackLineInsert.Insert();
CreateReservationEntry(transLine, ILE);
end;
/////////////////////////////////////////////////////////////////////////////
local procedure AssignNewLotNo(var specs: Record "Tracking Specification")
var
IsHandled: Boolean;

begin
Item.TestField("Lot Nos.");
specs.Validate("Lot No.", NoSeriesMgt.GetNextNo(Item."Lot Nos.", WorkDate(), true));
end;


///////////////////////////////////////////////////////////////////////

local procedure CreateReservationEntry(TransLines: Record "Transfer Line"; ILE: Record "Item Ledger Entry")
begin
if LastResEntry.FindLast() then
NextEntryNo := LastResEntry."Entry No." + 1;
if not Item.Get(TransLines."Item No.") then
exit;
Item.TestField("Item Tracking Code");
Item.TestField("Lot Nos.");

ReservationEntry.Init();
ReservationEntry."Entry No." := NextEntryNo;
ReservationEntry.validate("Item No.", TransLines."Item No.");
ReservationEntry.Description := TransLines.Description;
ReservationEntry.validate("Location Code", TransLines."Transfer-from Code");
ReservationEntry.Validate("Quantity (Base)", -TransLines."Qty. to Receive (Base)");
ReservationEntry.validate("Reservation Status", ReservationEntry."Reservation Status"::Surplus);
ReservationEntry.validate("Source Type", Database::"Transfer Line");
ReservationEntry.validate("Source Subtype", ReservationEntry."Source Subtype"::"1");
ReservationEntry.validate("Source ID", TransLines."Document No.");
ReservationEntry.validate("Source Ref. No.", TransLines."Line No.");
ReservationEntry.validate("Shipment Date", TransLines."Shipment Date");
ReservationEntry.validate("Qty. per Unit of Measure", TransLines."Qty. per Unit of Measure");
ReservationEntry.VALIDATE("Lot No.", ILE."Lot No.");
ReservationEntry.Validate("Package No.", ILE."Package No.");
ReservationEntry.validate("Item Tracking", ReservationEntry."Item Tracking"::"Lot and Package No.");
ReservationEntry."Created By" := UserId;
ReservationEntry.Positive := true;
ReservationEntry."Creation Date" := WorkDate();
ReservationEntry.Insert(true);
LotNo := ReservationEntry."Lot No.";
end;
/////////////////////////////////////////
local procedure GetItem(ItemNo: Code[20])
var
begin
if Item."No." <> ItemNo then begin
Item.Get(ItemNo);
Item.TestField("Item Tracking Code");
if ItemTrackingCode.Code <> Item."Item Tracking Code" then
ItemTrackingCode.Get(Item."Item Tracking Code");
end;
end;
it assigns lot no in item tracking lines but when i try to post the transfer order it given me that "You must assign a lot number for item" even though when i open item tracking lines there is Lot No assigned
Sign In or Register to comment.