The record in Item Ledger Entry already exists. Identification fields and Values: Entry No

Hi, i faced same issue in Business Central “on premise” version, i delete ILE and VE and G/L Entry records using SQL query because it was wrong.

i know this the wrong procedure, when try to post the sales entries in open statements its gave the error in the pic.

i restart the NAV and SQL services but still the error occurs and when i check the the entry no. inside the table its not existing…

please how i can solve this issue because its stopped all posting linked to ILE and VE., i found two tables linked “Adjusted item Ledger” and Discount Ledger Entry" shall i delete it also or there another way to solve this issue ?

this code when i debug that give error:
IF RetailSetup.“Update Cost Amount” THEN
IF (ValueEntry.Adjustment) AND (ValueEntry.“Item Ledger Entry No.” <> 0) AND (ValueEntry.“Cost Amount (Actual)” <> 0) AND
(locItemLedgerEntry.GET(ValueEntry.“Item Ledger Entry No.”)) AND (locItemLedgerEntry.“Statement No.” <> ‘’)

You can not really insert records in these tables manually or in code. They are populated during the posting process in Business Central and should really not be tampered with.