on 11-23-2013 1:08 PM
Hi,
We have a requirement of extracting the File Name and File size of an attachment which is picked up by the Sender File Adapter.The Sender File is picked up as an attachment through the Sender File Adapter. I need the File name and File size of the attachment.These two details are to be sent to the Target System.
Kindly suggest the logic as to how to achieve the same in the mapping.Is this possible through a UDF in the mapping?
Thanks,
Soundarya
Hi Soundarya
This UDF code will give you the attachment name and the size
String attachmentID = null;
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
if(inputAttachments.areAttachmentsAvailable())
{
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
attachmentID = (String)arrayObj[0];
Attachment attachment = inputAttachments.getAttachment(attachmentID);
int attachmentsize = attachment.getContent().length;
return "Attachment Name : "+attachmentID +" Attachment Size : "+attachmentsize+" bytes";
}
else {
return "no attachment found";
}
Output:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With the help of a small UDF you can get the file name in the mapping.
However i dont see any getsize method for inputAttachments. May be you can get the size after attachment.getContent();
You can give a try n confirm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Soudarya,
Please go through the link http://scn.sap.com/message/13525886#13525886
This should help you retrieve the file name of the attached file. Similarly you can get the file size.
Hope it helps!
Ambrish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
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.