Problem writing files with EnsLib.EDI.XML.Operation.FileOperation, %f is ignored

Hi,

I have very recently started to work with Ensemble and have both the 2014 and the 2017 version. 

To learn, I have created a small test flow that takes an xml file using EnsLib.EDI.XML.Service.FileService, sends it to a Process that transforms it with xslt into another format, and then passes it onwards to a EnsLib.EDI.XML.Operation.FileOperation Business Operation. 

This is the code that I have before and when sending it onwards:

set tStatus=##class(%XML.XSLT.Transformer).TransformStreamWithCompiledXSL(xmlStreamObj, tCompiledStyleSheet, .pOutput, err)
If $$$ISERR(tStatus) quit tStatus
if $$$ISERR(err) quit err
Do tCompiledStyleSheet.%Close()

Do pOutput.Rewind()
set xmlResultDoc=##class(EnsLib.EDI.XML.Document).ImportFromLibraryStream(pOutput, .tStatus)
If $$$ISERR(tStatus) quit tStatus

set tStatus=..SendRequestSync(..TargetConfigName,xmlResultDoc,.pResponse)

And this is how the settings on the BO looks like:

(I also tried adding a \ to the end of the file path)

This is the error message I get

ERROR <Ens>ErrGeneral: Failed to open for (over)write 'E:\Integration\labb\destination\ : <NOTOPEN>zopen+13 ^EnsLib.File.OutboundAdapter.1

It seems that Ensemble ignores the %f even though the help instructions on the field says it's supported. I tried this in both Ensemble 14 and 17. 

If I add a filename to the "File Path" field, it works and the file is created with the translated content, however, this is not a good solution since it requires me to predetermine the file name when creating the endpoint rather than dynamically taking the file name from the incoming file.

version: 2017.2.1.801.3

Am I doing it wrong or is it a bug in the FileOperation?

  • 0
  • 0
  • 68
  • 0
  • 1

Answers

File operations pull the value for %f from the "Source" property of the EnsLib.EDI.XML.Document object. In your code sample you're creating a new EnsLib.EDI.XML.Document and copying the output from your XSLT transformation into it, but you're not setting Source to anything. As an experiment, try setting Source to a value and confirm that your output file is given that name.

set xmlResultDoc.Source="MyFileName.xml"


If you want %f to use the same filename as the original input file then you'll want to grab the Source value from your original object that was created by the business service and copy it to xmlResultDoc.Source.