Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

NAV 2016. Create tracking information for Transfer Lines through code.

Posted on by 2,983

I use this code to create tracking information for my transfer lines.

LOCAL CrReservEntry(TransferLine : Record "Transfer Line";Lot : Code[20];qty : Decimal)
CrReservEntry.SetDates(0D, 0D);

    CrReservEntry.CreateReservEntryFor(DATABASE::"Transfer Line",
                                            1,
                                            TransferLine."Document No.",
                                            '',
                                            0,
                                            TransferLine."Line No.",
                                            TransferLine."Qty. per Unit of Measure",
                                            TransferLine."Qty. per Unit of Measure" * qty,
                                            TransferLine."Qty. per Unit of Measure" * qty,
                                            '',
                                            Lot);
    CrReservEntry.CreateEntry(TransferLine."Item No.",
                                   TransferLine."Variant Code",
                                   TransferLine."Transfer-from Code",
                                   TransferLine.Description,
                                   TODAY,
                                   TODAY,
                                   0,
                                   2);

CurrentSourceRowID := ItemTrackingMgt.ComposeRowID(5741,0,TransferLine."Document No.",'',0,TransferLine."Line No.");

SecondSourceRowID := ItemTrackingMgt.ComposeRowID(5741,1,TransferLine."Document No.",'',0,TransferLine."Line No.");

ItemTrackingMgt.SynchronizeItemTracking(CurrentSourceRowID,SecondSourceRowID,''); 


Indeed two lines are created in the Reservation entry table, but something is missing, because when I navigate in NAV to tracking information of the transfer line, there is nothing.

Any ideas?

*This post is locked for comments

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: NAV 2016. Create tracking information for Transfer Lines through code.
    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.

  • Rashed Profile Picture
    Rashed 3,765 on at
    RE: NAV 2016. Create tracking information for Transfer Lines through code.

    Create the line manually and then compare the reservation entry records that you inserted manually and through code. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans