我坚持创建一个具有两个任务的批处理作业 - 一个用于从登台表获取数据,另一个用于将登台表中的数据导出到平面文件。
第一个任务要求我调用DMFStagingWriter class
并且它是'工作正常,我的批处理可以将数据填充到临时表中。但是,当我尝试添加一些代码来完成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();
}
}