Create a PDF as attachment in custom module in mail receiver adapter
I'm trying to create a PDF attachment to an email using a custom module with the following codes. The attachment was created and sent, but when I tried to open it, I got the following error message: the file cannot be read either because a invalid encoding or the file is damaged.
Anybody knew if I did anything wrong in the way I'm opening and creating the PDF attachment below?
// add a new pdf attachment to the message
FileInputStream fi = new FileInputStream("c:/ftmailxi.pdf");
byte[] attachmentContent = new byte[fi.available()];
Payload attachmentPDF = msg.createPayload();
attachmentPDF.setName("ftmailxi.pdf");
attachmentPDF.setContentType("application/pdf");
attachmentPDF.setContent(attachmentContent);
//adding our this pdf as an attachment
msg.addAttachment(attachmentPDF);
//provide the XI message for returning
inputModuleData.setPrincipalData(msg);
This will surly help u
/people/sravya.talanki2/blog/2006/11/28/e-mail-xml-messages-in-pdf-format-from-sap-xi
Check this out
Mail with attachment.
Regards,
Prateek
Similar Messages
-
How to attach Excel file in Mail Receiver Adapter?
Hello Experts,
In R/3 coding I have Internal Table data available for which i have to generate an Alert mail with Excel file attachment.
This is the scenario of Proxy sender to Mail Receiver. but I don't know how to convert the Internal Table data into Alert mail excel File attachment.
Please suggest me.
Regards,
JageshHi Santhosh,
Thanks for your suggestion.
But without using XSLT mapping also, I have generated the Excel File attachment.
Throgh R/3 coding I am passing following.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-FROM = From Mail Address.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-TO = TO Mail Address.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-SUBJECT = 'Test Alert mail'.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-DATE = SY-DATUM.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT_TYPE = 'text/plain;name="CSV_data.csv"'.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT = 'Testing1,Testing2,Testing3'.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT_DISPOSITION = 'attachment'.
And in the Mail Receiver Adapter i have configured as following.
Use Mail package and Keep Attachment both options are selectd.
So I am getting the data in different columns in the excel file But How to set the Next ROW in Excel file?
I thnk i am missing something in CONTENT value.
Regards
Jagesh -
Mail receiver adapter: attachment adds 3 empy lines
Hi,
i use the mail receiver adapter with "mail package" for setting dynamic attachment names.
The attachment always gets 3 "cr/lf" lines at the end? Why and how can i stop that?
System: xi3.0sp15build0
Message was edited by:
Bernhard Josef NeuhauserHI,
Please read above link for PayloadSwapBean.
You use the PayloadSwapBean module to replace the application payload of the XI message that contains the business data with another payload that is appended to the XI message as an attachment
Also see the links below.. how to use PayloadSwapBean.
HOW - PayloadSwapBean - adding attachments to the message? :-)
Mailadapter, receive mails from mailserver: attachment?
Work with attachments
Sender Mail Adapter - html body mail
Multi Attachments with ZIP or Mail Adapter (Outbound)
Regards
Chilla.. -
Mail Receiver Adapter Attachment Content Encoding
Hello to all,
we use a mail receiver adapter to sent XI messages as email. Everything works fine but the content encoding of the attachment is set to UTF-8. I need ISO-8859-1 instead of UTF-8. How could I achieve this ?
Thanks ChristianHello Stefan,
we've tried this too (content type to: text/plain;charset="ISO-8859-1"), but it didn't work.
This is our output structure
<?xml version="1.0" encoding="ISO-8859-1"?><ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30"><Subject>Daten von 01.07.2008 12:20</Subject><From>mail(at)dummy.de</From><To>max.muster(at)web.de</To><Content_Type>multipart/mixed; boundary="--AaZz"</Content_Type><Content>----AaZz
Content-Type: text/html; charset=ISO-8859-1
Content-Disposition: inline
Mit freundlichen Grüßen
----AaZz
Content-Type: text/plain; charset=ISO-8859-1; name=Daten 01.07.2008 1220.txt
Content-Disposition: attachment; filename=Daten 01.07.2008 1220.txt
"N";2000000003;"1234123412341234";1234500009;000000000000;01;"L";"OKDAU";1;"Prof. Dr.";"Max";"Mustermann";"";"Musterstraße";"";000000;"PLZ45";"Musterhausen";"";19990101;"max.mustermann(at)muster.com";"";"";"";"";"1";"Titel";"Vorname";"Name";"20000101";"";"0";"Max Mustermann";"L";"BLZ";"100000001";"Musterbank";00;;01;000000;;;00;1;0;0;1;0;"ForumNr";1;1;0;1;0;1;0;0;20080620;0;;0;20080620;0;20080620;0002;STANDARD
"N";2000000004;"5678567856785678";1234567009;000000000000;01;"L";"OKDAU";1;"Prof. Dr.";"Stefan";"Maier";"";"Teststraße";"";000000;"PLZ65";"Testhausen";"";19991201;"stefan.maier(at)test.de";"";"";"";"";"1";"Titel";"Vorname";"Name";"20001201";"";"0";"Stefan Maier";"L";"BLZ";"100000001";"Testbank";00;;01;000000;;;00;1;0;0;1;0;"ForumENr";1;1;0;1;0;1;0;0;20080620;0;;0;20080620;0;20080620;0002;STANDARD</Content></ns:Mail>
But the attachment is UTF-8
Thanks for your help.
Christian -
What will be input for custom module developed for JDBC adapter
Hi,
I have a scenario SQLDB -> Xi -> R3 .
Here I have added a custom module before callsapadapter module.
As I know the sequence of module calling will be as follows :
1. Standard jdbc adapter
2. custom module
3. callsapadapter
Standard jdbc adapter has a select query . After that what will be the input format for my custom module .Will it be the xml structure of my source Data type or will it be a resultset or will it be a inputstream(stream of xml fomat????).
And then in which format i need to generate the output format for CallSapAdapter.
RegardsHello Moni,
SAP has a wonderful feature in ABAP. There are some Runtime Errors that you can <i>catch</i>. This is somewhat similar to the Exception Handling procedure in Java / C++. So here's how you go about it....
Sometimes there might some calculations that we do, multiplication , for example, where the result of the arithmetic operation is known only at run-time. And the recepient for this result may not always be of the right type to take the result. Consider the following code:
parameters a type i obligatory.
data : b type i,
c type i.
b = 99999999.
** Assume that the user has entered 99999999 for the value of the parameter a.
c = a * b. " 99999999 * 99999999 "
write c.
This program will certainly give a short dump saying that there was an arithmetic overflow. But we can actually avoid this Shor Dump and handle the situation quite elegantly. consider the following.
parameters a type i obligatory.
data : b type i,
c type i.
b = 99999999.
CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 1.
** Assume that the user has entered 99999999 for the value of the parameter a.
c = a * b. " 99999999 * 99999999 "
ENDCATCH.
if sy-subrc ne 0.
write: 'There was an arithmetic overflow in the calculation.'
else.
write c.
endif.
This way you can actually avoid the short dump and make the system set a value for sy-subrc. Based on the avlue of the sy-subrc, you can go ahead with further processing / error-handling, as the case may be.
Here, ARITHMETIC_EXCEPTIONS is called an <i>exception group</i>. For more information on what other run-time errors can be <i>caught</i>, and What the various exception groups contain, please refer to the online documentation for the CATCH statement.
Regards,
Anand Mandalika. -
Attachment in Mail Receiver Adapter
Hi,
I wrote a Adapter Module to create attachment in Receiver Mail Adapter. I create a PDF document using the IText API and create the attachment using this one. But it not work properly and the attachment is not send with the e-mail. My code is:
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
throws ModuleException{
try{
Document doc = new Document(PageSize.A4);
ByteArrayOutputStream out = new ByteArrayOutputStream();
PdfWriter.getInstance(doc,out);
doc.open();
PdfPTable table = new PdfPTable(3);
PdfPCell cell;
cell = new PdfPCell(new Paragraph("Rank"));
cell.setBackgroundColor(new Color(34, 90, 141));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Name"));
cell.setBackgroundColor(new Color(34, 90, 141));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Points"));
cell.setBackgroundColor(new Color(34, 90, 141));
table.addCell(cell);
//add the data rows.
int flag = 0;
Color bg;
for (int i = 0; i <= 10; i++){
//alternate colors
if (flag == 0){
flag = 1;
bg = new Color(204, 204, 255);
} else {
flag = 0;
bg = new Color(255, 255, 255);
cell = new PdfPCell(new Paragraph("1"));
cell.setBackgroundColor(bg);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Prakash Singh: " + i));
cell.setBackgroundColor(bg);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("" + (50000 - i * 10) + ""));
cell.setBackgroundColor(bg);
table.addCell(cell);
doc.add(table);
doc.close();
Message msg = (Message)inputModuleData.getPrincipalData();
AuditMessageKey amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,"CreateAttachment: Module Called");
Payload attachment = msg.createPayload();
attachment.setName("Order");
attachment.setContentType("Plain/Text");
attachment.setContent(out.toByteArray());
msg.addAttachment(attachment);
inputModuleData.setPrincipalData(msg);
}catch (Exception ex){
ModuleException me = new ModuleException(ex);
throw me;
return inputModuleData;
somebody has some ideia.
thanks.Hi,
I checked the "Keep Attachments" in the Communication Channel and the file was sent, but the extension of attachment is .bin. How I do to change the extension file name in attachment to .pdf? And how I do to keep the content in body of the mail when the keep attachments is checked?
thanks. -
Send XML File as attachement in Mail Receiver adapter
Hi all,
i have the following scenario. i would like to read an XML file from the file system and send this file as an attachement of a mail to a mail receiver specified in this file.
i would like to fill the payload of the mail with some information from the xml file and in addition i would like to send the complete xml file as an mail attachement.
can anybody tell me, how the mail receiver adater needs to be specified ?
best regards,
martinHey,
you can go for dynamic configuration of mail adapter.
In this you need to import a mail structure.
mail details such as to, from, subject and content of the mail are a part of the structure.
In your ID check the Use Mail package and also keep attachments.
Now you can give your details in mapping itself.
whatever you want to map in the content of the mail, map it in the content field.
also your file will behave as an attachment.
refer to this blog.
this is the mail structure. Import it as extenal definitions.
<?xml version="1.0" encoding="utf-8" ?>
<!--
SAP takes no position regarding the validity or scope of any intellectual property or
other rights that might be claimed to pertain to the implementation or use of the
technology described in this document or the extent to which any license under such
rights might or might not be available; neither does it represent that it has made any
effort to identify any such rights.
Copyright © SAP 2003-2004. All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative
works that comment on or otherwise explain it or assist in its implementation may be
prepared, copied, published and distributed, in whole or in part, without restriction of
any kind, provided that the above copyright notice and this paragraph are included on all
such copies and derivative works. However, this document itself does not be modified in
any way, such as by removing the copyright notice or references to SAP.
This document and the information contained herein is provided on an u201CAS ISu201D
basis and SAP DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-->
<xs:schema targetNamespace="http://sap.com/xi/XI/Mail/30"
xmlns:xi="http://sap.com/xi/XI/Mail/30"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--
Mail
-->
<xs:element name="Mail">
<xs:annotation>
<xs:documentation>Mail package for XI - Mail Adapter</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Subject" type="xs:string" minOccurs="0"/>
<xs:element name="From" type="xs:string" minOccurs="0"/>
<xs:element name="To" type="xs:string" minOccurs="0"/>
<xs:element name="Reply_To" type="xs:string" minOccurs="0"/>
<xs:element name="Content_Type" type="xs:string" minOccurs="0"/>
<xs:element name="Date" type="xs:dateTime" minOccurs="0"/>
<xs:element name="Message_ID" type="xs:string" minOccurs="0"/>
<xs:element name="X_Mailer" type="xs:string" minOccurs="0"/>
<xs:element name="Content" minOccurs="0">
<xs:annotation>
<xs:documentation>any type</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="encoding" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="MailReceipt">
<xs:annotation>
<xs:documentation>Mail Receipt for XI - Mail Adaper</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Server" type="xs:string"/>
<xs:element name="Format" type="xs:string"/>
<xs:element name="UseMailPackage" type="xs:boolean"/>
<xs:element name="Encoding" type="xs:string"/>
<xs:element name="Subject" type="xs:string" minOccurs="0"/>
<xs:element name="From" type="xs:dateTime" minOccurs="0"/>
<xs:element name="To" type="xs:string" minOccurs="0"/>
<xs:element name="Date" type="xs:dateTime" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
regards,
milan -
Mail Receiver Adapter - Flat File as Attachment
Hello,
I would like to send a flat file as attachment using an E-Mail receiver communication channel.
The flatfile is picked up beforehand using a file sender channel, so there is only routing necessary in PI.
Is it possible to send the flatfile as attachment by checking the option "XIPAYLOAD" or would this result in an error?
The scenario is quite simple and I am looking for the fastest and easiest way to implement it.
Thank you very much.Hey
You can follow as given in the below blog
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken]
Thanks
Aamir -
Mail receiver adapter: change filename of attachment to number in payload.
Dear experts,
I want to send out Purchase Orders from XI to a email address. The XI message containing the Purchase Order is sent as an attachment to a email to the supplier. However, the filename of the attachment needs to unique. Preferably the PO number which is in the file content.
Can anybody help me out with how to accomplish this?
My current settings are:
Transport protocol: SMTP
Message Protocol: XIPAYLOAD
Not using mail package
Keeping attachments.
Using: MessageTransformBean
Transform.ContentDisposition --> attachment;filename="testing.xml"
Please tell me how to dynamically change the "testing.xml" part!
Thanks in advance,
*will reward points if helpfulThanks Prateek!
This is what I was looking for.
Can you please do me one more favour?
How to include this code in the module? I have been looking on help.sap.com but only found to be able to do this in PCK. Is this correct?
How can I use the code?
Thanks in advance. -
Hi All,
In the scenario Webservice to RFC synchronous, I need to use custom module in the RFC adapter to create a attachment in the response message
Whether I need to use the custom module before the RFC standard module or after the standard module.?
Also If I select "Keep Attachments" in the sender soap adapter, can we monitor this in XI ..?
Regards
PrakashHi
Before the default module .
chk this also
Custom Module
rgds
Arun -
Hi ,
How to create attachments in XI using custom module.can anyone suggest on this?
Thanks
DineshHi Stefan,
Thanks for your quick response..
This is the first time am handling Webservice scenario..
Actually I spend some time for research activities on how to implement this scenario..
And we will talk with our client about what you have posted...
But I have heard SOAP sender and receiver adapters can support attachments..
My concern here is
1. Without custom module can we create an attachment? If so send us the links.
2. In most of the links I have found that attachments are created for Mail receiver adapter..Can I use the same logic to create attachment for SOAP receiver adapter?
3. I have heard using ABAP mapping or Java proxy we can create attachments. Can I use that attachmnent to send it to webservice
4. Can I use Java mapping to create SOAP attachments?
5. Finally which is the better solution to create an attachment..a)ABAP mapping b)Custom module c)Java proxy d)Java mapping
Please advice on this as I am new to this concept...
Thanks
Dinesh -
Creating a PDF contract for a website
I am trying to figure out how to create a PDF and attach it to my website. I need to make a contract that is easy for my customer's to find and print of from the web so I do not have to mail it to them. I need to use a PDF so they can not change anything in the contract before printing. Thank you and if you have any advice how to attach it to this website also would really help. I can not figure out a place to make it easily acceptable.
Thanks
Peter
[ links removed by forum host - promotion is not permitted on this forum ]After you create your file (you can apply security restrictions that prevent changing the file and only allow printing it), you just place the PDF in one of the public folders of your website and then link to it, just like any other file... The user will be able to download it directly, or open it in their browser.
-
Require PDF File attachment in Mail
Hi Experts,
I am doing the Proxy-XI-Mail scenario. I am sending the Mail related data like Content, Content_Type from R/3 to XI and configured the Mail receiver adapter.
R/3 coding:-
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT_TYPE = 'application/pdf;name="filename.pdf"'
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT = G_CONTENT
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-FROM = From_Mail.
G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-TO = To_Mail.
and then calling the client proxy
ID Mail Receiver configu:-
Selected Use Mail Package option
Content encoding base64
Keep attachment option is also selected.
I am geeting the Filename.pdf in mail as attachment.
Problem is:- I am not able to open the attached PDF File and error is:- 'Adobe Reader could not open filename,pdf because it is either not a supported file type ot because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded'
I think some conversions may be required to convert the XML Payload data into PDF file format for the Mail receiver adapter.
Please suggest
Thanks & Regards
JageshHi Jagesh,
The content type of the Pdf has to be identified, in order to conver the pdf successfully, You need to perform the conversion usign the PayloadSwapBean the Module tab. You use this when you want to receive attachment using Mail adapter. You need to configure few steps in Module Configuration
There you need to mention your MIME header paramenters Content-Type, Content-Description.
How this can be configured and how process with PayloadSwapBean check the below link
http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
Module Processor
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/5af7c0c994e24fb0d0088443513de2/content.htm
Regading MessageTransformBean, Migrating Dispatcher Classes
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm
Regards,
Prasanna -
Using reports to "just" create a pdf file
Hi All,
I'm using oracle aplication server 10g.
I have a situation where i must send several emails into my clients. I want to use the reports server to create several pdf files attached into a "pretty" mail message.
In the end the user will get a full report in a "pretty" html message with several pdf files.
I have already done a very flexibal pl/sql procedure that can send emails into any mail server and using any amount of attach files.
I have already done the reports and i can call them find from the find from oracle forms creating a pdf file.
My problem is that i can't stop the oracle from calling the browser and showing the report on the user screen. I simple want to generate the reports... create a html email message attach the reports (pdf) and send them into the user
Using the build in email support in oracle reports is out of the question because it's a bit limited.
Any help would be great.Hi,
Thanks a lot for your reply.
But i do not want to use reports to send the email, i just want him to generate a pdf file and NOT OPENING the pdf file on the user browser, having that i will use my own pl/sql procedure to send the email with the pdf file attached.
I need this because because reports is a bit limit in the email respect, and with a build in email procedure i can do a lot more things (mail queues, elaborate messages, mail store etc)
PS: i'm using the rp2rro.rp2rro_run_product package to run the reports
Miguel Angelo
Message was edited by:
[email protected] -
How to manipulate records inside customized modules and reflect to the seeded modules
If we are going to add custom modules inside Oracle EBS that link to Receivables, how do we create/update/delete records inside those custom modules and make them reflect inside Receivables? Are we going to use also the Interface tables and standard APIs? Can anyone help me on this matter or point me to some reading materials. Actually, I already started reading Oracle Applications Developer's Guide which gave great knowledge on how to start this task.
Thanks in advance.Jon632 wrote:
If we are going to add custom modules inside Oracle EBS that link to Receivables, how do we create/update/delete records inside those custom modules and make them reflect inside Receivables? Are we going to use also the Interface tables and standard APIs? Can anyone help me on this matter or point me to some reading materials. Actually, I already started reading Oracle Applications Developer's Guide which gave great knowledge on how to start this task.
Thanks in advance.
You can use interface table, or APIs or both.
All APIs are documented in eTRM website -- http://etrm.oracle.com
Oracle Receivables: Receipts API Overview, Setup, Sample Scripts and Troubleshooting (Doc ID 1361075.1)
Oracle Receivables Invoice API: Setup and Sample Scripts (Doc ID 1242202.1)
Oracle Receivables: Receipts API Known Issues and Patches (Doc ID 1362066.1)
Oracle Receivables Credit Memo API: Setup and Sample Scripts (Doc ID 1272600.1)
Oracle Receivables Invoice API: Known Issues and Patches (Doc ID 1306471.1)
Oracle Receivables: Transactions API Overview (Doc ID 1240573.1)
Oracle Receivables Credit Memo API: Known Issues and Patches (Doc ID 1316475.1)
Oracle Receivables Adjustments API: Overview, Sample Scripts, Known Issues (Doc ID 808758.1)
Oracle Receivables Deposits API: Sample Scripts, Known Issues/Patches (Doc ID 266964.1)
How to Register a Receivables Application Programming Interface (API) as a Concurrent Request (Doc ID 785369.1)
Thanks,
Hussein
Maybe you are looking for
-
Not had any other probs with it - have the 2 laptops, 2 ipods and 1 ipad registered and was told that was ok as 5 was maximum however one of the laptops has now been gotten rid of but I don't know how to check what is and isn't authorised for use.. M
-
Help Please! Macbook will not boot after MacOffice install
I've never used a mac before until now. I've a 2.2ghz, 2gb ram macbook(late '07, it has an *hitachi HD* which I've had for less than a week and was running fine until I installed mac office 2004 student edition. During the installation process i was
-
Another Blank Page in Fixed Layout Epub
Having trouble with a blank page in this epub (link to epub file on acrobat.com). I've read a couple of threads, and have exported the indd as an indb and reopened (trying to mitigate the possibility of the file being corrupt). I had to fix a date in
-
How to create Entity objects using xml as a datasource
Hi All, How to create EO(ADF Business components) using XML as a datasource instead of database tables..Pls do reply..Its an urgent requirement Thanks in Advance Edited by: 1000899 on Apr 25, 2013 12:01 AM Edited by: 1000899 on Apr 25, 2013 12:02 AM
-
IDVD false error "too many menus"
When I attempt to copy and paste a large menu tree, iDVD reports a false error message as below: Too many menus The maximum number of menus in an iDVD project is 99. No more menus can be created. However, I have < 20 menus, and I'm copying a tree wit