当提供的模板文件不能满足D365数据表的数据结构或者模板的数据不能直接通过DMF导入到实际的业务表时,我们按照模板自定义实体后,可以实现如下方法来将暂存表的数据通过一定的逻辑处理,将数据转换到我们的业务表中,sample代码如下
public static container copyCustomStagingToTarget(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution) { CustCustomerStaging staging; CustCustomerStaging stagingUpd; // Iterate through all records with have not been processed while select forupdate staging where staging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId && (staging.TransferStatus == DMFTransferStatus::NotStarted || staging.TransferStatus == DMFTransferStatus::Validated) { try { ttsbegin; // Do your stuff staging.TransferStatus = DMFTransferStatus::Completed; staging.update(); ttscommit; } catch (Exception::Error) { error("Something wrong has happened."); } } ttsbegin; update_recordset staging setting TransferStatus = DMFTransferStatus::Error where staging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup && staging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId && (staging.TransferStatus == DMFTransferStatus::NotStarted || staging.TransferStatus == DMFTransferStatus::Validated); ttscommit; // Method returns a container containing the quantities of inserted and updated records. select count(RecId) from staging where staging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup && staging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId && staging.TransferStatus == DMFTransferStatus::Completed; return [staging.RecId, 0]; }
需要注意的是,如下想上面的方法被正常执行,我们需要勾上实体上的Set-based processing字段
标签:staging,自定义,表到,DMFTransferStatus,D365,ExecutionId,&&,TransferStatus,dmfD From: https://www.cnblogs.com/dingkui/p/17375589.html