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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How to create Item tracking line from C/AL

(0) ShareShare
ReportReport
Posted on by

Hi all!

In my custome module I have code which creates item journal lines. For these item journal lines I would like to create tracking via lot no, but I dont know how.

I would really appreciate it if someone could write an example of how to do that. I assume I have to create a TempItemTrackLine and insert it. But which variables should I set? and what to do after that?

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Roberto Stefanetti Profile Picture
    12,998 on at

    hi,

    You don't need to write in tempitemtracking,  standard NAV "AS IS" write directly in table 337 "reservation entries" creating prospect lines for item tracking Handling.

    just in time for you...  a simple example:

    Tracking C/AL code exampe that write in table 337 Reservation entries

    //tbl83 "Item Journal Line"   -  LOOP on jornal line existing lines

    rec83.RESET;  

    rec83.SETRANGE("Journal Template Name" , 'ITEM')  ;  //filter template and batch

    rec83.SETRANGE("Journal Batch Name", 'INV2016');  

    LotLine := 0;

    IF rec83.FINDSET THEN

      REPEAT

         IF ItemHasLot(rec83."Item No.")  THEN  // function to check if item use LOTS

           BEGIN

           //Create Tracking record in table 337

           rec337."Entry No." := MaxEntry337 +1;  //recover MAX Entry No. from tbl 337

           rec337."Reservation Status" := rec337."Reservation Status"::Prospect;

           rec337."Creation Date" :=  WORKDATE;

           rec337."Source Type" := 83;

           rec337."Source Subtype" := 2;

           rec337."Source ID" := 'ITEM';

           rec337."Source Batch Name" := 'INV2016';

           rec337."Source Ref. No." := rec83."Line No.";

           rec337.Positive := TRUE;

           rec337.VALIDATE("Location Code", rec83."Location Code") ;

           rec337.VALIDATE("Bin Code", rec83."Bin Code");

           rec337.VALIDATE("Item No.",rec83."Item No.");  

           rec337.VALIDATE("Quantity (Base)", rec83.Quantity);

           rec337.VALIDATE(Quantity, rec83.Quantity);

           rec337."Item Tracking" :=rec337."Item Tracking"::"Lot No." ;   // IF LOT OR TRACKING  in this sample LOT

           LotLine :=  LotLine+=;

          //Creation of LOT NO. if necessary to create a new one LOT

           IF STRLEN(FORMAT(LotLine)) = 1 THEN

              rec337."Lot No." :=  'INV16-' + '00000' + FORMAT(LotLine)  ;

           IF STRLEN(FORMAT(LotLine)) = 2 THEN

              rec337."Lot No." :=  'INV16-' + '0000' + FORMAT(LotLine)  ;

           //OR USE CASE IF YOU HAVE MORE CASES TO HANDLE

           IF  rec337.INSERT(TRUE) THEN   //If Write Tracking Line then Create LOT INFO Records

           BEGIN

           //Lot Info creation

           recLotNoIInformation.INIT:

           recLotNoIInformation.VALIDATE("Item No.", rec337."Item No.");

           recLotNoIInformation.VALIDATE("Lot No." , rec337."Lot No.");    

           recLotNoIInformation.INSERT(TRUE);

           END

           END;

      UNTIL rec83.NEXT = 0;    

    i hope that cab be usefull...

  • Suggested answer
    keoma Profile Picture
    32,729 on at

    you can use CU 99000830 "Create Reserv. Entry" functions CreateEntry, CreateReservEntry, CreateReservEntryFor, CreateReservEntryFrom.

  • Community Member Profile Picture
    on at

    Thanks you!

    on a note: I triede to find bind code in rec337 but I could not find I so I left out thist line

    rec337.VALIDATE("Bin Code", rec83."Bin Code");

    Is that a problem?

    Also. Do you have an example on how to reserv from this reservation line from a sales order line?

    This has really been a big help.

  • Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    In my scenario, I had to auto-generate the Lot Tracking Code based on the date and job number. Codeunit 99000830 is what I used and it does the job!!

  • Community Member Profile Picture
    on at

    Thanks for the reply

    My issue is solved and I made use of then functions in CU 99000845 Reservation management which again makes use of 99000832 Sales Line-Reserve.

  • ThomasM Profile Picture
    20 on at

    Hey, can you tell which functions you used to solve your problem?

    Thanks in advance,

    Thomas

  • Community Member Profile Picture
    on at

    Hi. I'm trying to do this too but in item journal to make a negative adjustment. Is it possible with CU 99000830? Could you post what functions should I use? 

    Best regards. 

  • ThomasM Profile Picture
    20 on at

    I created this function to make use of the whole NAV Standard logic. NAV takes care for me to use the correct Lot:

    LOCAL PROCEDURE SalesOrderLineReserve@1000000012(VAR pioSalesLine@1000000000 : Record 37;piItem@1000000001 : Record 27);
        VAR
          lReservationEntry@1000000010 : Record 337;
          lReservEntryILE@1000000009 : Record 337;
          lReservEntryEdit@1000000008 : Record 337;
          lSalesLine@1000000006 : Record 37;
          lcuReservationManagement@1000000004 : Codeunit 99000845;
          DoFullReserve@1000000003 : Boolean;
          lcuSalesLineReserve@1000000002 : Codeunit 99000832;
        BEGIN
          lcuReservationManagement.SetSalesLine(pioSalesLine);
          lcuReservationManagement.AutoReserve(DoFullReserve, pioSalesLine.Description, WORKDATE, pioSalesLine."Outstanding Quantity", pioSalesLine."Outstanding Qty. (Base)");
          lcuSalesLineReserve.FilterReservFor(lReservationEntry,pioSalesLine);
    
          IF lReservationEntry.FINDSET THEN
            REPEAT
              lReservEntryILE.GET(lReservationEntry."Entry No.", NOT lReservationEntry.Positive);
              lReservEntryEdit.GET(lReservationEntry."Entry No.", lReservationEntry.Positive);
              lReservEntryEdit."Lot No." := lReservEntryILE."Lot No.";
              lReservEntryEdit.MODIFY;
            UNTIL lReservationEntry.NEXT = 0;
        END;


  • Community Member Profile Picture
    on at

    Can you explain me this function better pls? There is no return...

  • ThomasM Profile Picture
    20 on at

    Hi catiamatos1991,

    basically u need to use the codeunit Reservation Management as stated here earlier. The ID is: 99000845

    You basically just set the Kind of record you want to create a reservation for, in this example it's the sales order line, therefore the SetSalesLine Function is used, but there are a couple more functions like this.

    Then you just have to call the AutoReserve Method and you can leave the rest to NAV and it creates 2 reservation entries for you! One is positive and one negative (input/output)

    There is only one thing you need to keep in mind:

    I don't know why, but NAV does not set the "Lot No." into the second reservation entry (output - related to your document). You'll need to set this one by yourself, in my example i do this into the last code lines starting with: lcuSalesLineReserve.FilterReservFor(lReservationEntry,pioSalesLine); this returns the just created reservation entry and I had to get the Lot No. from it and write it to the other one to see the information into your item tracking page in the client (generally called by: lines -> item tracking)

    I hope that helps!

    PS.: I hope you got a developer license to dive into these CU's and research on your own a little bit - it helped me a lot to understand what NAV is doing here!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans