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.

IFlow%20without%20CamelFileName%20Set%20before%20ZIP%20function

IFlow without CamelFileName  header set before ZIP function

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

FileName%20Header%20in%20Content%20Modifier

FileName Header in Content Modifier

We set the FileName  in sftp receiver channel as ${header.FileName} [ Note we have not used the .zip extension]

FileName%20in%20SFTP%20Receiver%20Channel

FileName in SFTP Receiver Channel

When we try to hit the IFlow with XML, we have the following csv file in the sftp target folder.

ZIP%20Compressed%20CSV%20File%20in%20SFTP%20Folder

ZIP Compressed CSV File in SFTP 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

 

FileName%20in%20SFTP%20Receiver%20Channel

FileName in SFTP Receiver Channel

 

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”.

 

ZIP%20Compressed%20CSV%20File%20with%20type%20as%20File

ZIP Compressed CSV File 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

IFlow%20with%20CamelFileName%20header%20set%20before%20ZIP%20function

IFlow with CamelFileName header set before ZIP function

 

Now, i have changed the IFlow to set the header ‘ CamelFileName‘ before the ZIP function .

CamelFileName%20set%20in%20Content%20Modifier%20before%20ZIP%20Function

CamelFileName set in Content Modifier before 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}”]

SFTP%20Adapter%20Config

No FileName in SFTP Receiver Channel

 

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!

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x