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
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156