on 01-05-2011 8:26 AM
Hi All,
sorry for posting this again, but i haven't found the answer......
I am doing File(FTP) to mail Scenario. i am picking up the flat file from the Source directory using FTP server.For this we dont need any IR Objects. Receiver side i am using mail adapter.I am able to receive the mail. But it is coming as a .xml attachment. I want the payload as Body of the mail...... or atleast as .txt attachment.
I am using the mail adapter without mail package
If i have to use mail package, then how to do it, bcz there is no source structure to map with the mail structure as i am picking the flat file using FTP server
Transport Protocol: SMTP
Message Protocol: XIPAYLOAD
Without mail package
I have used Module configuration also but no luck....
I used Message Transform Bean
Transform.ContentType text/plain;chaeset=utf-8
Transform.ContentDisposition inline
Its giving an error like " error in method process, transaction is marked for roll back"
Please help me in getting the Requirment...........
Regards,
Raju
Hi Raju,
If your are using >= SAP PI7.1 above code will work. If you are using <SAP PI7.1 below code will work. Please take help of your colleague who had already worked with Java Mapping before.
package com.Mail;
import java.io.*;
import com.sap.aii.mapping.api.*;
import java.util.Map;
public class MailPackage_JavaMapping1 implements StreamTransformation {
private Map map;
public void setParameter(Map map1) {
}
public void execute(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException {
try {
//Edit these values
String Subject = "Enter your Subject here";
String From = "From@gmail_com";
String To = "To@gmail_com;To1@gmail_com;To3@gmail_com";
String Content_Type = "text/plain";
//Read the input payload, which is flat file
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
String Content = new String(b);
String outputMailPackage = "";
outputMailPackage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ns:Mail xmlns:ns=\"http://sap.com/xi/XI/Mail/30\"> <Subject>"
+ Subject + "</Subject> <From>" + From + "</From> <To>" + To + "</To> <Reply_To /> <Content_Type>"
+ Content_Type + "</Content_Type> <Content>" + Content + "</Content> </ns:Mail>";
outputstream.write(outputMailPackage.getBytes());
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
Regards,
Raghu_Vamsee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can get a .txt with coma separated values in it by using these modules.
1 localejbs/AF_Modules/StrictXml2PlainBean Local Enterprise Bean strict2plain
2 localejbs/AF_Modules/MessageTransformBean Local Enterprise Bean contentType
5 sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
contentType Transform.ContentDispostion : attachment;
contentType Transform.ContentType : text/plain;charset="UTF-8";name="Attachment.csv/txt"
contentType Transform.Description : file
strict2plain DataRecord.endSeparator : \r\n
strict2plain DataRecord.fieldSeparator : ,
strict2plain fieldNames : "list of fields"
strict2plain recordTypes : DataRecord
Regards
Aravind
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vamsee,
the code you suggested is not compiling..... its giving some errors.......... may be the Classes
AbstractTransformation
TransformationInput
TransformationOutput are not there in the XI server....... can you please suggest some different code.........
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
package com.Mail;
import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class MailPackage_JavaMapping extends AbstractTransformation {
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
try {
//Edit these values
String Subject = "Enter your Subject here";
String From = "From@gmail_com";
String To = "To@gmail_com;To1@gmail_com;To3@gmail_com";
String Content_Type = "text/plain";
//Read the input payload, which is flat file
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
String Content = new String(b);
//Constructing the XML message <a href="http://help.sap.com/saphelp_nwpi711/helpdata/en/6b/4493404f673028e10000000a1550b0/frameset.htm" TARGET="test_blank">http://help.sap.com/saphelp_nwpi711/helpdata/en/6b/4493404f673028e10000000a1550b0/frameset.htm</a>
String outputMailPackage = "";
outputMailPackage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ns:Mail xmlns:ns=\"http://sap.com/xi/XI/Mail/30\"> <Subject>"
+ Subject + "</Subject> <From>" + From + "</From> <To>" + To + "</To> <Reply_To /> <Content_Type>"
+ Content_Type + "</Content_Type> <Content>" + Content + "</Content> </ns:Mail>";
outputstream.write(outputMailPackage.getBytes());
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi raju.danthuluri,
MessageTransformBean http://help.sap.com/saphelp_nwpi711/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm should work. But I do not know why it is not working. Give it a try with some more possible combinations.
Now that MessageTransformBean is not working. Letu2019s go with u201CUse Mail Packageu201D option in receive mail channel. As you know, to use u201CUse Mail Packageu201D, the payload which is going to Receiver channel should look like this, http://help.sap.com/saphelp_nwpi711/helpdata/en/6b/4493404f673028e10000000a1550b0/frameset.htm
<?xml version="1.0" encoding="UTF-8"?>
<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
<Subject>Subject</Subject>
<From>namea@company_com</From>
<To>nameb@company_com</To>
<Reply_To />
<Content_Type>text/plain</Content_Type>
<Content>
This is the content.
</Content>
</ns:Mail>
Now you have to use ESR objects. We cannot use Graphical, XSLT mapping as input in this case is not XML (it is flat file). So, letu2019s go with Java Mapping (help - ).
Step 1: Import XSD and this XSD is for input and output structures (SAP Note 748024: Here you can download the XSD structure of the Mail Package) (Note: You can use some dummy DT and MT).
Step 2: Create Sender and Receiver Message Interfaces using imported XSD.
Step 3: Create an Operational mapping using above Message Interfaces (Step 2).
Step 4: Create a Java Mapping, using below code. Use this Java Mapping in Operational mapping.
Step 5: In Receiver Mail channel select u201CUse Mail Packageu201D.
Step 6: Test the interface, in SXI_MONITOR, payload should look same as above XML.
Regards,
Raghu_Vamsee
Edited by: Raghu Vamsee on Jan 9, 2011 1:56 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I already used MessageTransformBean
I have mentioned the parameters that i have used in my post..
please see and let me know it is correct or not.......
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the error is.....
Delivery of the message to the application using connection Mail_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Exception thrown in method process. The transaction is marked for rollback.: com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception thrown in method process. The transaction is marked for rollback..
Thanks for your quick reply
I already followed the guide, but can we do without mail package.
if mail package is compulsary, then how to map the mail structure with source flat file
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.