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