cancel
Showing results for 
Search instead for 
Did you mean: 

Need to create zip with name same as input file name from .txt file-Pass through Interface

0 Kudos

Hi Experts,

I have to create a File to File interface using FTP adapter (Passthrough Interface)

Requirement : I need to create zip with name same as input file name.

Input file will have name like –SH_YYYYMMDD_HHMMSS.txt.

I need to achieve this functionality using the standard PayloadZipBean OR using Dynamic configuration (in dummy graphical mapping).

I have already gone through links which suggest solution of Adapter Module and Java Mapping but i want to do it using standard module or Dynamic Bean.

Please suggest how to proceed.

Regards

Rajat

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi All,

This has been done using Dynamic Configuraton Bean,Payload Zip Bean and variable substitution in receiver channel.

Input file name abc.txt.

output File name abc.txt but zipped.

Thanks for your help and inputs.

Regards

Rajat

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos
engswee
Active Contributor
0 Kudos

Did you try adding the parameter zip.filenameKey = contentType?

0 Kudos

Hi,

I tried creating a pass through scenario with 2 File channels.

Both file channels have ASMA ticked and module has been used in Receiver channel.

PFA screenshot.

When i place a file in source folder (.txt) with content as 1;2;3 then i am getting the same file at the target side with the same name.( not zip but .txt) and some junk content as :

PK        ÚZ\G                untitled.xml3´6²6  PK  [¦ÄÙ        PK          ÚZ\G[¦ÄÙ                          untitled.xmlPK          :   A   

Let me know what options can be used.

Regards

Rajat

engswee
Active Contributor
0 Kudos

Hi Rajat

The junk content you are seeing is actually the zip file. Try downloading the file to your PC and change the extension to .zip, then open it in WinZip/7Zip, and you will see that it is actually a compressed archive.

Do understand that file name and actual content are two different things here. PayloadZipBean just deals with the content and the name of the compressed item within the enclosing zip file.

If you want to change the name of the file that is written by the receiver adapter from .txt to .zip, unfortunately there is no standard solution for this that can handle dynamic filename values. If you insist on it being a pass through interface, then you need a custom module. You can consider the following.

Rgds

Eng Swee

0 Kudos

When i am using ASMA at both sender and receiver side and using a dummy mapping in PI i am getting the .zip file with required name but it is a corrupted file.

UDF:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keyFileName = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

String keyval = conf.get(keyFileName);

String outfile = keyval.replaceAll(".txt",".zip");

conf.put(keyFileName,outfile);

return "";

sahithi_moparthi
Contributor
0 Kudos

Hi,

Try using Payload Zip Bean Module in your configuration.Please gothorugh below link:

http://scn.sap.com/people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the...

0 Kudos

Hi Sahithi,

Thanks for the prompt reply.

Case 1 : When i had xml data in a .txt file so it worked (with ZipBean) but the name of the file was MainDocument and i had to open it with notepad.

Case 2: When i add dummy data like 1234 it fails.


Please suggest solution for Case 2 as my file would have data like 1;2;3; in a .txt file.


Regards

Rajat