Skip to Content

The use of the PayloadZipBean is tricky. I will show you a scenario where an XI message goes to a receiver file adapter. Here the payload is converted to a flat structure and the codepage is changed to ISO-8859-1 and then zipped.

With using additional modules in the receiver file adapter, it is not possible to use the standard conversion. The conversion must be done in another module. You can choose between the conversion of the MessageTransformBean which is described here or the XML-to-Text Conversion Module. You find the description in SAP help.

For changing the encoding it is not possible to use the encoding parameters of the file adapter (this would corrupt the zip file) but you can use the new Text Codepage Conversion Module.

Here you see the configuration of the file receiver channel:

image

You see the file name scheme end with .zip and the file type is set to Binary.

Here you see the modules in the module chain:

image

image

Now you see the modules in the row as described above. But why is the MessageTransforBean here? What is its purpose?
In the file adapter configuration you can only choose the name of the zip file. So you need to set the name of the file inside the zip file with help of this module. In this example we choose the file name file.txt.

Note: If you want to set the file name dynamically, you have to implement an adapter module. In this WIKI page you find a sample code. You need SP20/SP12 for this.

Here is the result displayed with WinRAR:

image

The parameters of the PayloadZipBean

The module name is: AF_Modules/PayloadZipBean

  • zip.mode
      You define if you want to zip or unzip the payload. For zipping you can have: zip or zipOne for zipping the main payload, zipAll for zipping the main payload and all attachments together and unzip for unzipping the payload.
  • zip.filenameKey
      You define how the files inside the zip file should be named. You can choose: payloadName, contentType, contentDescription, and contentDisposition. This parameter is not needed, when zip.mode is unzip.
  • You find more information about the PayloadZipBean in SAP note 965256 and Online Help.

    Here is a list of other useful adapter modules: Wiki XI Adapter

    To report this post you need to login first.

    24 Comments

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

    1. Michal Krawczyk
      Hi Stefan,

      can you tell me from which sp is this
      module available? (I didn’t find any restrictions in the note you mention but
      I don’t see this bean in SP17 in JNDI registry
      under AF_Modules context)

      Thank you,

      Regards,
      michal

      (0) 
    2. Bhavesh Kantilal
      Stefan,

      As XI’s File Adapter has serious limitations on the size of the file that it can pick up, taking this concept a further, would a solution of having the Sender File Adapter pick up a Zipped File, Unzip it and perform the text to XML conversion allow the Sender File Adapter to process bigger files?

      Your ideas / comments on this approach would be really useful.

      As usual your blogs provide some great tips, Thanks.

      Regards
      Bhavesh

      (0) 
      1. Stefan Grube Post author
        Hi Bhavesh,

        You have to keep in mind that the working memory of the server is the limit. When you use the zip module, the zipped file and the file inside are in memory the same time. So the zip module will reduce the maximal file size.

        When you want to process big files and are not able to use the split mechanism of the sender file adapter, you have to increase the hardware memory.

        Regards
        Stefan

        (0) 
    3. Alessandro Guarneri
      Nice to know about its existence.
      And also, I’m glad to see that SAP itself has come up with something I made on myself recently (The specified item was not found.), and that can be used with any SP level, of course.
      Finally, I’m really laughing when thinking that someone judged “crazy” my idea… They should tell SAP now. 😀

      Alex

      (0) 
      1. Stefan Grube Post author
        Hi Alessandro,

        I think there was a misunderstanding. You called the idea of a huge file mover “weird”. I just wanted to agree. I thougth that weird and crazy are synonyms. But it seems that I was wrong. I apoligize.

        Regards
        Stefan

        (0) 
    4. Sanjeev Shekhar Singh
      Hi Stefan,

      Thanks a lot for the blog. As a novice in XI it was very helpful and very easy to understand too.

      But while implementing it, i am getting an error stating:
      <<<<Message processing failed. Cause: com.sap.aii.af.service.util.configuration.ConfigurationExceptionSet: The following configuration errors were detected: – Either Header .fieldSeparator or Header .fieldLengths must be specified – Either Body .fieldSeparator or Body .fieldLengths must be specified >>>

      This is inspite of the fact that i have specified the fieldLength. I have also tried giving the fieldSeparator but the same error persisted. 🙁

      Can you please give your advice on this, where might i have gone wrong?

      Thanks and Regards,
      Sanjeev.

      (0) 
      1. Stefan Grube Post author
        According the error message I would assume that you need two parameters:

        Header.fieldLengths and Body.fieldLengths

        Make sure that you have no trailing spaces in the configuration.

        If you have further issues with the conversion, you should post the configuration and the payload to the SDN forum.

        Regards
        Stefan

        (0) 
    5. santosh pai
      I am using sender JMS adapter and the data will be kept as Zipped XML message to JMS queue in the JMS server.
      Before processing the XML messages have to be unzipped.
      As the zip file is kept in the queue.My question is can we use payloadzip bean to unzip the file in JMS adapter Module?
      (0) 
    6. PRAVEEN KURNI
      Thanks for the nice Blog,
      But I was trying a scenario – Multiple Files to Zipped Mail Attachment.
      Multiple files to be picked up using Sender File Adapter– selecting them as additional files in File adapter. These to be Zipped using PayLoadZipBean at Receiver Mail Adapter. Can you please help me in doing the scenario.

      Best Regards
      Praveen K Kurni

      (0) 
    7. Steve Böttcher
      Hello Stefan,

      thanks for this nice introduction for using the PayloadZipBean. I tried this in the same way and I’m additional using a self deployed Bean for file name dynamically like discribed in the sample code of the wiki.

      But now I’m facing some issues regarding the filetype. My compressed file is named like the content also with the same filetype. After studying the SAP Docu the PayloadZipBean should normaly change the filetype to “.zip”, but this does not happen. I still have the filetype “.txt” although the content is compressed.

      Do you have an idea what kind of configuration is facing this problem and how I can solve it?

      Thanks in advance for your help.

      greeting Steve

      PS: The ASMA configuration is set in the receiver communication channel.

      (0) 
        1. Steve Böttcher
          Hi Stefan,
          thanks for your respond. I’m not sure if I understand your answer correctly. I don’t have a problem with the name of the content and the zip file, it’s only the filetype which is not correct.

          Maybe it is easier to understand my problem if I would describe the process:
          1) The process is IDoc to File
          2) In the graphical mapping the filename will be set dynamically via UDF using the DynamicConfiguration
          3) The output file has to be zipped. Via using the MessageTransformBean the conversion will be done. By using a self deployed Bean the “contentType” will be set with the name from the DynamicConfiguration.
          4) The PayloadZipBean is using the filenameKey “contentType”.

          To transmit the set filename to the Communication Channel (DynamicConfiguration), the ASMA’s are set for “File Name”.

          The problem is not like follows. The file will for example dynamically be set to the name “Test_20110120_15.txt”. After the whole “error free” procedure the zipped file will be stored with the name “Test_20110120_15.txt” containing the original file “Test_20110120_15.txt”. My expectation is that the stored file is named “Test_20110120_15.zip”, but whatever I will do the file is never stored with the file type “ZIP”.
          The only way to set the file type to “ZIP” is to set the Name fix in the “File Name Scheme” and to deactivate the ASMA. But after that also my content File does not have the dynamically set name.

          Do you have any idea how to deal with this problem or how I can configure the Communication Channel to meat my expectations?

          Thanks a lot for your help

          Greetings Steve

          (0) 
          1. Stefan Grube Post author
            Read my answer again and combine it with your own experience. There is nothing to add from my side.

            Please use forum for technical discussions.

            (0) 
            1. Kiran K

              Hi Stefan,

              I have used the following confiugration to zip the out of MessageTransform Bean, But the zip file created is throwing an error “Unrecoverable zip file read error” when I try to open. But when I remove the payloadzip bean and create the txt file using Message Transform bean the output looks good. Please find below config which I have used.

              1   AF_Modules/MessageTransformBean Local Enterprise Bean Transform

              2 AF_Modules/PayloadZipBean Local Enterprise Bean zip

              3 CallSapAdapter

              Transform Transform.ContentType text/plain;charset=utf-8;name=”input.txt”

                              Transform.Class          com.sap.aii.messaging.adapter.Conversion

                              xml.conversionType     SimpleXML2Plain

                              xml.fieldFixedLengths  50

                              xml.addHeaderLine      0

              zip           zip.mode                     zipAll

                             zip.filenameKey           contentType

              Regards,

              Kiran.

              (0) 
    8. Anumeha Khandelwal
      This is regarding an issue I am facing in my current project.

      Issue Description :
      I have to pick 5 zip files from a source location (here , PI file directory location ) on the basis of a finish file for example done.dat (empty file).
      Post the zip files to target location (here ftp location ). Once all the five zip files are posted, the finish file should also be posted . Finish file should be posted to the target location ONLY AFTER all the zip files have been posted.

      Is there any approach where I can achieve this requirement. My major issue is posting the five zip files and the finish file after that, to the target location , I can pick the source files from the source location without bothering about the finish file(or even with the finish file, using sender file adapter with additional files options) . Since the receiver file adapter does not support attachments and neither can my requirement be fulfilled by Soap axis adapter on receiver end, as this posts the attachments in a folder .

      If you could provide some solution to post all the five files and then the finish file to the target location that would solve my problem.

      Looking forward for your  inputs .
      Thanks in advance.

      (0) 
    9. Hari Sonnenahalli

      Stefan-

      This is a fantastic blog.  Will this works for FILE adapter using NFS protocol to zip all the files in a given folder and delete the zipped files.

      Please let me know.

      Regards

      HS

      (0) 
    10. Arkesh Sharma

      Hi Stefan,

      I am working on a similar scenario where I have to only unzip the file in the target directory.

      Basically, I have to pick a zip file from the source directory and then unzip the file in the target directory. I tried all the combination but I am getting errors. The details of the error can found at the below discussion link –

      SAP PI 7.4 – PayloadZipBean Unzipping issue

      Please suggest something in this regard.

      Regards,

      Arkesh

      (0) 

    Leave a Reply