cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of additional attachment in Java Mapping

Former Member
0 Kudos

Hello all,

I want to use a Java Mapping with the functionality to create a second /attachment which I can send over email out?

I don’t want to pick this file somewhere from the server, instead I want to fill the content of the additional attachment directly in the java mapping.

I hope somebody knows the answer of my question.

If its possible is there any kind of example??

Many thanks for your help

ilka

Accepted Solutions (0)

Answers (2)

Answers (2)

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Like pointed out either use adapter modules or, use mail API's inside the Java Mapping to send the mail.

One more option (though am not sure if it makes sense) , is to trigger XI alerts from your Java Mapping and then pass the the alert content to the Mail.

Something of this sort, I have explored in my blog,

/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function

Regards,

Bhavesh

Former Member
0 Kudos

Hi Ilka,

Unfortunately, XI mapping programs (Message, XSLT, or java) do not have access to the attachment(s).

The only way that I know to accomplish this is by using an adapter user-module, which does have access to attachment contents and able to create/change attachment(s).

Regards,

Bill

Former Member
0 Kudos

hi William,

With respect to the above mail, is this still the case in PI 7.31? Can we not create an attachment using udfs or probably a Java mapping?

REgards,

ninu

stefan_grube
Active Contributor
0 Kudos

The original statement is 6 years old!

Meanwhile you can create attachments starting with PI 7.1.

Check online help for further details.

Former Member
0 Kudos

hi Stefan,

http://scn.sap.com/thread/1874962

Regarding the comment in this thread, can you please tell me if you have faced any issue with creating output attachments. Right now, i have a message mapping in which i have written a udf to create attachments

this message mapping is a multi mapping and the source is 0-unb. I have used a return as xml on the root message and pointed it to the udf after split by value.

There are three root nodes in one of my cases, and when this goes through this mapping, there is 1 attachemnt each created with three main documents and submain documents. However, all the attachments contain details of the first root node itself where in actually it should be each main and submain document having a different attachment. Please find my udf below. Please let me know if you think it is wrong somewhere.

udf :-

GlobalContainer globalContainer = container.getGlobalContainer();
       
OutputAttachments outputAttachments = globalContainer.getOutputAttachments() ;

int flag =0;
AbstractTrace trace = container.getTrace();
String attachmentName = "";

//for(int i=0;i<var1.length;i++){

try
{
var1=var1.replaceAll("><",">\n<");
attachmentName = "attachment"+cnt;
Attachment newopAttachment = outputAttachments.create((attachmentName), var1.getBytes("UTF-8"));
outputAttachments.setAttachment(newopAttachment);
trace.addInfo("newopAttachment"+newopAttachment);
cnt=cnt+1;
attachmentName ="";
newopAttachment = null;
var1="";
}
catch (Exception e)
{  
trace.addInfo("ever reaching trace");
      e.printStackTrace(); 
}
//result.addValue("1");  
//}
//result.addValue("1");  

return "1";

----

Input :-

Messages

Message1

SBDH

SBDH

SBDH

Each of the above SBDH, i have returned as xml and pointed to the udf after split by value

Your help is highly appreciated.

Regards,

Ninu