Compare tow tables and catch the non existing record in the other table

Hey Guys

I am trying to compare a value entry table vs an Item Budget table and prepare a report that indicates Items consumed without budget. Here is what I come up with so far. Please give me your valuable comment.

Thanks in advance

LostItem := ‘Item_xxx’;

StartDate:=‘010121D’;

EndDate:=‘013121D’;

ValueEntry.RESET;
ValueEntry.SETRANGE(ValueEntry.“Item Ledger Entry Type”,ValueEntry.“Item Ledger Entry Type”::“Negative Adjmt.”);
ValueEntry.SETRANGE(“Item No.”,LostItem);
ValueEntry.SETFILTER(“Posting Date”,’%1…%2’,StartDate,EndDate);
IF ValueEntry.FINDFIRST THEN
MESSAGE(’%1 \ %2 \ ‘,ValueEntry.“Item No.”,ValueEntry.“Document Date”);
Item_Budget.RESET;
Item_Budget.SETRANGE(“Serial No.”,LostItem);
IF Item_Budget.ISEMPTY THEN
MESSAGE(’%1: Is not found in Budget.’,LostItem);

//want it to store on some temp table or so

My guess it doesn’t work because you are using the LostItem (Item No.?) to filter on the Serial Number field. Try to filter on Item No. in the Item Budget Entry table?