Introduction

When working with compressed ZIP files, the standard PayloadZipBean module can be configured in a communication channel to extract the entries from compressed files. However, the functionality of the module is limited whereby the main payload will be replaced by the first entry of the compressed file, while the other entries will be added as attachments to the same message.

Sometimes, the entries in the compressed file need to be further processed, and if they are of the same format, the same processing needs to be applied on each of the entries. This will necessitate custom Java development to access the attachments and apply transformation for each of the attachments.

UnzipSplitterBean aims to fill this gap by combining the logic in Java Mapping: Unzip file and create additional attachments and AttachmentSplitterBean – Split attachments into child messages. It allows for the extraction of the zip entries into separate child messages, thereby allowing the usual processing via graphical mapping instead of requiring custom Java to access the attachments.

Source Code and Deployment Archive

UnzipSplitterBean belongs in the same adapter module project as FormatConversionBean. Refer to following blog for the location of source code and/or EAR deployment file.

FormatConversionBean – One Bean to rule them all!

Module Parameter Reference

The JNDI name for the module is listed below for adding the module to the processing chain of a communication channel.

Module name = Custom_AF_Modules/UnzipSplitterBean

Below is a list of the parameters for configuration of the module. Certain parameters will automatically inherit the default values if it is not configured.

Parameter Name Allowed Values Default Value Remarks
reuse

Y, N

Y
  • Y = Indicates that the same scenario will be used for the child messages. Therefore the main payload will be replaced by the first entry from the compressed file
  • N = Indicates that the child messages will be routed to a different binding of another scenario
mimeType Valid MIME types application/xml Sets the MIME type used as the prefix of the content type of the child messages
fileNameAttr FileName Dynamic Configuration attribute used to store zip entry’s file name in child message
fileNameNS http://sap.com/xi/XI/System/File Dynamic Configuration namespace used to store zip entry’s file name in child message
mode

binding,

channel

Required field when reuse = ‘N’.

Determines which channel the child messages should be sent to

  • binding = Channel is determined via lookup of matching sender agreement based on child message header details
  • channel = Channel is determined from Object ID of channel (found under Object Properties of Comm Channel in Swing version of Integration Directory). The child message header details are determined from corresponding binding of the channel. When using this mode, ensure that the comm channel is only used in a single sender agreement/ICO/iFlow
adapterType Valid adapter types in the PI system

Required field when reuse = ‘N’ and mode = ‘binding’.

Adapter type for the channel where the child messages will be sent to

adapterNS

Required field when reuse = ‘N’ and mode = ‘binding’.

Adapter namespace for the channel where the child messages will be sent to

fromParty

Available when reuse = ‘N’ and mode = ‘binding’.

Sender Party of sender agreement where the child messages will be sent to

fromService

Required field when reuse = ‘N’ and mode = ‘binding’.

Sender Service of sender agreement where the child messages will be sent to

toParty

Available when reuse = ‘N’ and mode = ‘binding’.

Receiver Party of sender agreement where the child messages will be sent to

toService

Available when reuse = ‘N’ and mode = ‘binding’.

Receiver Service of sender agreement where the child messages will be sent to

interfaceName

Required field when reuse = ‘N’ and mode = ‘binding’.

Sender interface name of sender agreement where the child messages will be sent to

interfaceNamespace

Required field when reuse = ‘N’ and mode = ‘binding’.

Sender interface namespace of sender agreement where the child messages will be sent to

channelID

Required field when reuse = ‘N’ and mode = ‘channel’.

Object ID of the channel where the child messages will be sent to

messageLog

pre, post

Saves a log version of the message that is viewable in Message Monitor

  • pre = logs main message before splitting
  • post = logs main message after splitting
logLocation Name of log version when messageLog is populated. Location defaulted to value in messageLog if logLocation not populated

Example Scenarios

Scenario 1

Sender SFTP channel will pick up zip file and split the entries into separate messages. Default setting used for the module so same scenario will be reused for the child messages. The unzipped content will be delivered to an SFTP folder without further transformation.

