web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    BarreBe.1 Profile Picture
    15 on at

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans