Thursday 24 May 2018

Error Retail Statement Posting InventTransTMPOriginKeyValueTransfer

Error in Retail Statement Posting


Error Messages

Cannot create a record in Transfer of the InventTrans origin foreign key value (InventTransTMPOriginKeyValueTransfer). Inventory transactions originator: 1001/409666, 1001/409666. The record already exists.

Microsoft.Dynamics.Ax.Xpp.ErrorException: Exception of type Microsoft.Dynamics.Ax.Xpp.ErrorException' was thrown. at Dynamics.Ax.Application.RetailStatementPostSalesOrders.Run() in RetailStatementPostSalesOrders.run.xpp:line 129
at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) in BatchRun.runJobStaticCode.xpp:line 54
at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 13
at BatchRun::runJobStatic(Object[] )
at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters) at BatchIL.taskThreadEntry(Object threadArg)

Cause 

If you are getting error in Retail Statement posting and you are using Indian GST tax, then you are getting this error due to change HSN code into item master and push data into store database during the mid of the transaction, (Ex. Item A having HSN Code '123456' and you changed HSN Code '78910' on same day before shift close) then you will face this problem at the time of statement posting.

Solution
Identify your (Item,HSN Code and Transaction Time) from AX database RetailTransactionSaleTrans Table and break Statement into the part then post.


SQL Query

Create Function [Dbo].[Vijaysharma]  (@Timeinsec Varchar(Max))  
Returns Varchar(Max)  
Begin  
Declare @Op Varchar(Max)  
Set @Op = ''  
Select @Op=Right('0' + Cast(@Timeinsec / 3600 As Varchar),2) + ':' +  
Right('0' + Cast((@Timeinsec / 60) % 60 As Varchar),2) + ':' +  
Right('0' + Cast(@Timeinsec % 60 As Varchar),2)  
Return @Op  
End 
----------------------------Find Duplicate Records-------------------------------------------------------
Select Itemid, Concat(Hsncode_In,Itemid) As Hsnitem Into #Vijay From Retailtransactionsalestrans Where Transdate='2018-09-07' and store='004'
Select Distinct Hsnitem,Itemid Into ##Vijay From #Vijay 
Select Itemid, Count(1) As Duplicate Into ###Vijay From  ##Vijay Group By Itemid Having  Count(1) > 1;
Select Rt.Hsncode_In,Rt.Itemid,Rt.Transdate,Rt.Transtime,rt.store Into ####Vijay From  Retailtransactionsalestrans As Rt  Join  ###Vijay As Vi On Vi.Itemid=Rt.Itemid Where Rt.Transdate='2018-09-07' and store='004'
Select Hsncode_in,Itemid,transdate,store, [Dbo].[Vijaysharma](TRANSTIME) 'Time' into #####Vijay from ####Vijay order by itemid,Time
select min(time) 'Start Time',max(time) 'End Time',Itemid,Hsncode_in,Store from #####Vijay group by itemid,hsncode_in,store order by max(time),itemid
------------Delete Temp Tables------------------------------------------------------------------------------
Drop Table #Vijay ,##Vijay ,###Vijay,####Vijay,#####Vijay

Excel Sheet

Select Hsncode_in,Itemid from RetailtransactionSalesTrans where Transdate='2018-05-22'
Copy these records from the SQL Tables and paste into the excel sheet, Insert one more column and Put formula =concate(B1,C2)

Go to the Menu Data tab and Remove Duplicate from the concate column, after that select ITEMID column, go to the menu Home Tab click on Conditional Formatting--Highlight Cells Rules--Click on Duplicate Values, Select Duplicate with color. you will find duplicate values. You can check transaction time of that particular item and can calculate(Split) your statement accordingly.

No comments:

Post a Comment