Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Suggested answer

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,

  • 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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans