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
- 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
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
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
Test Result:
File name populated in header
Target file name generated
Well concieved and explained. Thanks for sharing!!!
Excellent Blog Indrajit. Thanks.
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.