我坚持创建一个批处理作业,它有两个任务——一个用于从暂存表中获取数据,另一个用于将数据从暂存表导出到平面文件。
第一个任务需要我调用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();
}
}