This article illustrates how to handle zip files in SAP PI/PO. We will go through a demo integration scenario where zip files should be extracted and processed via an Asynchronous interface. To unzip the compressed payload, we will use the adapter module “PayloadZipBean”.
In this article, we will discuss,
- The design of the demo integration scenario
- Properties of adapter module “PayloadZipBean”
- Zip file handling interface development steps in ESR
- End-to-end iFlow configuration in Eclipse NWDS
- Zip file processing pipeline in PRO message monitor and end-to-end interface testing
Demo Interface Scenario Overview
Each zip file contains an XML file and a PDF file; zip files are located in an SFTP server. XML file contains invoice data and the PDF is the corresponding PDF of the invoice. We need to extract each zip file from the input SFTP folder, map the invoice XML to a target XML format, and save the PDF to the target folder.
The integration strategy is to map the invoice XML to the target structure using a graphical mapping program and copy the PDF attachment to target using a Java Mapping program. I have written a separate post on how to implement the Java Mapping to handle the PDF as an attachment.
In this article, we will focus mainly on how to unzip the incoming zip file and on the integration strategy to process the different types of files included in it.
Refer to the linked article if you are interested in learning how to attach a file to an SAP business document using an ABAP processing logic.
How to Unzip Files in SAP PI/PO
The most common way to unzip incoming zip files in SAP PI/PO is using the adapter module “AF_Modules/PayloadZipBean”. You can use “AF_Modules/PayloadZipBean” to either extract the individual payloads of a zipped file or to compress multiple payloads to a zip file.
Unzip File using “AF_Modules/PayloadZipBean”
This adapter module can be used with any adapter type in SAP PI/PO, if the adapter is extendable, i.e. adapter type allows the use of adapter modules. Here is a list of adapter types in SAP PI/PO where the module chain can be implemented.
To use this adapter module for purposes of compressing and uncompressing files, we need to utilize several parameters.
Here is a list of parameters of the adapter module PayloadZipBean with their functionality and permitted values.
|zip.mode||zip or zipOne||zip or compress the main payload|
|zipALL||zip all payloads of the message|
|unzip||unzip the incoming message and extract the payloads|
|zip.filenameKey||payloadName, payloadType, contentDescription, contentDisposition||Define how the files inside the zip file should be named. Only required for zip.mode zip.|
How to Configure the Communication Channel with PayloadZipBean
To Unzip files through the sender adapter, PayloadZipBean should be assigned to the Communication Channel as shown below.
Parameter “mode” should be configured as “unzip”.
Zip File Handling Interface Implementation Guide
Now we will look at how to implement the interface that unzips files and routes the payloads to desired locations step by step.
We will first go through ESR development steps and then understand how to bring those objects together as an iFlow. To implement the iFlow, you need to have Eclipse NWDS installed.
The steps on how to implement the PDF processing part of the interface is illustrated in my previous article on attachment handling in SAP PI/PO. In this article, we will look at the remaining configuration steps.
Implementation Steps in ESR
Create Source Message Type
This will be the source Message Type for invoice XML and attachment.
Build an Outbound Service Interface
Using the sender Message Type created in the previous step, develop the sender Service Interface for zip file sender.
Define Target Message Types
We will create two target message types, one for invoice XML receiver and the other one for the PDF. Check out my previous post on attachment handling to learn the Message Type strategy for PDF payload.
Message Type for invoice XML: InvoiceXML
Configure Two Inbound Service Interfaces
We will build two Inbound Service interfaces, one for invoice XML receiver and the other one for the PDF receiver.
Inbound Service Interface for invoice XML: InvoiceXML_Inb_Async
Inbound Service Interface of the PDF receiver is illustrated in the article on attachment processing.
Configure the Invoice XML Message Mapping and Operation Mapping
We will build a graphical mapping in the usual way to map the sender invoice XML format to the target invoice XML format. In this example, the message formats at the sender and receiver are exactly the same, therefore, the mapping is one-to-one.
Message Mapping: InvoiceXML_to_InvoiceXML
This Message Mapping program will map the main payload which is the invoice XML to target message format. In this example, it is a one-to-one map between source structure and target structure.
Operation Mapping: InvoiceXML_to_InvoiceXML
Java Mapping I have created to handle the PDF as an attachment and its Operation Mapping configuration are illustrated in the attachment processing post.
iFlow and Integrated Configuration Development
Now that we have designed all the necessary objects in ESR, let’s configure the end-to-end iFlow in NWDS Eclipse.
Zip File Processing iFlow
Here we have the end-to-end zip file handling interface implemented as an iFlow via Eclipse NWDS.
Sender System and Sender Service Interface
The sender system is BC_TEST_SENDER and the Inbound Service Interface name is InvoiceXMLwithAttachment_Out_Async.
Zip File Sender SFTP Adapter
Sender Communication Channel is of adapter type SFTP and its name is SFTP_s_ZIP. This Channel picks up zip files from SFTP server.
Here is how you need to configure the adapter module ZippayloadBean in the sender Communication Channel.
Invoice XML Receiver Service Interface
PDF Receiver Service Interface
Attachment PDF Receiver Communication Channel
SFTP_r_PDF is the SFTP receiver Communication channel that writes PDF files to the specified folder.
Tips and Tricks: Make sure to deactivate the option “Store attachments” in the receiver Communication Channels. Since we have two payloads in the XI message, both will be passed to the receiver Channels. By deactivating option “Store attachments” we suppress the unnecessary payload at the receiver.
Operation Mapping – Main Payload (invoice XML)
Operation Mapping – PDF
Testing the Zip File Processing Interface and Its Processing Pipeline
Let’s place a zip file with invoice XML and PDF in zip file sender SFTP folder.
First, invoice.zip will be unzipped by the sender SFTP adapter using the adapter module “AF_Modules/PayloadZipBean”. invoice.xml will be assigned as the main payload of the XI message and PDF will be assigned to the message as the first attachment.
Zip File Interface Processing Pipeline
Let’s look at the message processing pipeline of the Zip file processing interface in SAP PI/PO. We will go through the message processing steps using the SAP PI/PO message monitor.
Message Processing Overview in Message Monitor
File Unzipped from Sender Adapter
Main Payload and Attachment in XI Message Content
Inbound Message Split into Two
Main Payload Mapping
The main payload, invoice XML, is mapped to the target invoice format by a graphical Message Mapping program.
Main Payload Sent to Receiver Adapter
Main Payload File Created
Attachment Processed by Java Mapping
PDF Payload Delivered to Attachment Receiver Communication Channel
Attachment PDF Saved in Receiver SFTP Location
Now you know how to handle zip files in PI/PO interfaces, as well as understand the importance of the adapter module “PayloadZipBean” and its parameters. If you have any questions or if you implemented zip file handling interfaces in a different way, please leave a comment below.
SIGN UP TODAY!
Sign up to receive our monthly newsletter and special deals!
TECH GADGETS I USE EVERY DAY
These are some of the tech gadgets I use every day. If you make a purchase through these links I will earn a small comission at absolutely no extra cost to you.