on 09-12-2016 2:32 PM
Hi Experts,
My requirement is PI has to pick one CSV file from third party and place it into another third party( SFTP to SFTP). After placing the file into the server PI has to send an email notification to business user.
I have used mail package to achieve this. Mapped Subject, From, To fields with required constants and Content field mapped with the below UDF and Date function.
UDF code:
public String MailBody(String date, Container container) throws StreamTransformationException{
try
{
String MyFileName= "";
String output = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
MyFileName = conf1.get(key1);
MyFileName = MyFileName.substring(0, MyFileName.lastIndexOf("."));
output = MyFileName + " has been sent to ADP on " + date;
conf1.put(key1, MyFileName);
return output;
}
catch(Exception e) {
String exception = e.toString();
return exception;
}
I am encountering the below error after the file transmission in PI.
Error:
Mapping "http://www.varian.com/inbound/TRION/OM_MAIL_TRIONIB" failed to execute: MappingException: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_TRIONIB_ECC_; Details: com.sap.aii.utilxi.misc.api.BaseRuntimeException; Content is not allowed in prolog., ApplicationRuntimeException: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_TRIONIB_ECC_; Details: com.sap.aii.utilxi.misc.api.BaseRuntimeException; Content is not allowed in prolog., BaseRuntimeException: Content is not allowed in prolog., BaseRuntimeException: Content is not allowed in prolog., org.xml.sax.SAXParseException: Content is not allowed in prolog.
Appreciate your quick help!
Followed the below blog but no luck!
Thanks
Gayathri.
Hi Gayathri,
May be you have a junk character in your payload, check this thread Java parsing XML document gives "Content not allowed in prolog." error - Stack Ove...
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ryan, Below is the CSV file after decrypting. Output: CompID,Employee ID,Code Type,Filler,Code,Amount,Amount Type,Frequency,Limit,Revision Date,Revision Rate/Amount | ||||
VARIAN,959334,DEDUCTION,,DIS,34.74,$,P,,, | ||||
VARIAN,959334,SUPPAY,,609,2.49,$,P,,, | ||||
VARIAN,959334,DEDUCTION,,ADD,5.33,$,P,,, | ||||
VARIAN,959334,DEDUCTION,,SUP,16.75,$,P,,, | ||||
VARIAN,963569,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,963569,DEDUCTION,,M10,52.00,$,P,,, | ||||
VARIAN,963569,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,963569,SUPPAY,,609,0.00,$,P,,, | ||||
VARIAN,958762,DEDUCTION,,DIS,0.00,$,P,,, | ||||
VARIAN,958762,DEDUCTION,,D03,0.00,$,P,,, | ||||
VARIAN,958762,DEDUCTION,,DAP,82.84,$,P,4000,, | ||||
VARIAN,958762,DEDUCTION,,VSP,0.00,$,P,,, | ||||
VARIAN,958762,DEDUCTION,,M28,0.00,$,P,,, | ||||
VARIAN,962603,DEDUCTION,,D03,9.68,$,P,,, | ||||
VARIAN,962603,DEDUCTION,,M10,130.53,$,P,,, | ||||
VARIAN,962603,DEDUCTION,,VBP,5.46,$,P,,, | ||||
VARIAN,963240,DEDUCTION,,SL1,3.09,$,P,,, | ||||
VARIAN,955304,DEDUCTION,,M27,70.62,$,P,,, | ||||
VARIAN,87315,SUPPAY,,609,8.79,$,P,,, | ||||
VARIAN,963380,DEDUCTION,,ABA,11.89,$,P,,, | ||||
VARIAN,963380,DEDUCTION,,ACE,7.32,$,P,,, | ||||
VARIAN,963516,DEDUCTION,,AEA,15.87,$,P,,, | ||||
VARIAN,963516,DEDUCTION,,SL1,3.09,$,P,,, | ||||
VARIAN,963516,DEDUCTION,,ACS,28.13,$,P,,, | ||||
VARIAN,963516,DEDUCTION,,ACE,11.79,$,P,,, | ||||
VARIAN,963638,DEDUCTION,,DIS,12.21,$,P,,, | ||||
VARIAN,963638,DEDUCTION,,HAP,70.00,$,P,560,, | ||||
VARIAN,963638,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,963638,DEDUCTION,,M09,48.24,$,P,,, | ||||
VARIAN,963638,DEDUCTION,,ADD,1.39,$,P,,, | ||||
VARIAN,963638,DEDUCTION,,SUP,10.33,$,P,,, | ||||
VARIAN,963638,DEDUCTION,,SL1,3.62,$,P,,, | ||||
VARIAN,963504,DEDUCTION,,SL1,3.51,$,P,,, | ||||
VARIAN,963397,DEDUCTION,,ABA,4.47,$,P,,, | ||||
VARIAN,964191,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,964191,DEDUCTION,,M01,45.45,$,P,,, | ||||
VARIAN,964191,DEDUCTION,,VBP,3.07,$,P,,, | ||||
VARIAN,964191,DEDUCTION,,CL1,0.88,$,P,,, | ||||
VARIAN,964191,DEDUCTION,,SL1,0.88,$,P,,, | ||||
VARIAN,87999,DEDUCTION,,DIS,9.77,$,P,,, | ||||
VARIAN,87999,SUPPAY,,609,0.52,$,P,,, | ||||
VARIAN,87999,DEDUCTION,,ADD,2.22,$,P,,, | ||||
VARIAN,87999,DEDUCTION,,SUP,3.49,$,P,,, | ||||
VARIAN,959042,DEDUCTION,,DIS,25.67,$,P,,, | ||||
VARIAN,959042,SUPPAY,,609,2.15,$,P,,, | ||||
VARIAN,959042,DEDUCTION,,ADD,4.49,$,P,,, | ||||
VARIAN,959042,DEDUCTION,,SUP,13.01,$,P,,, | ||||
VARIAN,957095,DEDUCTION,,DIS,55.25,$,P,,, | ||||
VARIAN,957095,DEDUCTION,,D02,16.91,$,P,,, | ||||
VARIAN,957095,DEDUCTION,,M27,161.24,$,P,,, | ||||
VARIAN,957095,DEDUCTION,,SAF,6.92,$,P,,, | ||||
VARIAN,957095,DEDUCTION,,VSP,1.46,$,P,,, | ||||
VARIAN,957095,SUPPAY,,609,2.35,$,P,,, | ||||
VARIAN,963398,DEDUCTION,,AEA,5.97,$,P,,, | ||||
VARIAN,963398,DEDUCTION,,ACE,7.18,$,P,,, | ||||
VARIAN,960724,DEDUCTION,,DIS,34.66,$,P,,, | ||||
VARIAN,960724,SUPPAY,,609,1.62,$,P,,, | ||||
VARIAN,960724,DEDUCTION,,ADD,4.71,$,P,,, | ||||
VARIAN,960724,DEDUCTION,,SUP,9.42,$,P,,, | ||||
VARIAN,963632,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,963632,DEDUCTION,,ADD,1.97,$,P,,, | ||||
VARIAN,963632,DEDUCTION,,SL1,0.66,$,P,,, | ||||
VARIAN,963632,DEDUCTION,,ADS,0.28,$,P,,, | ||||
VARIAN,964149,DEDUCTION,,D02,23.98,$,P,,, | ||||
VARIAN,964149,DEDUCTION,,SP5,20.00,$,P,,, | ||||
VARIAN,964149,DEDUCTION,,M27,223.51,$,P,,, | ||||
VARIAN,964149,DEDUCTION,,VBP,7.20,$,P,,, | ||||
VARIAN,964149,DEDUCTION,,CL1,0.88,$,P,,, | ||||
VARIAN,963470,DEDUCTION,,ABA,4.47,$,P,,, | ||||
VARIAN,963123,DEDUCTION,,ACE,13.82,$,P,,, | ||||
VARIAN,963474,DEDUCTION,,ABA,4.47,$,P,,, | ||||
VARIAN,963474,DEDUCTION,,ACE,7.32,$,P,,, | ||||
VARIAN,964244,SUPPAY,,609,3.46,$,P,,, | ||||
VARIAN,963561,DEDUCTION,,PET,3.69,$,P,,, | ||||
VARIAN,963488,DEDUCTION,,PET,3.69,$,P,,, | ||||
VARIAN,963321,DEDUCTION,,ABA,4.47,$,P,,, | ||||
VARIAN,963247,DEDUCTION,,ACS,13.82,$,P,,, | ||||
VARIAN,963247,DEDUCTION,,ACE,13.82,$,P,,, | ||||
VARIAN,963288,DEDUCTION,,ACS,7.18,$,P,,, | ||||
VARIAN,963288,DEDUCTION,,ACE,7.18,$,P,,, | ||||
VARIAN,87609,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,87609,DEDUCTION,,M27,70.62,$,P,,, | ||||
VARIAN,87609,DEDUCTION,,VBP,3.07,$,P,,, | ||||
VARIAN,87609,DEDUCTION,,SUP,4.68,$,P,,, | ||||
VARIAN,87609,DEDUCTION,,SL1,0.00,$,P,,, | ||||
VARIAN,87609,DEDUCTION,,ADS,0.00,$,P,,, | ||||
VARIAN,963434,DEDUCTION,,D03,0.00,$,P,,, | ||||
VARIAN,963434,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,963434,DEDUCTION,,HAP,125.00,$,P,1000,, | ||||
VARIAN,88004,DEDUCTION,,D02,23.98,$,P,,, | ||||
VARIAN,88004,DEDUCTION,,SP5,20.00,$,P,,, | ||||
VARIAN,88004,DEDUCTION,,M27,223.51,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,DIS,11.05,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,HAP,161.11,$,P,1450,, | ||||
VARIAN,963523,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,M27,70.62,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,ADD,3.99,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,SUP,33.30,$,P,,, | ||||
VARIAN,963523,DEDUCTION,,ADS,1.11,$,P,,, | ||||
VARIAN,954896,DEDUCTION,,D02,0.00,$,P,,, | ||||
VARIAN,954896,DEDUCTION,,HAP,101.73,$,P,2310,, | ||||
VARIAN,954896,DEDUCTION,,SP5,0.00,$,P,,, | ||||
VARIAN,954896,,,,0.00,$,P,,, | ||||
VARIAN,954896,DEDUCTION,,M10,0.00,$,P,,, | ||||
VARIAN,954896,DEDUCTION,,VBP,0.00,$,P,,, | ||||
VARIAN,952355,DEDUCTION,,DIS,20.46,$,P,,, | ||||
VARIAN,952355,DEDUCTION,,ADD,2.77,$,P,,, | ||||
VARIAN,32479,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,32479,DEDUCTION,,M10,52.00,$,P,,, | ||||
VARIAN,32479,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,963433,DEDUCTION,,ABA,7.02,$,P,,, | ||||
VARIAN,963450,DEDUCTION,,AEA,12.47,$,P,,, | ||||
VARIAN,32427,DEDUCTION,,DIS,8.68,$,P,,, | ||||
VARIAN,32427,SUPPAY,,609,0.26,$,P,,, | ||||
VARIAN,32427,DEDUCTION,,ADD,1.18,$,P,,, | ||||
VARIAN,32427,DEDUCTION,,SUP,4.66,$,P,,, | ||||
VARIAN,952179,DEDUCTION,,M14,262.74,$,P,,, | ||||
VARIAN,964152,DEDUCTION,,DIS,5.11,$,P,,, | ||||
VARIAN,964152,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,964152,DEDUCTION,,M14,71.64,$,P,,, | ||||
VARIAN,964152,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,952095,DEDUCTION,,M27,223.51,$,P,,, | ||||
VARIAN,952095,DEDUCTION,,SL1,0.77,$,P,,, | ||||
VARIAN,958221,SUPPAY,,609,1.11,$,P,,, | ||||
VARIAN,958221,DEDUCTION,,ADD,1.66,$,P,,, | ||||
VARIAN,958221,DEDUCTION,,SUP,6.54,$,P,,, | ||||
VARIAN,964201,SUPPAY,,609,5.54,$,P,,, | ||||
VARIAN,963492,DEDUCTION,,SUP,96.37,$,P,,, | ||||
VARIAN,963492,DEDUCTION,,SL1,5.26,$,P,,, | ||||
VARIAN,963494,DEDUCTION,,M09,110.04,$,P,,, | ||||
VARIAN,963494,SUPPAY,,609,6.23,$,P,,, | ||||
VARIAN,956112,SUPPAY,,609,6.09,$,P,,, | ||||
VARIAN,956112,DEDUCTION,,ADD,0.96,$,P,,, | ||||
VARIAN,964153,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,964153,DEDUCTION,,M27,70.62,$,P,,, | ||||
VARIAN,964153,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,964153,SUPPAY,,609,2.70,$,P,,, | ||||
VARIAN,963406,DEDUCTION,,AEA,5.97,$,P,,, | ||||
VARIAN,963406,DEDUCTION,,ACE,7.18,$,P,,, | ||||
VARIAN,963362,DEDUCTION,,AEA,15.87,$,P,,, | ||||
VARIAN,963362,DEDUCTION,,ACE,11.79,$,P,,, | ||||
VARIAN,91183,DEDUCTION,,DIS,25.32,$,P,,, | ||||
VARIAN,91183,SUPPAY,,609,4.06,$,P,,, | ||||
VARIAN,91183,DEDUCTION,,ADD,0.96,$,P,,, | ||||
VARIAN,87675,SUPPAY,,609,0.03,$,P,,, | ||||
VARIAN,33874,DEDUCTION,,DAP,32.50,$,P,260,, | ||||
VARIAN,33874,DEDUCTION,,HAP,32.50,$,P,260,, | ||||
VARIAN,33874,DEDUCTION,,CL1,0.88,$,P,,, | ||||
VARIAN,33874,DEDUCTION,,ADD,3.96,$,P,,, | ||||
VARIAN,33874,DEDUCTION,,ADC,0.28,$,P,,, | ||||
VARIAN,33874,DEDUCTION,,SUP,13.07,$,P,,, | ||||
VARIAN,33874,DEDUCTION,,SL1,0.77,$,P,,, | ||||
VARIAN,33874,DEDUCTION,,ADS,1.11,$,P,,, | ||||
VARIAN,960556,DEDUCTION,,M28,89.11,$,P,,, | ||||
VARIAN,964182,SUPPAY,,609,0.62,$,P,,, | ||||
VARIAN,960144,DEDUCTION,,D02,16.91,$,P,,, | ||||
VARIAN,960144,DEDUCTION,,M28,89.11,$,P,,, | ||||
VARIAN,960144,DEDUCTION,,HSF,472.11,$,P,,, | ||||
VARIAN,960144,DEDUCTION,,HS5,500.00,$,P,500,, | ||||
VARIAN,960144,DEDUCTION,,VSP,1.46,$,P,,, | ||||
VARIAN,960144,DEDUCTION,,HSS,0.00,$,P,,, | ||||
VARIAN,964161,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,964161,DEDUCTION,,M27,70.62,$,P,,, | ||||
VARIAN,964161,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,963462,DEDUCTION,,AEA,12.47,$,P,,, | ||||
VARIAN,963462,DEDUCTION,,ACE,7.18,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,DIS,24.56,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,HAP,62.50,$,P,500,, | ||||
VARIAN,91096,DEDUCTION,,D02,23.98,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,M27,223.51,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,SAF,6.92,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,VBP,7.20,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,CL1,0.88,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,ADD,4.32,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,ADC,0.28,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,SUP,19.01,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,SL1,0.77,$,P,,, | ||||
VARIAN,91096,DEDUCTION,,ADS,1.11,$,P,,, | ||||
VARIAN,960854,SUPPAY,,609,0.39,$,P,,, | ||||
VARIAN,960598,DEDUCTION,,ACE,4.32,$,P,,, | ||||
VARIAN,959929,DEDUCTION,,DIS,10.82,$,P,,, | ||||
VARIAN,959929,SUPPAY,,609,0.25,$,P,,, | ||||
VARIAN,963454,DEDUCTION,,ACE,3.99,$,P,,, | ||||
VARIAN,32354,DEDUCTION,,DIS,15.98,$,P,,, | ||||
VARIAN,32354,DEDUCTION,,ADD,2.16,$,P,,, | ||||
VARIAN,32354,DEDUCTION,,SUP,4.32,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,DIS,4.09,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,D03,4.11,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,M10,113.37,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,VSP,1.25,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,CL1,0.53,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,ADD,0.56,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,ADC,0.17,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,SUP,1.07,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,SL1,0.55,$,P,,, | ||||
VARIAN,964197,DEDUCTION,,ADS,0.17,$,P,,, | ||||
VARIAN,963634,DEDUCTION,,D02,7.18,$,P,,, | ||||
VARIAN,963634,DEDUCTION,,M10,52.00,$,P,,, | ||||
VARIAN,963634,DEDUCTION,,VSP,0.70,$,P,,, | ||||
VARIAN,32223,DEDUCTION,,DIS,17.02,$,P,,, | ||||
VARIAN,32223,DEDUCTION,,ADD,2.33,$,P,,, | ||||
VARIAN,32223,DEDUCTION,,SUP,3.43,$,P,,, | ||||
VARIAN,963350,DEDUCTION,,ABA,4.47,$,P,,, | ||||
VARIAN,963350,DEDUCTION,,ACE,7.32,$,P,,, | ||||
VARIAN,963502,DEDUCTION,,AEA,12.47,$,P,,, | ||||
VARIAN,963503,DEDUCTION,,AEA,5.97,$,P,,, | ||||
VARIAN,963503,DEDUCTION,,ACE,3.99,$,P,,, | ||||
VARIAN,91145,DEDUCTION,,ACS,7.18,$,P,,, | ||||
VARIAN,960696,SUPPAY,,609,1.38,$,P,,, | ||||
VARIAN,962333,DEDUCTION,,D03,9.68,$,P,,, | ||||
VARIAN,962333,DEDUCTION,,M09,119.12,$,P,,, | ||||
VARIAN,962333,DEDUCTION,,VSP,1.46,$,P,,, Thanks Gyaathri. |
Hi Gayathri,
In order to have the graphical message mapping process the message the payload would need to be in the following format based on your definition:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_TRIONIB_PI xnmlns:ns0="http://www.varian.com/inbound/TRION">
<FileName>somefile.csv</FileName>
</ns0:MT_TRIONIB_PI>
To get this after decryption you would need to use the MessageTransformBean to get the flat file contents into an appropriate XML format or the system will give you the message that you are getting about content not being allowed in the prolog.
Regards,
Ryan Crosby
Hi Ryan,
My requirement is just to send an email notification after the file transformation. Till file transfer its working fine, I have used java mapping to send required( after decryption using PGP DEC module in sender channel) file as an attachment to receiver.
To send email notification i am using one more mapping with dummy source structure(MT_TRIONINB_PI) and receiver message type as(External message -- Mail). So i am getting an error in mail step.
Could you please explain in detail about the solution which u have given.
Thanks
Gayathri.
Hi Gayathri,
The message structure has to be in the format I mentioned for a graphical mapping to process it successfully. Based on what you are describing you have a flat file payload that would be the input to your graphical mapping which will cause you to get that error about the prolog.
If you want to process the message after the attachment has been generated then you would need to create XML output that matches the schema of the message type in your operational mapping. Then and only then would the system pick up the message and map it accordingly. Below would be the sequence of steps if I'm understanding your setup correctly that should be followed for it to work and in each step mentions the payload formatting after the step:
1. Pick up file and decrypt - flat file
2. Process flat file payload and create attachment - XML payload with root MT_TRIONIB_PI
3. Execute graphical mapping to create email body - Can be any format since attachment and body have already been generated
4. Receiver channel to output email body along with attachment
Regards,
Ryan Crosby
Hi Ryan,
There are 2 pints here.
1. Decryption and sending file as an attachment( done by using java mapping in one Operational mapping)
public class FileNameExtension extends AbstractTransformation {
public void transform(TransformationInput transformationInput,
TransformationOutput transformationOutput)
throws StreamTransformationException {
try {
InputStream inputstream = transformationInput.getInputPayload()
.getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload()
.getOutputStream();
Map mapParameters = (Map) transformationInput.getInputHeader()
.getAll();
// Set Output File name
DynamicConfiguration conf = (DynamicConfiguration) mapParameters
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
"http://sap.com/xi/XI/System/File", "FileName");
String fname = "";
fname = conf.get(key);
fname = fname.substring(0, fname.lastIndexOf("."));
conf.put(key, fname);
// b) Just copy Input file content to Output file content
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
} catch (Exception exception) {
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
Decryption:
2. Sending an email after the file transmission with only body content( attachment is not required in email) -- Facing problem here
In my requirement mail has to be sent to customer but not with file attachment along with the email.
Only email body should have some text with the source file name. For this I have used UDF and mapped with content field in receiver message type( Mail).
public String MailBody(String date, Container container) throws StreamTransformationException{
try
{
String MyFileName= "";
String output = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
MyFileName = conf1.get(key1);
MyFileName = MyFileName.substring(0, MyFileName.lastIndexOf("."));
output = MyFileName + " has been sent to ADP on " + date;
conf1.put(key1, MyFileName);
return output;
}
catch(Exception e) {
String exception = e.toString();
return exception;
}.
1. Pick up file and decrypt - flat file
2. Process flat file payload and create attachment - java mapping
3. Execute graphical mapping to create email body - Can be any format since attachment and body have already been generated
4. Receiver channel to output email body
Thanks
Gayathri.
Hi Gayathri,
So you are doing a multiple receiver interfaces from one source message... For that to work the way you have it setup currently then you would also need a java mapping for the TRION interface to convert the flat file payload into the appropriate XML format before the graphical mapping executes or you will continue to see that error. A graphical message mapping cannot process a flat file and the content must be in the proper XML format. You can confirm this easily by taking the flat file payload and trying to execute the mapping from the ESR workbench (with the dynamic configuration code commented out).
Regards,
Ryan Crosby
Hi Gayarthi,
Here is a java mapping that you could use to generate the XML source for your graphical mapping. The only change is that the source for your filename parameter on your UDF would come from the "FileName" directly instead of having to read it from dynamic configuration:
import java.net.URL;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.MappingTrace;
public class TRIONMapper extends AbstractTransformation{
private MappingTrace trace;
private static final DynamicConfigurationKey KEY_FILENAME =
DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
@Override
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException {
// Initialize variables, objects for processing
trace = getTrace();
// access dynamic configuration
DynamicConfiguration conf = in.getDynamicConfiguration();
String filename = conf.get(TRIONMapper.KEY_FILENAME);
if(filename == null || filename.compareTo("") == 0)
{
throw new StreamTransformationException("Invalid or missing filename");
}
try {
// Get builder resources
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbFactory.newDocumentBuilder();
Document doc = db.newDocument();
URL namespaceURL = new URL("http://www.varian.com/inbound/TRION");
String namespace = namespaceURL.toString();
// Root element
Element rootElement = doc.createElementNS(namespace, "ns0:MT_TRIONIB_PI");
doc.appendChild(rootElement);
Element fileElement = doc.createElement("FileName");
fileElement.setTextContent(filename);
rootElement.appendChild(fileElement);
// Transform to output
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(out.getOutputPayload().getOutputStream());
transformer.transform(source, result);
} catch(Exception e) {
throw new StreamTransformationException("Unable to create XML payload", e);
}
}
}
I included the instantiation of the "MappingTrace" object in case you want to add some information into the message logs.
Regards,
Ryan Crosby
Hi Praveen,
main payload will be email body and the attachments will be email attachments.
I just want to attach the CSV file ( which is output file after decryption) as email attachment and also email body should be text with file name and date.
So , here what does the main payload refers. How will I ignore this?
Hope you got my point..
Thanks
Gayathri.
Hi Gayatri,
Use below java mapping.
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.Attachment;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.OutputAttachments;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class DynamicEmailBodyJavaMap extends AbstractTransformation {
@Override
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)
throws StreamTransformationException {
StringBuilder sb = new StringBuilder();
try {
String fileName = transformationInput.getDynamicConfiguration().get(
DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName"));
sb.append(fileName);
sb.append(" file has been sent to POD on ");
sb.append(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
transformationOutput.getOutputPayload().getOutputStream().write(sb.toString().getBytes());
OutputAttachments outputAttachements = transformationOutput.getOutputAttachments();
InputStream inputStream = transformationInput.getInputPayload().getInputStream();
byte[] buf = new byte[inputStream.available()];
inputStream.read(buf);
String contentType = "text/plain;charset = \"UTF-8\";name=\"" + fileName + "\"";
Attachment attachment = outputAttachements.create(fileName, contentType, buf);
outputAttachements.setAttachment(attachment);
} catch (Exception e) {
throw new StreamTransformationException(e.getMessage());
}
}
}
Regards,
Praveen.
Hi Gayathri!
Did you try to test your Operation mapping? And what is your source message structure?
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.