ステージング テーブルからデータを取得するためのタスクと、ステージング テーブルからフラット ファイルにデータをエクスポートするためのタスクの 2 つのタスクを持つバッチ ジョブの作成に行き詰まっています。
最初のタスクでは、呼び出す必要があり、DMFStagingWriter class
正常に動作します。バッチはデータをステージング テーブルに入力できます。ただし、呼び出された2番目のタスクを完了するためにコードを追加しようとするdmfStagingToSourceFileWriter class
と、今のところできませんでした。コードのこのコメント"// Write from Staging table to file"
で始まる部分があり、ステージング テーブルからファイルにデータをエクスポートするのに役立つ正しいコードを書くのが困難です。
私は何が欠けていますか?
ありがとうございました。
public void run()
{
DMFDefinitionGroup definitionGroup;//nom proccessing group
DMFDefinitionGroupEntity definitionGroupEntity;
DMFEntity dMFEntity,localEntity;
DMFExecutionId executionId;//nom job
boolean execute;
DMFDefinitionGroupExecution definitionGroupExecution;
DMFStagingWriter stagingWriter;
SAUDMFVendPackingSlipTrans vendPackingSlipTrans;
SAUDMFVendPackingSlipTransDetails vendPackingSlipTransDetails;
DMFEntityType dmfEntityType;
DMFdefinationGroupName definationGroupName;
DMFDataSourceProperties dataSourceProperties;
DMFSourceName source;
FilenameSave filePath;
str headerRow;
DMFStagingToSourceFileWriter dmfStagingToSourceFileWriter;
select firstOnly definitionGroup
join definitionGroupEntity
where definitionGroup.DefinationGroupName == definitionGroupEntity.DefinitionGroup
join dMFEntity
where definitionGroupEntity.Entity == dMFEntity.EntityName
&& dMFEntity.EntityName == "sauVendPackingSlipTrans"
&& definitionGroup.DefinationGroupName == "VendPackingSlipTransAx";
select firstonly vendPackingSlipTransDetails
join vendPackingSlipTrans
where vendPackingSlipTransDetails.SAUDMFVendPackingSlipTrans == vendPackingSlipTrans.RecId ;
executionId = this.getExecutionMethod(definitionGroup.DefinationGroupName);//nom proccessing group
// if no file set, then use repository mode
if(!fileName)
{
execute = DMFDefinitionGroupExecution::serviceInsertOrDisplay( definitionGroup,
executionId,
dMFEntity.EntityName,
'',
'',
vendPackingSlipTransDetails.ProcessingFolder,
vendPackingSlipTransDetails.CompletedFolder,
vendPackingSlipTransDetails.ErrorFolder,
NoYes::Yes,
DMFFileType::File,
1,
vendPackingSlipTransDetails.AccessFolder);
}
// else use file mode
else
{
execute = DMFDefinitionGroupExecution::insertOrDisplay( definitionGroup,
executionId,
'',
NoYes::No,
fileName);
}
definitionGroupExecution = DMFDefinitionGroupExecution::find(definitionGroup.DefinationGroupName,
dMFEntity.EntityName,
executionId);
if(execute)
{
ttsBegin;
definitionGroupExecution.selectForUpdate(true);
definitionGroupExecution.ExecuteTargetStep = NoYes::Yes;
definitionGroupExecution.Update();
ttsCommit;
//Write from ax to stagingWritting
stagingWriter = new DMFStagingWriter();
stagingWriter.parmDMFExecution(DMFExecution::find(executionId));
stagingWriter.parmcalledFrom(true);
stagingWriter.parmInBatch(this.isInBatch());
if(!fileName)
stagingWriter.sauParmRunOnService(true);
stagingWriter.run();
//Write from Staging table to file
definationGroupName = vendPackingSlipTransDetails.StaggingToFileDefGrp;
select firstOnly definitionGroupEntity
where definitionGroupEntity.DefinitionGroup == definationGroupName;
// check if definition group exists
if(!definitionGroupEntity.DefinitionGroup)
throw error(strFmt("Le groupe de traitement %1 n'existe pas", definationGroupName));
source = definitionGroupEntity.Source;//vendPackingSlipTrans_file
// if file name correctly set (mandatory)
if(vendPackingSlipTransDetails.Export_Prefix && vendPackingSlipTransDetails.Export_FileExtension)
{
//filePath = FolderPath + prefixfileName + grpAx + extension;
filePath = strFmt("%1%2_%3_%4", vendPackingSlipTransDetails.FolderPath,
vendPackingSlipTransDetails.Export_Prefix,
vendPackingSlipTransDetails.AXToStaggingDefGrp,
vendPackingSlipTransDetails.Export_FileExtension);
// set first line if required
if(vendPackingSlipTransDetails.ExportFileHeader)
headerRow = this.setHeaderRow(dataSourceProperties.FileColumnDelimiter, vendPackingSlipTransDetails.Export_Prefix);
}
else
throw error(strFmt("Le préfix doit être renseigné dans le paramétrage d'export de l'entité %1", entityType));
// Shared folder has to be set
if (!DMFParameters::find().SharedFolderPath)
throw error("@DMF1444");
// Shared folder has to be accessible
if (DMFParameters::find().ValidationStatus != NoYesError::Yes)
throw error("@DMF1415");
// export to file
dmfStagingToSourceFileWriter = DMFStagingToSourceFileWriter::construct();
dmfStagingToSourceFileWriter.parmsourceTarget(DMFSourceTarget::Source);
dmfStagingToSourceFileWriter.parmEntityName(definitionGroupExecution.Entity);
dmfStagingToSourceFileWriter.parmDefinitionGroupExecution(definitionGroupExecution);
dmfStagingToSourceFileWriter.sauParmDMFEntityType(DMFEntity::find(definitionGroupExecution.Entity).Type);
dmfStagingToSourceFileWriter.sauparmHeaderRow(headerRow);
dmfStagingToSourceFileWriter.saveLast();
dmfStagingToSourceFileWriter.sauVariablesSetter([definationGroupName,source,filePath]);
dmfStagingToSourceFileWriter.run();
//dmfStagingToSourceFileWriter.exportRun();
}
}