Stefan Cronje · May 23, 2017

Ensemble Service using File.InboundAdapter: File name of the file being processed


I have created a Business Service which uses the EnsLib.File.InboundAdapter. This service will call a business service which will create an acknowledgement file in a directory specified in the operation after loading the parsed file into some temporary tables.

In order to create the acknowledgement file, I need the original file name. In the OnProcessInput of the service, it receives a stream of file data, and I can't find a way to get hold of the file name.

Any advice will be appreciated, thank you.

0 1,063
Discussion (5)2
Log in or sign up to continue

Do you have any data transformations along the way?  If so be sure to move the %Source property.

There are no transformations.

I create a new message and call an Operation using ProcessAsync in the Business Service. This message has a property for the File Name which I want to populate. with the name of the original file picked up by the business service.

Let me recap what I think I understand.  You have a business service that uses an inbound file adapter.  The OnProcessInput method of that service builds the message that then gets sent into the production.  The input parameter of the OnProcessInput is a file character stream of some kind.  You want to get the filename associated to that stream to add to your message.

If all the above is true then you need to access the 'filename' property of the stream.  Note that the exact property may depend on the stream class being used.  'Filename' will work with any file based stream in the %Stream package or those stream classes defined in %Library.  If this stream is of type Ens.StreamContainer then use the 'OriginalFilename' property.

If I am still not clear perhaps you could share at least some of the implementation of you OnProcessInput method and the details of the message class you are building.

One other question would be how are you trying to incorporate the source filename into the output filename?  Are you using the %f filespec?

Thank you. The parameter of OnProcessInput being a %Stream.Object confused me, as that has no FileName property in the class reference. The FileName property did however work. I realize now that a FileCharacterStream object is passed to the OnProcessInput from the File InboundAdapter.

Regarding your question: I use the original file name in a Business Operation, which uses the File.OutboundAdapter. I concatenate a suffix to the original filename and then use putline of the OutboundAdapter to create the file.


The stream has an attribute called "Filename" that you can query like this on your OnProcessInput():

Set tFileName=pInput.Attributes("Filename")

You can query the same attribute on your Business Process or Business Operation.

This is documented on the Adapter documentation here.

Kind regards,