Design

/wp-content/uploads/2016/03/iflow1_916373.png

Configuration

The sender channel will pick up all files ending with .zip extension.

/wp-content/uploads/2016/03/sender1_916374.png

The module is configured with no additional parameters.

/wp-content/uploads/2016/03/module1_916375.png

Testing

The following compressed file with 3 entries will be used for testing.

/wp-content/uploads/2016/03/testfile_916376.png

From the audit log, the module extracts the 3 entries, the first one will replace the main payload, while the other two will be dispatched as child messages to the same sender channel.

/wp-content/uploads/2016/03/log1_916377.png

The main payload is replaced by the first entry of the compressed file.

/wp-content/uploads/2016/03/main1_916378.png

In the audit log of the child message, processing by the module is skipped as the child message is already decompressed.

/wp-content/uploads/2016/03/skip_916382.png

Following is the payload for the child messages.

/wp-content/uploads/2016/03/child2_916383.png

/wp-content/uploads/2016/03/child3_916384.png

And finally, all the messages are delivered to the target folder.

/wp-content/uploads/2016/03/output1_916400.png

Scenario 2

The above scenario is enhanced so that the child messages are extracted and routed to a different scenario. The original compressed file will be delivered to the target folder unchanged.

Design

In addition to the iFlow in the above scenario, an additional iFlow is configured for routing the child messages to the target SFTP folder. The sender channel will be a SOAP sender.

/wp-content/uploads/2016/03/iflow2_916401.png

Configuration

The module configuration in the original SFTP channel (of iFlow 1) is configured as follows, so that the child messages are routed to the second iFlow. The header details (sender system/party, namespace and adapter type) should match the sender of the second iFlow above.

/wp-content/uploads/2016/03/param2_916402.png

Testing

From the results of the testing, there will be 1 message for the first iFlow and 3 child messages for the second iFlow.

/wp-content/uploads/2016/03/messages_916436.png

From the audit log, it is observed that all the zip entries are dispatched as child messages.

/wp-content/uploads/2016/03/log2_916437.png

And finally, the original compressed file and the zip entries are delivered to the target folder.

/wp-content/uploads/2016/03/output2_916438.png

Conclusion

As shown by the example scenarios above, processing of entries within a compressed file can be simplified with the use of UnzipSplitterBean. Although the examples show simplified passthrough processing of the child messages, these can be further enhance like any typical scenario, i.e. additional modules (FCC), graphical mapping, etc. It is much simpler to handle the entries as messages instead of attachments of a parent message.

To report this post you need to login first.

6 Comments

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

  1. Asif Khan

    Eng Swee your blogs are always very helpful and life saver.

    As usual this is very nice and helpful blog as we have many requirement where we have to work with the zip and this will really help as the standard module doesn’t have many functionality and is very limited.

    (0) 
    1. Eng Swee Yeoh Post author

      Hi Asif

      Thank you for your kind words. It’s always a pleasure to know that the solutions provided have been beneficial to others in the community 😉

      Best regards

      Eng Swee

      (0) 
    1. Eng Swee Yeoh Post author

      Hi Thorsten

      Only Zip as a start. Shouldn’t be too difficult to add support for Gzip. Will update this post when that is added.

      Thanks for the feedback.

      Regards

      Eng Swee

      (0) 
    2. Eng Swee Yeoh Post author

      Wait a sec! The idea of the module is to extract Zip files that contain multiple entries. GZip only supports compression of a single file.

      (0) 
  2. Prema Boodi

    Hi Eng,

    when i’m using Custom_AF_Modules/UnzipSplitterBean in sender communication channel. i have error in  Communication Channel Monitoring:

    Error: com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at Custom_AF_Modules, the whole lookup name is localejbs/Custom_AF_Modules/UnzipSplitterBean.

     do i have do anything other configuring?

    Thanks!

    (0) 

Leave a Reply