SBX - Search With Button

SBX - Forum Post Title

How to create Item tracking line from C/AL

Microsoft Dynamics NAV Forum

Allan Borg asked a question on 5 Jan 2016 3:00 AM
My Badges

Question Status

Verified

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

Reply
Verified Answer

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...

Reply
Franz Kalchmair responded on 5 Jan 2016 4:32 AM
Suggested Answer

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

Reply
Allan Borg responded on 5 Jan 2016 6:22 AM
My Badges

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.

Reply
Nareshwar R. responded on 6 Jan 2016 3:45 AM
My Badges

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!!

Reply
Allan Borg responded on 6 Jan 2016 3:53 AM
My Badges

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.

Reply
Thomas M responded on 6 Dec 2017 2:23 PM

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

Thanks in advance,

Thomas

Reply
Víctor José Morcillo Díaz responded on 2 Jan 2018 8:12 AM
My Badges

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. 

Reply
Thomas M responded on 3 Jan 2018 2:35 AM

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;


Reply
Verified Answer

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...

Reply
Franz Kalchmair responded on 5 Jan 2016 4:32 AM
Suggested Answer

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

Reply

SBX - Two Col Forum

SBX - Migrated JS