cancel
Showing results for 
Search instead for 
Did you mean: 

Get attachment name in the target structure field

Former Member
0 Kudos

Dear SCN

I am getting an attachment in PI through ABAP proxy. I need to pass the name of the attachment also in the following format in target structure like this. What is best way to do this? Do we need to write a code for ASMA? If yes, can anybody share the code.

<cor:fileUploadMTOMAttachments>cid:MIS-ERROR-REPORT.txt</cor:fileUploadMTOMAttachments>

Regards

Monika



Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear SCN

I am using the following udf. However i am unable to get the attachment name.

GlobalContainer globalContainer = container.getGlobalContainer();

InputAttachments IA = globalContainer.getInputAttachments();

OutputAttachments OA = globalContainer.getOutputAttachments();

AbstractTrace trace = container.getTrace();

String base64="";

if(IA.areAttachmentsAvailable()) {

Collection<String> CollectionIDs = IA.getAllContentIds(true);

Object[] arrayObj = CollectionIDs.toArray();

if(arrayObj.length > 0){

    String attachmentID =(String) arrayObj[0];

    Attachment attachment =IA.getAttachment(attachmentID);

    base64 =  attachment.getBase64EncodedContent();

          trace.addInfo("getBase64EncodedContent: \n" + base64);

          trace.addInfo("attachmentID: \n" + attachmentID);

    //String contentType = attachment.getContentType();

    // OA.create(attachmentID, base64.getBytes() , contentType);

}

}

return base64;

gagandeep_batra
Active Contributor
0 Kudos

Hi Monika,

What error you are getting;for that: & on which verison you are

did you check following blog also:

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/07/01/retaining-soap-adapter-attachment...

Regads

gAgan