I am using a temporary table in one of my reports. The temporary table is pointing to a new table that we created, that has no custom table level CAL code.
At a point in my report I need to clear all the values from my table but I can't seem to get this to work. I've tried the following:
1. Calling the DELETEALL method
2. Looping through each record and calling the DELETE function
Is the problem that I am using a custom table we created or is there some other way of deleting record from a temp. table I am not familiar with?
Thank you,
Leo
0
Comments
TempRec.DELETEALL;
should work.
Can you post your code?
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
TEMP_DTLotQuantities.DELETEALL;
DTLotQuantitiesCnt := 1;
DTQuantityRemaining := Quantity;
ItemLedgerEntry.INIT;
ItemLedgerEntry.SETRANGE("Item No.",ItemNo);
ItemLedgerEntry.SETRANGE("Item Tracking",ItemLedgerEntry."Item Tracking"::"Lot No.");
ItemLedgerEntry.SETFILTER("Lot No.",'<>%1','');
ItemLedgerEntry.SETFILTER("Remaining Quantity",'>0');
IF ItemLedgerEntry.FIND('-') THEN REPEAT
TEMP_DTLotQuantities.SETRANGE(RefERPNo,ItemLedgerEntry."Lot No.");
IF TEMP_DTLotQuantities.FIND('-') THEN
BEGIN
TEMP_DTLotQuantities.DTID := TEMP_DTLotQuantities.DTID + ItemLedgerEntry."Remaining Quantity";
TEMP_DTLotQuantities.MODIFY;
END
ELSE
BEGIN
TEMP_DTLotQuantities.ID := DTLotQuantitiesCnt;
TEMP_DTLotQuantities.RefERPNo := ItemLedgerEntry."Lot No.";
TEMP_DTLotQuantities.DTID := ItemLedgerEntry."Remaining Quantity";
TEMP_DTLotQuantities.INSERT;
DTLotQuantitiesCnt := DTLotQuantitiesCnt + 1;
END;
UNTIL ItemLedgerEntry.NEXT = 0;
This is being called inside of a function that is called multiple times in the report, which is why I need to delete all records in the temporary table (TEMP_DTLotQuantities) every time. I get an error "ID '1' Already exists" when calling this function multiple times.
Thanks.
On the face of it the code looks fine. What's the key of the temp table?
Have you used the debugger to see where the error occurs?
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html