Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Recently I had developed a IDOC to HTTPs Asynchronous scenario in SAP PI 7.5. There was a requirement integrating SAP ECC(client) and Amazon S3 (server) via EAI SAP PI 7.5.

In the server side, file name should be delivered as an Attachment in a csv multi form data. SAP has provided a Java method to read the attachment data and content type, content disposition, content ID, but there is no standard function to read the attachment file name.

The new Java HTTP_AAE adapter supports attachments, Multipart Documents, form submission. HTTP_AAE adapter also provides options to send HTTP Header Parameters, Query Parameters and HTTP URL parameters in the dynamic header of the PI message.

To read the form data attachment ‘name’ and ‘filename’ as Content-Disposition (content which is expected to be displayed inline in the browser, i.e. as a Web page or as part of a Web page, or as an Attachment, that is downloaded and saved locally).

Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW


Content-Disposition: form-data; name="file"; filename="INV_20180119_110812.csv"


Below are the detail steps which explains in reading the API body parameters i.e. the key and value and sending the file name dynamically :

In the first graphical mapper(IDOC to XML) declare the Adapter Specific Message Attributes as an User-defined Functions for deriving the file name scheme as below and map to an field ‘fileName’.


public String getASMAFileName(String CREDAT, String CRETIM, Container container) throws StreamTransformationException{

String filename = "INV_" + CREDAT + "_" + CRETIM + ".csv";

return filename;

1st Mapper:

In the second graphical mapper(XML to CSV) declare the Adapter Specific Message Attributes as an User-defined Functions for setting the mime type, specifying csv header fields, creating attachment as csv form data, passing the ASMA filename from first graphical mapper and header fields as an Input arguments to the user defined function and map to an field ‘file’.

Below is the standard Java method.


public void setContentType(String[] SKUId, String[] EANNumber, String[] Warehouse, String[] Quantity, String[] UOM, String[] Cost, String[] Entity, String[] TransactionType, String[] filename, ResultList rs, Container container) throws StreamTransformationException {

AbstractTrace trace = container.getTrace();

// field Names from your first mapping structure

String header = "SKUId,EANNumber,Warehouse,Quantity,UOM,Cost,Entity,TransactionType";

String content = header + "\n";

String mimeType = "application/;charset=" + "\"" + "uft-8" + "\"";

String fName = filename[0];

for (int i = 0; i < SKUId.length; i++) {

// adjust the below line with your field names from first structure

content = content + SKUId[i] + "," + EANNumber[i] + "," + Warehouse[i] + "," + Quantity[i] + "," + UOM[i] + "," + Cost[i] + "," + Entity[i] + "," + TransactionType[i] + "\n";



//Create attachment with CSV data

try {

GlobalContainer globalContainer = container.getGlobalContainer();

OutputAttachments outputAttachments = globalContainer.getOutputAttachments();

Attachment attachments = outputAttachments.create(fName, mimeType, content.getBytes());


} catch (Exception e) {





2nd Mapper:

In the Integration Directory:

Coming to the Java HTTP_AAE Receiver communication channel, Under General tab the HTTP request details can be specified as multi-part form request and can be sent as an csv file attachment.

Tick ‘Set Form’ if the target server accepts a form-based submission. Enter the Main Payload Field Name to specify the name of the request parameter [here it is ‘file’ (name)] whose value contains the XI main payload.

Tick ‘Set Multipart’ if the HTTP request is a multipart request where one or more different sets of data form the HTTP body.

If you want the attachments in the request to be delivered to the target system, choose Keep Attachments.

Form-Based File Upload indicates that the HTTP POST request is form based and is multipart (RFC 1867). You use this scenario to select the XI message payload and XI main message attachments from a form-based file-upload.

Now Under Advanced tab, set the Additional Parameters as below it is used to submit the content type headers as ‘true' (Incoming HTTP request content type headers).

Under Module Configuration tab, define the ‘PayloadSwapBean’ module name
(localejbs/AF_Modules/PayloadSwapBean) and declare the ‘swap.keyName’ as ‘content-type’ and ‘swap.keyValue’ as application/;charset="uft-8".

PayloadSwapBean module will replace the application payload (Main Document) of the XI message that contains the business data with another payload that is appended to the XI message as an attachment. Note: Using PayloadSwapBean we cannot handle multiple attachments. This limits us to use when we are dealing with only one attachment.

swap.keyName is to enter a payload attribute such as payload-name or payload-description, or an attribute from the MIME header such as content-Disposition, content-description, and so on.

swap.keyValue is to enter the value that the attribute is to have. The MIME headers of the payloads are searched in order and the system takes the first payload that meets the criteria. This payload is swapped with the application payload.

TraceHTTP is to trace server-side HTTP communications and below are the following severity levels we can configure for parameter Trace HTTP:

Plain - The whole HTTP Request and response communication is traced(headers, body) in plain text.

Headers -Only HTTP headers are traced, both for the HTTP Request and response

Hex - A hex dump is traced  for the whole HTTP request and response communication in the hexadecimal format.

This will indeed dump the entire raw HTTP message(Both request and response) to the Logs in .../server#/j2ee/cluster/dispatcher/log/services/http directory.

Do note this feature is supported only PI 7.31 SP 14 and greater, PI 7.4, 7.5 SP 9 and greater.


Debug the HTTP traces in Nwa log Viewer application

Open NWA->Troubleshooting->Logs and Traces -> Log Viewer

Amazon S3 target server:

However, in this blog, I had solved this problem by manually creating Multipart request using JAVA Mapping since REST/SOAP Adapter is not having multipart form(request) options by default. In this way you can use plain HTTP_AAE adapter. Below is the URL to understand how a multipart request looks like. Please visit this URL:

This blog tries to explain how a multipart form data request looks like, how it can be easily generated from XI and provides java code to achieve this scenario using HTTP_AAE.
Labels in this area