on 01-02-2014 8:41 AM
Hi All,
I have a requirement to read the attachment file name in SAP PI using java udf and place it in dynamic configuration.
Scenario is Proxy==>PI==>SOAP , so i have to read the attachment file name which is comming from proxy and then send it to SOAP receiver in dynamic configuration.
Hi Pavan
Proxy uses SOAP to send message to XI, so you can check the Dynamic Configuration in XI runtime in Monitor(sxi_monitor) for details. Find out the parameter where the attachment name is stored and read that using java udf.
Thanks
Sasidhar Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
I am trying to read the attachment file names in mapping and tried the UDF posted by you. UDF returns runtime created attachment ID like below.
I also tried like , but could not retrieve file name and the result is still CID as below. I tried using Dynamic configuration with the same result.
Can someone help me on reading attachment filename from ABAP Proxy sender? Or is there a possibility mapping to read PI SOAP BODY manifest that has file name in **<SAP:Name>FileName.PNG</SAP:Name>**?
Please let me know..
Thanks,
Kavitha
Thanks Azhar, I used attachments.getContentType(); and retrieved only document type. It does not have information on FileName. Attached the snapshot below that was returned.
In my case, sender is ABAP proxy, and i have to read the file name and encode the content and send to target system. I can encode file content but have problem retrieving with file name. Does Attachment interface have a method getName() or so to return file name?
Thanks,
Kavitha
Here is my code i'm using to read attachment file name:
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
AbstractTrace trace = container.getTrace();
try
{
//check the availability of attachments in input message
if(inputAttachments.areAttachmentsAvailable())
{
trace.addInfo("Input attachment available");
//get attachmentIds and store it in an Object array
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
int attachmentCount = arrayObj.length;
String[] Content = new String[attachmentCount];
String[] AttachmentID = new String[attachmentCount];
String[] AttachmentName = new String[attachmentCount];
//Loops input attachments to get content of the attachment
for(int i =0;i<attachmentCount;i++)
{
AttachmentID[i] =(String) arrayObj[i];
Attachment attachments =inputAttachments.getAttachment(AttachmentID[i]);
Content[i] = attachments.getBase64EncodedContent();
//AttachmentName[i] = attachments.getContentType();
AttachmentName[i] = attachments.getName();
AttData.addValue(Content[i]);
AttName.addValue(AttachmentName[i]);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
and it compiles with below error after adding attachment.getname() method.
cannot find symbol |
I searched on this error but couldn't get through.Can you help proceed further with the error and with reading file name?
Help on this much appreciated!!
Kavitha.
Hi Kavitha,
There is no method as getName for Attachment.
I suggest you to first check in pimon, if you are getting the File name in Content-Type (refer the screenshot I attached abv).
If yes, then you need to perform substring operations on Content-Type value that you get inorder to pick the File name from the content-type string.
The screenshot you added is not very clear. Can you also try to add trace in your mapping to check the value returned in content-type:
trace.addInfo("contentType is:"+AttachmentName[i]);
Hope it helps.
Regards,
Azhar
Hi Azhar,
I am using Proxy to Mail scenario and need to retrieve attachment names so that I can pass on to mail. I see that all attachments are converting into "untitled.txt" and hence trying to set the file name in UDF. But I need to retrieve exact source attachment name send through proxy.
I need to retrieve attachment file name "Attach1.txt" in UDF which was attached using ABAP Proxy.
I could get the "contentID" value as "cid:payload-552538D9131F36A2E10000000A284B3F@sap.com" using mentioned code but my requirement is to get the "Attach1.txt" value mentioned in <SAP:Name> tag.
In our case, we see attachment name starting with "payload-" where as I see in other blogs that we can see actual attachment name instead of SAP generated name.
I see attachment name in <SAP:Payload> tag like <SAP:Payload xlink:href="cid:Attach1.txt"> whereas in our case we see as <SAP:Payload xlink:href="cid:payload-.......>
Please advise.
Regards
Srini
Hi Azhar,
Since sender is ABAP proxy, i cannot check the message in communication channel monitoring for attachment file name.
Moreover, Attachment.getContentType() could only me document type. Here is the traceinfo for same, that returned image/png as ContentType and does not contain file name in it.
Please suggest if there is a way to read the attachment name sent in ABAP proxy message.
Thanks for your help,
Kavitha
Hi Kavitha,
For Proxy scenario I am not very sure on process to read Attachment name. Hope someone in forum might provide inputs on this.
As an alternative solution, since you are having Proxy at Sender side, can you request the Sender to send File name in one of the XML Field, so that you can map it directly. I believe the ABAPer can pass the filename value in the payload.
Regards,
Azhar
Hi Pavan,
Do you check this blog ?
Also:
Kind regards,
BR.
Viana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pavan,
Sorry for that.
Java UDF code :
http://scn.sap.com/thread/1341089
Configuration at Directory:
https://scn.sap.com/thread/3154499
Regards,
Hello,
Check this code:
Below code will read the attachment file name
GlobalContainer gc = container.getGlobalContainer();
InputAttachments ia = gc.getInputAttachments();
String ContentID = new String();
AbstractTrace trace = container.getTrace();
try
{
if(ia.areAttachmentsAvailable())
{
trace.addInfo("Input attachment available");
Collection<String> collectionIDs = ia.getAllContentIds(true);
for (Iterator<String> it = collectionIDs.iterator(); it.hasNext();)
{
ContentID = it.next();
trace.addInfo("ContentID :" + ContentID);
result.addValue(ContentID) ;
}
}
}
catch(Exception e)
{
}
Thanks
Amit Srivastava
Hi Amit, Thanks for the code, this is helpfull for me. I need some more help on this,
by using the above code i am able to get "payload-DB16DE56787A6555E10000003547E459@sap.com" in the feild.
Requirement: is it possible to provide the same along with "cid" and can we create link on this(on click of this) the payload or content id specific to this has to be opened.
please let me know if i have to provide any further information.
Regards,
Swapna.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.