Skip to Content
Author's profile photo Former Member

How to generate target file name based on the input attachment file name

Recently we have developed a HTTP to File scenario in PI. There was a requirement that the target file name will be same as the attachment file name. SAP has provided a java method to read the attachment data and content type, content ID, but there is no standard function to read the attachment file name.

We have referred the following blog to create the HTTP test client for our interface.

http://scn.sap.com/community/pi-and-soa-middleware/blog/2012/08/12/http-test-tool-for-sap-pi-73

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

So to read the attachment file name, we have passed the attachment file name in the URL and then read the same from dynamic header. Below are the detail steps

  1. Find the input parameter for attachment , inside the HTML form

<td width=”30%”><input type=”file” name=”Attachment1″ size=”40″ /></td>

Attachment1 is the parameter.

2. Modify the java script to include the attachment file name in the URL

/wp-content/uploads/2013/02/imag1_186525.jpg

So in the URL file name parameter will carry the actual attachment file name.

3.Make the change in the communication channel so that the file name will be populated in the dynamic header

/wp-content/uploads/2013/02/imag2_186526.jpg

4.Write the following line of java code to read that value from header and then set the same for file adapter so that the target file will be generated with that name

/wp-content/uploads/2013/02/imag3_186527.jpg

Test Result:

/wp-content/uploads/2013/02/imag4_186528.jpg

File name populated in header

/wp-content/uploads/2013/02/imag5_186529.jpg

Target file name generated

/wp-content/uploads/2013/02/imag6_186536.jpg

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Well concieved and explained. Thanks for sharing!!!

      Author's profile photo vishal javalkar
      vishal javalkar

      Excellent Blog Indrajit. Thanks.

      Author's profile photo Former Member
      Former Member

      Hi, Indrajit.

      I was actually looking for a blog you wrote last year "Step By Step Guide for Merging two different interfaces in SAP NetWeaver BPM". I think the link used to be:

      http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/09/10/step-by-step-guide-for-merging-two-different-interfaces-in-netweaver-bpm

      But now it is gone. Would you mind to email me the blog? My email is jonathan.ma@rcmp-grc.gc.ca.

      Thanks,

      Jonathan.