When fetching data from the StoreDB you might see this message. The reason is normally configuration keys or added system fields. By adding the code suggestion, the system will report all the columns that are incorrect and you can then take action by mofifying the Transfer field list in AX subjobs.

 

 ERROR IN THE HQ RETAIL STORE CONNECT

ERROR 32769

Target request handler failed to process target request header: SCAXRequestHandlerException: AX target request handler failed to process request: AX Managed Interop failure.  ErrorException:  Error when bulk inserting data.   Target table: RetailTran

 

 

 

CODE SUGGESTION

\Classes\RetailConnSCDataBulkCopy\bulkCopyToTemp

public void bulkCopyToTemp(str physicalTempDBTableName)

{

   
System.Data.SqlClient.SqlBulkCopy sqlBulkCopy;

   
str connStr;

   
System.Data.SqlClient.SqlBulkCopyColumnMappingCollection colMapping;

   
str columnName;

   
str dstTableName;

   
int i;

   
System.Xml.XmlReader xmlReader;

   
Microsoft.Dynamics.Retail.StoreConnect.Request.Base.SCSimpleXmlDataReader
xmlDataReader;

 

   
System.Collections.Specialized.StringCollection columnNameCollection;

   
System.Collections.Specialized.StringCollection guidColumnNameCollection;

 

   
System.Exception clrException;

   
str exceptionMessage;

   
str columnName2;

   
str missingColumns;

   
str systemfields1 = 'CreatedBy';

   
str systemfields2 = 'ModifiedBy';

   
str systemfields3 = 'ModifiedDateTime';

   
str systemfields4 = 'CreatedDateTime';

   
str systemfields5 = 'CreatedTransactionId';

   
str systemfields6 = 'ModifiedTransactionid';

   
str systemfields7 = 'Recid';

   
str systemfields8 = 'RecVersion';

   
;

   
columnNameCollection = new
System.Collections.Specialized.StringCollection();

   
guidColumnNameCollection = new
System.Collections.Specialized.StringCollection();

   

   
for (i = 1; i <= conLen(columnNames);
i++)

   
{

        columnName = conPeek(columnNames, i);

        columnNameCollection.Add(columnName);

   
}

 

   
for (i = 1; i <= conLen(guidColumnNames);
i++)

   
{

        columnName = conPeek(guidColumnNames, i);

       
guidColumnNameCollection.Add(columnName);

   
}

            try

   
{

        xmlReader = new
System.Xml.XmlTextReader(tmpDataFilePath);

        xmlDataReader = new
Microsoft.Dynamics.Retail.StoreConnect.Request.Base.SCSimpleXmlDataReader(

            xmlReader,

            columnNameCollection,

            guidColumnNameCollection,

            targetTableName,

            false);

 

        connStr = this.getConnectionString();

        sqlBulkCopy = new
System.Data.SqlClient.SqlBulkCopy(connStr);

        dstTableName = #TempDBPrefix +
physicalTempDBTableName;

 

        colMapping =
sqlBulkCopy.get_ColumnMappings();

 

        for
(i = 1; i <= conLen(physicalColumnNames); ++i)

        {

            colMapping.Add(i-1, conPeek(physicalColumnNames,
i));

        }

 

       
sqlBulkCopy.set_DestinationTableName(dstTableName);

       
sqlBulkCopy.set_BulkCopyTimeout(#BulkCopyTimeOut);

       
sqlBulkCopy.WriteToServer(xmlDataReader);

        rowsAffected =
xmlDataReader.get_NumberOfRecordsRead();

        sqlBulkCopy.Dispose();

        xmlDataReader.Dispose();

        xmlReader.Dispose();

        this.CleanTempDataFile();

   
}

   
catch(Exception::CLRError)

   
{

        for(i
= 1; i <= conLen(physicalColumnNames);
++i)

 

        {

            if((conPeek(physicalColumnNames,i) =="") || (conPeek(physicalColumnNames,i)
== Systemfields1) || (conPeek(physicalColumnNames,i)
== Systemfields2)|| (conPeek(physicalColumnNames,i)
== Systemfields3)|| (conPeek(physicalColumnNames,i)
== Systemfields4)|| (conPeek(physicalColumnNames,i)
== Systemfields5) || (conPeek(physicalColumnNames,i)
== Systemfields6) || (conPeek(physicalColumnNames,i)
== Systemfields7) || (conPeek(physicalColumnNames,i)
== Systemfields8))

            missingColumns += conPeek(columnNames,i) + ",";

        }

        clrException =
CLRInterop::getLastException();

        exceptionMessage =  clrException.ToString();

        exceptionMessage = strFmt("Error
when bulk inserting data. \r\nTarget table: %1\r\n Target columns: "

                                    + "%2\r\n\r\nCheck if these fields are disabled by the
license configuration "

                                    + "keys.\r\nIf the configuration keys are correct,
change the transfer field"

                                    + "list on the scheduler subjob. \r\nIt is also not
allowed to add system fields to the Transferfield list 'CreatedBy,ModifiedBy,
ModifiedDateTime, CreatedDateTime, CreatedTransactionId, ModifiedTransactionid,
Recid, RecVersion'\r\n\r\n%3\r\n%4.1",

                                   
targetTableName,

                                   
missingColumns,

                                   
exceptionMessage,

                                   
physicalTempDBTableName);

        if
(sqlBulkCopy)

        {

            sqlBulkCopy.Dispose();

        }

 

        if
(xmlDataReader)

        {

            xmlDataReader.Dispose();

        }

 

        if
(xmlReader)

        {

            xmlReader.Dispose();

        }

        this.CleanTempDataFile();

        throw
error(exceptionMessage);

   
}

}

 

 

 

 

 

 OUTPUT IN THE APPLICATION EVENTLOG

After the change of the code, you can now see which fields on the transfer fieldlist that is incorrect.

 

2012.12.3
4:36:50:879       (11140) 
[1]          
CCommMgr::HandleException: Target request handler failed to process target
request header:
Microsoft.Dynamics.Retail.StoreConnect.Request.AXHandler.SCAXRequestHandlerException:
AX target request handler failed to process request: AX Managed Interop
failure. ---> Microsoft.Dynamics.AX.ManagedInterop.ErrorException:
              
Error when bulk inserting data.

Target table: RetailTransactionTable

Target columns: createdBy,modifiedby,

 

Check if these fields are disabled by the
license configuration keys.

If the configuration keys are correct,
change the transfer fieldlist on the scheduler subjob.

It is also not allowed to add system
fields to the Transferfield list 'CreatedBy,ModifiedBy, ModifiedDateTime,
CreatedDateTime, CreatedTransactionId, ModifiedTransactionid, Recid, RecVersion'

 

System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.InvalidOperationException: The given ColumnMapping does not match up
with any column in the source or destination.

   at
System.Data.SqlClient.SqlBulkCopy.AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet
internalResults)

   at
