Version: AX 2012 FPK
Problem description:
When running a P job to pull the data from the POS, the store connect fails while inserting the data back to AX.
The error message is logged in the Event Viewer or Outgoingmessages table is this, depending on the
tracing options set in the store connect settings.
ORIGINAL MESSAGE 2012.5.30 System.Reflection.TargetInvocationException: at --- End of inner exception stack trace --- at at System.Reflection.RuntimeMethodInfo.Invoke(Object at at at at at ProcessTargetRequestHeader(ISCTargetRequestHeader --- End of inner exception stack trace --- at ProcessTargetRequestHeader(ISCTargetRequestHeader at CCommMgr.ProcessTargetRequest(CCommMgr*
|
Since this error message only indicates a column mapping issue, it is not very informative.
Reason:
In the following example, we explain why and how we came to the solution.
When we generate Retail seed data in the Retail parameters/initialize,
we are inserting the data from a resource file (AOT). In that process Dynamics
AX is not validating the columns if configuration keys are enabled.
In the example we found out that the customer had disabled the SALES TAX configuration key.
In the table RetailTransactionSalesTrans there are 5 fields
that all are bound to the LedgerBasicSalesTax configuration key (sales tax) which as shown in the picture is
disabled in the configuration keys.
TaxAmount
TaxGroup
TaxItemGroup
OriginalTaxGroup
OriginalTaxItemGroup
Debugging the issue:
To debug the issue we first had to find were the error message originates from. By looking at the
String “Error when bulk inserting data. Target table: RetailTransactionSalesTrans” we could guess that
we had to look for Error when bulk inserting data. Target table:, which we also found in the class.
\Classes\RetailConnSCDataBulkCopy\bulkCopyToTemp
Enabling a breakpoint in that class and enabling debugging through the business connector, we could step through the code.
Through the debugger we saw that we had two containers keeping the source columns and target columns
The two containers are ColumnNames(Source), PhysicalColumnNames (target)
These two containers or list of columns must match; else we have a mapping issue.
As shown in the PhysicalColumnNames
The columns 31,32,58,59,60 are missing
As mentioned earlier, these columns were not activated by the configuration keys.
The call stack of the call
Solution and modification:
The solution is to either enable the License configuration keys affecting the Retail transaction tables or adjust the subjob transfer
field list.
The code change that introduces a better error handling
\Classes\RetailConnSCDataBulkCopy\bulkCopyToTemp
publicvoid { System.Data.SqlClient.SqlBulkCopy str str str int System.Xml.XmlReader xmlReader;
System.Exception clrException; str
//MS CHANGE str str //MS CHANGE ;
columnNameCollection = new guidColumnNameCollection = new
for { columnName = conPeek(columnNames, i); columnNameCollection.Add(columnName); }
for { columnName = conPeek(guidColumnNames, i); guidColumnNameCollection.Add(columnName); }
try { xmlReader = new xmlDataReader = new xmlReader, columnNameCollection, guidColumnNameCollection, targetTableName, false);
connStr = this.getConnectionString(); sqlBulkCopy = new dstTableName = #TempDBPrefix +
colMapping =
for { colMapping.Add(i-1, conPeek(physicalColumnNames, }
rowsAffected =
sqlBulkCopy.Dispose(); xmlDataReader.Dispose(); xmlReader.Dispose(); this.CleanTempDataFile(); } catch(Exception::CLRError) { //MS for { if(conPeek(physicalColumnNames,i) =="") missingColumns += conPeek(columnNames,i) + ","; }
clrException = exceptionMessage = exceptionMessage = strFmt("Error targetTableName,missingColumns, //MS
if { sqlBulkCopy.Dispose(); }
if { xmlDataReader.Dispose(); }
{ xmlReader.Dispose(); }
this.CleanTempDataFile();
throw } }
|
NEW ERROR MESSAGE 2012.6.1 9:13:45:821 (14376) [1] CCommMgr::HandleException: Target table: RetailTransactionSalesTrans Target
Check if these fields are disabled by the license configuration keys. If the configuration keys are correct, change the transfer field list on the scheduler subjob
System.Reflection.TargetInvocationException: at System.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Add(SqlBulkCopyColumnMapping --- End of inner exception stack trace --- at at at System.Reflection.RuntimeMethodInfo.Invoke(Object at at at Microsoft.Dynamics.AX.ManagedInterop.Object.Call(String at ProcessTargetRequestHeader(ISCTargetRequestHeader --- End of inner exception stack trace --- at ProcessTargetRequestHeader(ISCTargetRequestHeader at CCommMgr.ProcessTargetRequest(CCommMgr*
|
Author: Kim Truelsen
Date: 1/6-2012