Open Retail Statement > Posting open statement gives error “Function InventTrans.inventMovement has been used incorrectly”
We are experiencing this error at one of our client’s production environment (Dynamics AX 2012 R2 CU7). I have debugged the issue thoroughly and found that while constructing the InventMovement class for one of the movements (InventTrans), the originator (Table InventTransOrigin method call to method: originator(), queries
respective table for related data, in our case RetailtransactionSalesTrans table since 150 (Statement) in ReferenceID field in InventTransOrigin table) is not found.
Later while returning this movement object, its originator (buffer()) is validated and since not initialized, the IF condition is not met, so no variable is returned, the underlying condition is evaluated, which is met as true and gives the error. Code listing is provided for the referece as follows;
Code Listings and Flow
Process Knowledge
As far as I have investigated and inquired my colleagues, the process is that,
First all sales transactions / movements are compiled / calculated
System then generates an SO (on runtime)
When posting the SO, InventTrans aare generated to post the inventory physically
Posting is completed
Now during this process and somewhere in the InventUpdate classes, the invetMovement method is called which then looks that the request is from Statement (150) with Retail congif key ON, tries to find a record in RetailTransactionSalesTrans which is not there.
Hence the issue is identified, but the question is, if a Retail Statement is open, should such statements and their transactions have records in InventTrans and InventTransOrigin ?
How is it possible that ITO has reference category to 150 (retail statement) and reference ID = valid retail statement (open state) has no reference record in RetailTransactionSalesTrans.
Is it a bug ? Is their any hotfix available ? If it is not, how to resolve it ? Any one else experienced it ?
Kindly help me regarding this