How to debug composite entity with "Incorrect syntax near the keyword 'FROM'" exception?

2

I created a new composite entity based on two new entities. Those in turn are based on new views, which are based on new queries. The queries are based on a mix of standard tables and views and custom tables.

Similar composite entities were created in the past and work.

When exporting the composite entity with a data project, I'm getting the following exceptions:

Exception in AX-DIXFRuntime event log:

System.Exception: Incorrect syntax near the keyword 'FROM'.
   at Microsoft.Dynamics.AX.Framework.Tools.DMF.ServiceProxy.DmfEntitySharedTypesProxy.DoWork[T](Func`1 work)
   at Dynamics.AX.Application.DMFGenerateSSISPackage.`generateFileDataV2(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution, String _defGroupName, DMFFileFormat _fileFormat, DMFDelimiter _rowDelimiter, DMFDelimiter _columnDelimiter, String _codePage, String _locale, NoYes _isFirstRowHeader, NoYes _unicode, String _source, String _textQualifier, DMFXMLStyle _style, String _rootElement, String _filePath, Map _entitySyncVersion, Int32 _previewCount, Boolean @_entitySyncVersion_IsDefaultSet, Boolean @_previewCount_IsDefaultSet) in xppSource://Source/ApplicationFoundation\AxClass_DMFGenerateSSISPackage.xpp:line 1419

Exception in AX-DIXFSSISRuntime event log:

SSISexceptionMessage System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'FROM'. 
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) 
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) 
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) 
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() 
at System.Data.SqlClient.SqlDataReader.get_MetaData() 
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) 
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) 
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) 
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) 
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) 
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) 
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFCompositeEntity.GetDatasetForXMlExport(String stagingString) 
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFCompositeEntity.ExportCompositeEntityToXML() 
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelperService.Service.ServiceHelper.ExportCompositeEntityToXML(DMFCompositeEntity dmfCompEnt) ClientConnectionId:9a234a11-809d-4d88-828d-8981bfb4faa8 Error Number:156,State:1,Class:15 

What I've tried so far:

  • refresh the entities and composite entity with en-us language setting
  • debug DMFGenerateSSISPackage.generateFileDataV2 and compare with the export of a working composite entity > no obvious incorrect differences found
  • remove line entity from the composite entity > same issue
  • export header/line entity directly > works without issue

Question

My question is if there is a way to find out what the SQL is that caused the Incorrect syntax near the keyword 'FROM' exception. If there is no way, I'm happy to hear suggestions how I can further narrow down this issue.

ssis
dynamics-365-operations
asked on Stack Overflow Feb 10, 2020 by FH-Inway

1 Answer

3

The issue is caused by the length of the label text of the composite entity and the length of the entity names. They must not exceed a limit of 99 characters.

Assume that you have two entities with names

  • VeryLongNameWithSixtyCharactersThatIdentifyTheFirstEntity123 (60 characters)
  • AnotherLongNameWithSeventyCharactersThatIdentifyTheSecondEntity1234567 (70 characters)

Also assume that the label text of your entity is the following

  • Label text with 30 characters1

If you navigate to workspace Data management and open the list of entities, find the composite entity named Label text with 31 characters1 and open "Child entities". It will show 2 entries named

  • Label text with 30 characters1_VeryLongNameWithSixtyCharactersThatIdentifyTheFirstEntity123 (90 characters)
  • Label text with 30 characters1_AnotherLongNameWithSeventyCharactersThatIdentifyTheSecondEntity1234567 (100 characters)

This composite entity will export correctly.

But if you add another character to the name of the second entity, the second entry of the child entities will have 101 characters. This will cause the described exception error.

Fix by Microsoft

In issue 2086 of the Microsoft documentation, they announced to introduce a check during compile time for this in PU 36 which is currently under investigation. See KB4549600.

answered on Stack Overflow Feb 10, 2020 by FH-Inway • edited Feb 25, 2020 by FH-Inway

User contributions licensed under CC BY-SA 3.0