Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Creating Item Tracking Lines for Sales Order with C/AL + How to get Item Available Quantity with C/AL

Posted on by Microsoft Employee

Hi community,

Please your help is very much appreciated,

1)  Does the CreateReservEntryFor and CreateEntry functions of the Codeunit 99000830 "Create Reserv. Entry" are sufficient to add item tracking lines(Assign Lot Numbers) to a Sales Line or there is other validations/functions to do/call before calling these two functions.

2) How to calculate the item available Quantity by Lot with C/AL.

3) how to check if a Lot No. is a valid Lot No (configured in NAV) with C/AL (ex: how to check if LT10 is a valid Lot No.).

----------------

Thanks in advance,

*This post is locked for comments

  • Suggested answer
    BarreBe.1 Profile Picture
    BarreBe.1 15 on at
    RE: Creating Item Tracking Lines for Sales Order with C/AL + How to get Item Available Quantity with C/AL

    Hi,

    I remember this post and the solution from Robert Stefanetti:

    community.dynamics.com/.../how-to-create-item-tracking-line-from-c-al

    I tried this code as different from the link inside this post. I did this for Purchase Line and Sales Line to handle thes in a warehouse document.

    It seems the rec337 table (here known as Reservation) is as here below:

    For Purchase Line:

    Reservation."Reservation Status" := Reservation."Reservation Status"::Prospect;
    Reservation."Creation Date" := WORKDATE();
    Reservation."Source Type" := PurchLine.RecordId().TableNo();
    Reservation."Source Subtype" := PurchLine."Document Type";
    Reservation."Source ID" := PurchLine."Document No.";
    Reservation."Source Batch Name" := '';
    Reservation."Source Ref. No." := PurchLine."Line No.";
    Reservation.Positive := TRUE;
    Reservation.VALIDATE("Location Code", PurchLine."Location Code");
    // Reservation.VALIDATE("Bin Code", ItemJnlLine."Bin Code");
    Reservation.VALIDATE("Item No.", PurchLine."No.");
    Reservation.VALIDATE("Quantity (Base)", PurchLine."Quantity (Base)");
    Reservation.VALIDATE(Quantity, PurchLine.Quantity);
    Reservation."Item Tracking" := Reservation."Item Tracking"::"Lot No."; // IF LOT OR TRACKING in this sample LOT
    Reservation."Lot No." := LotNoToInsert;
    Reservation."Expiration Date" := Expires;
    IF Reservation.INSERT(TRUE) THEN BEGIN
    //Lot Info creation
    LotNoInformation.INIT();
    LotNoInformation.VALIDATE("Item No.", Reservation."Item No.");
    LotNoInformation.VALIDATE("Lot No.", Reservation."Lot No.");
    if not LotNoInformation.INSERT(TRUE) then LotNoInformation.Modify(TRUE);
    END

    For Sales Line:

    Reservation."Reservation Status" := Reservation."Reservation Status"::Prospect;
    Reservation."Creation Date" := WORKDATE();
    Reservation."Source Type" := SaleLine.RecordId().TableNo();
    Reservation."Source Subtype" := SaleLine."Document Type";
    Reservation."Source ID" := SaleLine."Document No.";
    Reservation."Source Batch Name" := '';
    Reservation."Source Ref. No." := SaleLine."Line No.";
    Reservation.Positive := TRUE;
    Reservation.VALIDATE("Location Code", SaleLine."Location Code");
    // Reservation.VALIDATE("Bin Code", ItemJnlLine."Bin Code");
    Reservation.VALIDATE("Item No.", SaleLine."No.");
    Reservation.VALIDATE("Quantity (Base)", SaleLine."Quantity (Base)");
    Reservation.VALIDATE(Quantity, SaleLine.Quantity);
    Reservation."Item Tracking" := Reservation."Item Tracking"::"Lot No."; // IF LOT OR TRACKING in this sample LOT
    Reservation."Lot No." := LotNoToInsert;
    Reservation."Expiration Date" := Expires;
    IF Reservation.INSERT(TRUE) THEN BEGIN
    //Lot Info creation
    LotNoInformation.INIT();
    LotNoInformation.VALIDATE("Item No.", Reservation."Item No.");
    LotNoInformation.VALIDATE("Lot No.", Reservation."Lot No.");
    if not LotNoInformation.INSERT(TRUE) then LotNoInformation.Modify(TRUE);
    END


    I also remarked that the Quantity (base)/ Quantity field must be different from 0 to show up the tracking line, but there must be something more and I think about the above fields because they are different from the Item Journal.

    I edited this post because after modify the Source batch Name to empty it works.

    Best regards

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans