Sometimes we get a requirement to update the data before it gets inserted into the staging table.
Here I'm using "postGetStagingData" method to update the data before it gets inserted into the staging table.
[ExtensionOf(tableStr(DemandForecastEntity))]
final public class DemandForecastEntity_Extension
{
public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
DemandForecastEntityStaging demandForecastEntityStaging ;
InventDimCombination inventDimCombination;
InventDim inventDim;
while select forupdate demandForecastEntityStaging where demandForecastEntityStaging .DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup
&& demandForecastEntityStaging .ExecutionId == _dmfDefinitionGroupExecution.ExecutionId
&& demandForecastEntityStaging .TransferStatus == DMFTransferStatus::NotStarted
{
inventDimCombination.clear();
inventDim.clear();
select firstonly inventDimCombination
where inventDimCombination.ItemId == demandForecastEntityStaging .ItemNumber
join inventDim
where inventDim.inventDimId == inventDimCombination.InventDimId;
if(inventDimCombination)
{
ttsbegin;
demandForecastEntityStaging .ProductConfigurationId = inventDim.configId;
demandForecastEntityStaging .ProductColorId = inventDim.InventColorId;
demandForecastEntityStaging .ProductSizeId = inventDim.InventSizeId;
demandForecastEntityStaging .ProductStyleId = inventDim.InventStyleId;
demandForecastEntityStaging .doUpdate();
ttscommit;
}
}
}
}
In the same way you can use "PostTargetProcess" method if you want to update the data before it gets inserted into the target tables.
This method is automatically called by the DMFEntityWriter class in the end of processRecords() method when all records are transferred from staging to target. It is not available from override method drop down on Data Entity because it is static and is called via reflection.
Please note that it can be done only in data management scenarios but not via OData because OData updates\inserts records row by row and there is no post event\method to use.
@Rahul
Here I'm using "postGetStagingData" method to update the data before it gets inserted into the staging table.
[ExtensionOf(tableStr(DemandForecastEntity))]
final public class DemandForecastEntity_Extension
{
public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
DemandForecastEntityStaging demandForecastEntityStaging ;
InventDimCombination inventDimCombination;
InventDim inventDim;
while select forupdate demandForecastEntityStaging where demandForecastEntityStaging .DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup
&& demandForecastEntityStaging .ExecutionId == _dmfDefinitionGroupExecution.ExecutionId
&& demandForecastEntityStaging .TransferStatus == DMFTransferStatus::NotStarted
{
inventDimCombination.clear();
inventDim.clear();
select firstonly inventDimCombination
where inventDimCombination.ItemId == demandForecastEntityStaging .ItemNumber
join inventDim
where inventDim.inventDimId == inventDimCombination.InventDimId;
if(inventDimCombination)
{
ttsbegin;
demandForecastEntityStaging .ProductConfigurationId = inventDim.configId;
demandForecastEntityStaging .ProductColorId = inventDim.InventColorId;
demandForecastEntityStaging .ProductSizeId = inventDim.InventSizeId;
demandForecastEntityStaging .ProductStyleId = inventDim.InventStyleId;
demandForecastEntityStaging .doUpdate();
ttscommit;
}
}
}
}
In the same way you can use "PostTargetProcess" method if you want to update the data before it gets inserted into the target tables.
This method is automatically called by the DMFEntityWriter class in the end of processRecords() method when all records are transferred from staging to target. It is not available from override method drop down on Data Entity because it is static and is called via reflection.
Please note that it can be done only in data management scenarios but not via OData because OData updates\inserts records row by row and there is no post event\method to use.
/// <summary
/// Executes the logic once after processing the target data.
/// </summary>
/// <param name= “_dmfDefinitionGroupExecution">
/// The definition group that should be processed.
/// </param>
public
static
void
postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
//check if import job is finished
if
(_dmfDefinitionGroupExecution.StagingStatus == DMFBatchJobStatus::Finished)
{
MyStaging myStaging;
//select all staging records that were processed by current execution job without errors.
while
select
myStaging
where
myStaging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup
&& myStaging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId
&& myStaging.TransferStatus == DMFTransferStatus::Completed
{
//here you can find newly created records and update\post them.
}
}
}
@Rahul
Thanks for your post Rahul
ReplyDeleteYou're welcome!
DeleteI’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... CRM for Outlook
ReplyDeletehi ,
ReplyDeletelike u said for postTargetProcess method cannot be used for OData , then what should we use in its place for Odata
postTargetProcess cannot be done via ODATA because ODATA updates, inserts records row by row and there is no post event\method to use
DeleteThe concept of a "lucky charm" is prevalent in FairGO. Many players have their own rituals and items they believe bring good fortune.
ReplyDelete