cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch Content-Transfer-Encoding of SAP Attachment

Former Member
0 Kudos

Dear All,

I have a requirement where I am sending xml payload and multiple attachments from SAP to 3rd Party system.

For each attachment , I have to fetch Content-Transfer-Encoding  and pass this in a field in receiver side.

Anyone please give me an idea how to do this requirement ???

Any UDF or java could would be a great

Thanks

Sandeep

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190293
Active Contributor
0 Kudos

Hi S. Sharma!

I've never tried it myself but within adapter module you can try to get attachment as Payload and use its method getAttribute().

Payload

Regards, Evgeniy.

Former Member
0 Kudos

Hi

I am using this UDF to fetch other attributes of  attachment  but I dont know whats the method to fetch content transfer encoding..   Please suggest.

String attachmentID = null; 

java.util.Map map; 

AbstractTrace trace; 

//gets the input attachment from the source message 

GlobalContainer globalContainer = container.getGlobalContainer(); 

InputAttachments inputAttachments = globalContainer.getInputAttachments(); 

OutputAttachments outputAttachments = globalContainer.getOutputAttachments(); 

trace = container.getTrace(); 

//map = globalContainer.getParameters();  

try 

          //checks for the availability of attachments in the input message 

          if(inputAttachments.areAttachmentsAvailable()) 

          { 

                    trace.addInfo("Attachments Available"); 

                    //gets the attachmentIds and store it in an Object array 

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

                    Object[] arrayObj = CollectionIDs.toArray();  

                    //Loops at the input attachments to get the content of the attachment 

                    for(int i =0;i<arrayObj.length;i++) 

                    { 

                              attachmentID =(String)arrayObj[i]; 

                              trace.addInfo((i+1) + ") Attachment Name: " + attachmentID); 

                              Attachment attachment = inputAttachments.getAttachment(attachmentID); 

                              String contentType = attachment.getContentType(); 

                              contentType = contentType + ";multipart/form-data;boundary=b2Lh0weilHCR3Aw6z30XSc-HGGYpw-LcKSA;"+ "name=\"" + attachmentID + "\"";

                              byte[] attachmentBytes = attachment.getContent(); 

                              Attachment renameAttachment = outputAttachments.create(attachmentID, contentType, attachmentBytes);  

                              outputAttachments.setAttachment(renameAttachment); 

                              

                    } 

return var1;

          }  

catch (Exception e) 

          e.printStackTrace(); 

return           var1; 

          }  

catch (Exception e) 

          e.printStackTrace(); 

return           var1; 

Thanks

Sandeep

former_member190293
Active Contributor
0 Kudos

I'm afraid that Attachment interface which is used in mapping API gives no possibility to get access to "Content-Transfer-Encoding" attribute of attachment.

Regards, Evgeniy.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

There is no way to retrieve ASMA when you are using XI adapter. However, if you are using SOAP over XI protocol, there is a way.

Retrieve the value using dynamic configuration (XHeaderName1). This is assuming that Content-Transfer-Encoding is really existing in the http header.

Regards,

Mark

former_member190293
Active Contributor
0 Kudos

Hi Mark!

I'm not sure which of the existing headers will be taken .

Regards, Evgeniy.