Automatic Lot No. Assigment - FIFO

leikelmanleikelman Member Posts: 31
This is our current process for handling sales orders:

1. A client sends us a data file containing the sales headers and detail lines.
2. We import that file into tables in NAV that act as holding tables. These tables are copies of the Sales Header (#36) and Sales Line (#37) tables.
3. We run two scheduled reports which process information in the holding tables and insert the records into the Sales Header and Sales Line tables.

We are currently using Lot. Numbers to track items. However, we are not using the Lot. No. series but are entering the Lot. No. manually during a purchase order.

What we need to happen, either programmatically or automatically, is when a Sales Line record is inserted, it must have the "Item Tracking Lines" populated with the correct Lot. No., according to FIFO.

What we are trying to similuate automatically is the funcitonality of the following manual steps:

1. Open the "Sales Order" Card/Form
2. Click on one of the Sales Line.
3. Click on Line -> Item Tracking Lines from the menu buttons.
4. On the new form that appears, "Item Tracking Lines", Click on Functions -> Select Entries
5. A new form will open, "Item Tracking - Select Entries", with the appropriate Lot(s) selected, according to FIFO.
6. Click the "OK" button and the "Item Tracking Lines" form is populated with all of the information.


Is this something that we can do programmatically or have NAV do for us automatically?


Thank you,

Leo

Comments

  • matttraxmatttrax Member Posts: 2,309
    You'll have to write code for it, but it can definitely be done (I've done it myself, but with serial numbers instead of lots).

    A good place to start is Codeunit 99000845 - Reservation Management. There are other codeunits around that ID that can help too.

    The following code might also help
    CreateReservEntry.SetDates(
      0D, 0D);
    
    CreateReservEntry.CreateReservEntryFor(
      DATABASE::"Item Journal Line",
      ItemJnlLine."Entry Type",
      ItemJnlLine."Journal Template Name",
      ItemJnlLine."Journal Batch Name",
      0,
      ItemJnlLine."Line No.",
      ItemJnlLine."Qty. per Unit of Measure",
      1,
      SerialNo,
      '');
    
    CreateReservEntry.CreateEntry(
      ItemJnlLine."Item No.",
      ItemJnlLine."Variant Code",
      ItemJnlLine."Location Code",
      ItemJnlLine.Description,
      ItemJnlLine."Posting Date",
      ItemJnlLine."Document Date",
      0,
      2);  //2 is the option for Surplus
    

    where CreateReservEntry is an instance of Codeunit 99000830.
Sign In or Register to comment.