PROCEDURE CreateTLItemTracking@1000000007(TransferLine@1240060005 : Record 5741;xTransferLine@1000000003 : Record 5741);
VAR
TrackingSpecification@1240060000 : Record 336;
ReservEntry@1240060001 : Record 337;
ReserveTransferLine@1240060002 : Codeunit 99000836;
LastEntryNo@1240060003 : Integer;
CreateReservEntry@1240060004 : Codeunit 99000830;
ItemTrackingMgt@1240060006 : Codeunit 6500;
CurrentEntryStatus@1240060007 : 'Reservation,Tracking,Surplus,Prospect';
FilterReservEntry@1000000000 : Record 337;
Item@1000000001 : Record 27;
ReservEngineMgt@1000000002 : Codeunit 99000831;
AvailabilityDate@1000000004 : Date;
I@1000000005 : Integer;
BEGIN
WITH TransferLine DO BEGIN
IF ("Serial No." <> '') AND (Quantity > 1) THEN
ERROR(Text003,"Line No.");
IF (("Serial No." = '') AND (xTransferLine."Serial No." = ''))
OR (Quantity = 0)
OR (("Serial No." = xTransferLine."Serial No.") AND (Quantity = xTransferLine.Quantity)
AND (xTransferLine."Transfer-from Code" = "Transfer-from Code")
AND (xTransferLine."Transfer-to Code" = "Transfer-to Code")) THEN
EXIT;
IF (xTransferLine."Serial No." <> '') AND ("Serial No." = '') THEN BEGIN
ReserveTransferLine.FilterReservFor(FilterReservEntry,TransferLine,0);
FilterReservEntry.SETRANGE("Source Subtype");
FilterReservEntry.SETRANGE("Serial No.",xTransferLine."Serial No.");
IF FilterReservEntry.FINDSET THEN BEGIN
REPEAT
FilterReservEntry.DELETE(TRUE);
UNTIL FilterReservEntry.NEXT = 0;
EXIT;
END;
END;
IF (xTransferLine."Serial No." <> '') AND ("Serial No." <> '') THEN BEGIN
ReserveTransferLine.FilterReservFor(FilterReservEntry,TransferLine,0);
FilterReservEntry.SETRANGE("Serial No.",xTransferLine."Serial No.");
FilterReservEntry.SETRANGE("Source Subtype");
IF FilterReservEntry.FINDSET THEN BEGIN
REPEAT
FilterReservEntry.VALIDATE("Serial No.","Serial No.");
FilterReservEntry.MODIFY(TRUE);
UNTIL FilterReservEntry.NEXT = 0;
EXIT;
END;
END;
IF (xTransferLine."Transfer-from Code" <> "Transfer-from Code") THEN BEGIN
ReserveTransferLine.FilterReservFor(FilterReservEntry,TransferLine,0);
FilterReservEntry.SETRANGE("Serial No.","Serial No.");
FilterReservEntry.SETRANGE("Source Subtype");
IF FilterReservEntry.FINDSET THEN
REPEAT
FilterReservEntry.DELETE(TRUE);
UNTIL FilterReservEntry.NEXT = 0;
END;
ReserveTransferLine.FilterReservFor(FilterReservEntry,TransferLine,0);
FilterReservEntry.SETRANGE("Serial No.","Serial No.");
IF FilterReservEntry.FINDFIRST THEN
EXIT;
FOR I := 0 TO 1 DO BEGIN
Item.GET(TransferLine."Item No.");
ReserveTransferLine.InitTrackingSpecification(TransferLine,TrackingSpecification,AvailabilityDate,I);
TrackingSpecification.VALIDATE("Serial No.","Serial No.");
TrackingSpecification.VALIDATE("Quantity (Base)",Quantity);
IF ItemTrackingMgt.IsOrderNetworkEntity(TrackingSpecification."Source Type",
TrackingSpecification."Source Subtype")
THEN
CurrentEntryStatus := CurrentEntryStatus::Surplus
ELSE
CurrentEntryStatus := CurrentEntryStatus::Prospect;
CreateReservEntry.SetDates(
TrackingSpecification."Warranty Date",TrackingSpecification."Expiration Date");
CreateReservEntry.SetApplyFromEntryNo(
TrackingSpecification."Appl.-from Item Entry");
CreateReservEntry.CreateReservEntryFor(
TrackingSpecification."Source Type",
TrackingSpecification."Source Subtype",
TrackingSpecification."Source ID",
TrackingSpecification."Source Batch Name",
TrackingSpecification."Source Prod. Order Line",
TrackingSpecification."Source Ref. No.",
TrackingSpecification."Qty. per Unit of Measure",
TrackingSpecification."Quantity (Base)",
TrackingSpecification."Quantity (Base)",
TrackingSpecification."Serial No.",
TrackingSpecification."Lot No.");
IF I = 0 THEN
CreateReservEntry.CreateEntry(TrackingSpecification."Item No.",
TrackingSpecification."Variant Code",
TrackingSpecification."Location Code",
TrackingSpecification.Description,
0D,
"Shipment Date",0,CurrentEntryStatus)
ELSE
CreateReservEntry.CreateEntry(TrackingSpecification."Item No.",
TrackingSpecification."Variant Code",
TrackingSpecification."Location Code",
TrackingSpecification.Description,
"Shipment Date",
0D,0,CurrentEntryStatus);
END;
END;
END;
Check this code which i have used previously to create Item Tracking Lines, please rememberr this is for creation for serial no.