Account number for transaction type Inventory loss does not exist

Closing inventory in AX 2009 got error message - Account number for transaction type Inventory loss does not exist. Check the inventory posting - there is no account specified. Specify the account and try to resume the calculation. Got the same error.

Open InventSettlement table by AOT and filter for the voucher number. Look for Inventory loss value in column OperationsPosting. Check that there is account specified in column OperationsAccount. In my case it was empty. The table is not editable. Note the value of the RecId.

Create a job

static void update_InventSettlement(Args _args)
{
InventSettlement inventSettlementLoc;
;
inventSettlementLoc = inventSettlement::findRecId(5650538843, true);
if(inventSettlementLoc)
{
ttsbegin;
inventSettlementLoc.OperationsAccount='12345';
inventSettlementLoc.update();
ttscommit;
}
}

or use SQL Management Studio to enter the value.

Resume the calculation.