System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal()

   at
System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount)

   at
System.Data.SqlClient.SqlBulkCopy.WriteToServer(IDataReader reader)

   --- End of inner exception
stack trace ---

   at
System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object
target, Object[] arguments, SignatureStruct& sig, MethodAttributes
methodAttributes, RuntimeType typeOwner)

   at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

   at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture)

   at
Microsoft.Dynamics.AX.ManagedInterop.ClrBridgeImpl.InvokeClrInstanceMethod(ClrBridgeImpl*
, ObjectWrapper* objectWrapper, Char* pszMethodName, Int32 argsLength,
ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException)

t100543_890F916D362F4C1C8368EE4FEECE4AF2.1

   at
Microsoft.Dynamics.AX.ManagedInterop.Object.CallWithReturnType(String
methodName, Type returnType, Object[] paramList)

   at
Microsoft.Dynamics.AX.ManagedInterop.Object.Call(String methodName)

   at
Microsoft.Dynamics.Retail.StoreConnect.Request.AXHandler.SCAXTargetRequestHandler.ProcessTargetRequestHeader(ISCTargetRequestHeader
targetRequestHeader)

   --- End of inner exception
stack trace ---

   at
Microsoft.Dynamics.Retail.StoreConnect.Request.AXHandler.SCAXTargetRequestHandler.ProcessTargetRequestHeader(ISCTargetRequestHeader
targetRequestHeader)

   at
CCommMgr.ProcessTargetRequest(CCommMgr* ,
basic_string<wchar_t\,std::char_traits<wchar_t>\,std::allocator<wchar_t>
>* r_file_path, SCRequestHandlerManager scRequestHandlerManager)

 

 

 

Author: Kim Truelsen

Release date: 3/12-2012