cancel
Showing results for 
Search instead for 
Did you mean: 

SFTP sender - Process files with the same name

das87
Explorer
0 Kudos

Hi Experts,

I have the following requirement, to download an XML file and accompanying PDF from a Sender SFTP server and process them. Both files must have the same filename, so we can match the XML with the respective PDF.

The XML file will be converted to an INVOICE02 IDOC via message mapping, and the PDF will be archived into our DMS solution (IXOS) via an RFC call to our S/4 HANA on-prem system. I can split the processing via a Router but I didn't manage to "bundle" the XML and PDF. This is important because the SFTP server will have several "pairs" of XMLs and PDFs.

BR,

Daniel

View Entire Topic
Willem_Pardaens
Product and Topic Expert
Product and Topic Expert
0 Kudos

To make sure you can specify the exact PDF file to retrieve from the SFTP server, based on the filename of the XML file you're currently processing, I would leverage the Poll Enrich step.

In your SFTP Sender adapter, read only the XML files (filename = *.xml). In your flow, add a Poll Enrich step which connects to the SFTP server again to download the corresponding PDF file. This will guarantee you are processing the 'paired' PDF file.

Poll Enrich info: https://blogs.sap.com/2021/05/12/cloud-integration-use-poll-enrich-with-sftp-adapter/

das87
Explorer
0 Kudos

Hi Willem,

Thanks for your reply!

Do you know how I define the filename dynamically, so it would be taken by the poll enrich step?

My idea was to use a content modifier to create a property called "XML-FILE-NAME", however, the expressions ${in.CamelFileName} and ${in.CamelFileNameOnly} didn't work out, as shown in the error message below:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-b52da549-c7e5-4fb0-7397-1d74-1683652517437-72-2], cause: org.apache.camel.language.simple.types.SimpleParserException: Unknown function: in.CamelFileNameOnly
Ryan-Crosby
Active Contributor
0 Kudos

das877 it should be ${header.CamelFileNameOnly} but it's also important to note that obviously two files with the exact same name cannot exist in the same location. They are either stored in separate folders or on different systems, or have a different extension.

das87
Explorer

Hi,

I managed to overcome the situation via a message header called "xml_file" that used the expression "${file:onlyname.noext}".

Thanks for your contribution!

BR,

Daniel Santos