on 05-14-2009 8:48 AM
Hi,
In PI 7.1 there is one option to read attachment content inside mapping using the api: "com.sap.aii.mapping.api".
To do that in operation mapping we have to check the option "ReadAttachments", to get the attachments in addition to the payload. If I check the Readattachments check box, message goes into the queue and the queue status is running.
Please help me to read the attachment content in mapping.
Thanks & Regards,
Yuga
Problem Solved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
That issue has been solved,the problem is with the syntax.
Now I was able to get the attachment details,but i was not able to read the content of the attachment.
Here is my code:
String Content = "";
String AttachmentID ="";
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
if(inputAttachments.areAttachmentsAvailable())
{
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
int attachmentCount = arrayObj.length;
for(int i =0;i<attachmentCount;i++)
{
AttachmentID =(String) arrayObj<i>;
Attachment attachments =inputAttachments.getAttachment(AttachmentID);
Content = Content + attachments.getContent().toString();
}
}
return Content;
My requirement is to read all the attachment's.Attachment has XML content, so after reading I need to parse the xml content inside graphical mapping itself is there is any option to do like this.
Thanks & Regards,
Yuga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check this link:
https://www.mkyong.com/java/how-do-convert-byte-array-to-string-in-java/
Since attachments.getContent() only return byte[]. The code should be modified like following to restore the data back into string form (if data is plain string)
String Content = "";
String AttachmentID ="";
InputAttachments inputAttachments = container.getGlobalContainer().getInputAttachments();
if(inputAttachments.areAttachmentsAvailable())
{
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
int attachmentCount = arrayObj.length;
for(int i =0;i<attachmentCount;i++)
{
AttachmentID =(String) arrayObj[i];
Attachment attachments =inputAttachments.getAttachment(AttachmentID);
String s = new String(attachments.getContent());
Content = Content + s;
}
}
return Content;
see [http://help.sap.com/javadocs/pi/SP3/xpi/index.html?com/sap/aii/mappingtool/tf7/rt/package]
for Interface InputAttachments
see [http://help.sap.com/javadocs/pi/SP3/xpi/index.html?com/sap/aii/mappingtool/tf7/rt/package]
for Interface OutputAttachments
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To begin, you must use InputAttachments class to read the attachment from source message and OutputAttachments class to write the attchments to target message.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.