Skip to Content

Have you ever encountered a situation where you need to zip multiple files and creating a single zipped file in the target directory? The first approach that wouls have come across will be to use the option of additional files present in the File Sender Adapter. But pretty soon you would have realized its major drawback. (File adapter only allows to pick additional files which has a part different in them.) So the next approach, have you heard about the OS Commands and PayloadZipBean and wondered how powerful the module is?  In this blog I which will update you the design approaches which can be used in these types of situations.  

Scenario I

To zip multiple files (with different name and extensions) and to create a single target zipped file.  

Approach

Use the following OS Commands: cmd /C “jar cvfM \\machine-name\foldername\zippedfolder\test.zip -C \\machine-name\foldername\files2zip .” 

  1. Files which need to be zipped is kept in location : \\machine-name\foldername\files2zip
  2. Zipped file will be created in location \\machine-name\foldername\zippedfolder\zip and will have name test.zip.

 Additionally the files that are zipped now needs to be deleted, which can be done through the command cmd /C “DEL /Q “\\machine-name\foldername\files2zip \*.*”” This approach can be used for zipping multiple files and keeping the zipped file in a particular directory. 

Scenario II

There are multiple files available in a directory which needs to be zipped into a single zipped file. But the catch here is it is also having a XML file which first needs to be transformed and the transformed (output) file should be kept in the zipped file with the same name a the source xml file 

Approach

 

Start with the approach as mentioned in Scenario I.  Once all the files are zipped and kept in a folder, use a file adapter to pick the zipped file with the following modules and key.

 

image

 

The PayloadZipBean will unzip the contents of the zipped folder in SAP PI and the PayloadSwapBean will swap the current payload with a payload of type application/xml. Once the files are unzipped in PI, the current payload is taken randomly, we need to swap this payload with an xmlized payload (else our message mapping step will fail). In order to achieve PayloadSwapBean should be mandatorily used after PayloadZipBean. And finally which writing the file in target directory we need to use a file adapter with the payload zip bean with mode = zipAll;

 

image

 

Finally I will mention the advantages and disadvantages of this method.

Advantages:

  1. Functionality can be achieved by using OS Commands and Standard Modules
  2. Development/testing time for customized modules can be avoided

Disadvantages:

  1. You are first zipping and then unzipping the entire payload in PI, this could have been avoided by using a customized module which will pick only the required xml file and make it as the primary payload.
  2. The set of source files which need to be zipped should have only one xml file.

Zip1

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. abhishek salvi
    Hi,

    The configurations (for Zip module) mentioned in the weblog are provided in the SAP Note and Stefan’s blog as well. It would be of great help to us if you inlcude screenshots of testing also.

    Regards,
    Abhishek.

    (0) 
  2. abhishek salvi
    Hi,

    The configurations (for Zip module) mentioned in the weblog are provided in the SAP Note and Stefan’s blog as well. It would be of great help to us if you inlcude screenshots of testing also.

    Regards,
    Abhishek.

    (0) 
    1. Suraj S.R. Post author
      Dear Abhishek,

      I guess the blogs purpose was unclear to you. Let me try to put it this way: The purpose of this blog was to show the various complex business process which may prompt the user to write user Adapter Modules instead of using the standard modules available with PI.

      Here both the OS Commands and PI inbult modules power was harnessed inorder to achieve the functionality.

      Also the testing (MONI screens)screenshots were avoided to make the blog brief and also to avoid filling sdn space ( 🙂 !!!). Also I wished the reader to take this idea and do a testing themselves and share there experience here. They themselves can feel the combined power of OS Commands + Standard Modules of PI.

      Cheers
      Suraj

      (0) 
  3. Virendra Singh Somwanshi

    Hi Suraj

    Its a nice blog. Thanks for sharing. Currently I am working on simple File to file scenario where i have to pick a zip file from location unzip it (Contain multiple file) and send it to SAP Ecc application server. I am able to unzip the file in sender CC by using PayloadZipBean. But in receiver i am getting error. I am not using any Module configuration in receiver CC. In receiver i have only given path of application server. Do i need to configure module configuration here also. What are the config need to be done in receiver CC? Please suggest.

    Regards

    Virendra Somwanshi

    (0) 

Leave a Reply