Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 10, 2015 at 09:39 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 28, 2015 at 03:28 AM

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

    Add comment
    10|10000 characters needed characters exceeded

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

      DynamicAttributeChangeBean - The no-mapping solution to changing Dynamic Configuration ... dynamically!

      Rgds

      Eng Swee

  • avatar image
    Former Member
    Oct 27, 2015 at 10:10 AM

    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 "";


    Error.JPG (40.8 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Santhoshi M

      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

  • Oct 29, 2015 at 01:46 AM
    Add comment
    10|10000 characters needed characters exceeded