This blog describes the use of CamelFilename header while zipping the files using Zip function in SAP Cloud Integration ,Build number 6.27.9 !
When using zip function in sap cloud integration make sure to set the header CamelFileName before the Zip function.Also CamelFileName header should not be set explicitly in FileName parameter in SFTP Receiver Adapter. [ If set Dynamic Value of ${header.CamelFileName}is lost and rather file name is just ” ${header.CamelFileName}”]
1.What if CamelFileName header is not set before the Zip function function.
1.a) Set Header FileName = Test_${date-with-timezone:now:CET:dd-MM-yyyy}.csv
Using FileName as ${header.FileName} without using .zip extension in the sftp adapter.
Let us try to understand the first case. I have used a sample flow where a Xml file is converted to csv and we zip the csv file and put it into the SFTP folder.
Using the Content Modifier : Setting the FileName we have created a header FileName
We set the FileName in sftp receiver channel as ${header.FileName} [ Note we have not used the .zip extension]
When we try to hit the IFlow with XML, we have the following csv file in the sftp target folder.
We can see that the .zip type is missing in the file as well as when i tried to open the file it was corrupt. Actual Size of the Proper CSV file was about 237 Kb .. which we will see later .
1.b) Set Header FileName = Test_${date-with-timezone:now:CET:dd-MM-yyyy}.csv
Using FileName as ${header.FileName}.zip in the sftp adapter
In this case you will have a zip file in the SFTP Folder, but compressed file would have automatically assigned name with type as “File”.
When the target system unzips, looks up for a specific naming format , this could lead to problems as now the actual intended filename pattern would become a folder under which the compressed file would be saved as type “File” with a automatically assigned file name.
2.What if CamelFileName header is set before the Zip function
Now, i have changed the IFlow to set the header ‘ CamelFileName‘ before the ZIP function .
We should not set the FileName in sftp receiver channel.The SFTP Adapter takes CamelFileName header set in Iflow as FileName.[ On setting the ${header.CamelFileName} explicitly in sftp adatper, no dynamic value is carried over and rather filename in SFTP become “${header.CamelFileName}”]
When we try to hit the IFlow with XML, we have following zip file in the sftp target folder. Also the unzip file contains the same file name pattern as intended.
The explanation for above behavior could be due to the fact that CamelFileName header is generated after zip compression and assigned a random value if not assigned before. I leave it upto the readers to build a basic flow and use simulation to understand the same.
One more behaviour is that CamelFileName header is lost when used in SFTP Adapter. I don’t have a concrete answer for that atleast now.
Update 1: CamelFileName header when set in Iflow is chosen as filename for SFTP receiver adapter when filename parameter is blank .When CamelFileName header is explicitly set as filename in SFTP Adapter, dynamic value of CamelFileName header is lost!