on 06-22-2015 4:52 PM
Hi,
I want to send out an email in case if an empty file is received from the source system.
I have already explored the following options:
1. Check filesize in Receiver determination and route it to a Mail receiver : This would not work as in case of empty file ...no PI message would be created.
2. UDF would not work too for the reason cited above
Could you please share your experience of handling such a requirement ? I think EJB module is the only solution....please share the code if you have handled this.
Thanks..
Thanks everyone for your response.
I solved the issue by creating a receiver for Mail business component in case of empty file (Receiever Determination --> Filesize = 0)......used dummy mapping and interface in IM......and did not use Mail package in Receiver mail adapter....
This helped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arijit,
I have same requirement please guide me how to achieve this email alert.
Hi Arijit,
Just a hint. Maybe create 2 mappings as follows:
:
1) From your source to target structure (File to File)
2) From your source to mail structure ( File To Mail)
And then use BPM - SWITCH step for conditional routing.
I have not tried it, but I guess you can try and see.
Regards,
Mateen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mateen,
This approach would not work as there is no payload in case of empty file so the message would fail in message mapping step with the error :
Runtime exception occurred during application mapping com/sap/xi/tf/_MM_SF_EmployeeData_To_HMS_ReceiveM~; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Premature end of file.</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
Hi Arijit,
Put a condition in the SWITCH step (maybe based on a key field) such that the mapping "MM_SF_EmployeeData_To_HMS_Receive" would execute if the payload is not empty and the other mapping (create a mapping to the Mail package structure and use default values in the mapping) would execute if the payload is empty.
Regards,
Mateen
Adapter module can be a good option but one more option if u r comfortable with scripts/command line
Run a Batch script before message pick in channel.
In Script check file size if empty put a string "Empty". Now you can use Graphical mapping and route it to mail adapter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Batch script would be a very discrete design and add another overhead in the overall design.
Your second option would not work as
there is no payload in case of empty file so the message would fail in message mapping step with the error :
Runtime exception occurred during application mapping com/sap/xi/tf/_MM_SF_EmployeeData_To_HMS_ReceiveM~; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Premature end of file.</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
Hi Arjit,
You can check file size + send email at mapping level.
For example:
1. To check the file this wiki can be helpful File Lookup in UDF - Process Integration - SCN Wiki. Of course, you will need some changes
2. To send an email without mail adapter: Mail without email adapter? Part - I - Process Integration - SCN Wiki
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Inaki,
As i have said, if the input is empty file then there would not be any input payload and the message would fail with the following error message in message mapping step:
Runtime exception occurred during application mapping com/sap/xi/tf/_MM_SF_EmployeeData_To_HMS_ReceiveM~; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Premature end of file.</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
Hi Arijit,
You could use a java mapping to read the stream and generate a trigger message type in the event that the payload is empty and simply pass the stream otherwise. In that way you could use the newly inserted information to determine if the message should pass on success or be sent to another process so that the email is triggered.
Regards,
Ryan Crosby
Hi Arijit,
Here is a sample of some code that you could use to insert a message using the java mapping:
// IO libraries
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
// Stream transformation libraries
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 Test extends AbstractTransformation
{
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException
{
try
{
// Read InputStream of input payload
BufferedReader br = new BufferedReader(new InputStreamReader(in.getInputPayload().getInputStream()));
OutputStream os = out.getOutputPayload().getOutputStream();
StringBuilder sb = new StringBuilder();
char[] chars = new char[4096];
while(br.read(chars) != -1)
{
// append characters bytes to stringbuilder
sb.append(chars);
}
// Check if any characters have been written
if(sb.length() == 0)
{
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
sb.append("<ns:MT_EMPTY xmlns:ns=\"http://namespace.com\">\r\n");
sb.append("<isEmpty>true</isEmpty>");
sb.append("</ns:MT_EMPTY>\r\n");
}
// Write to output stream
os.write(sb.toString().getBytes());
os.flush();
os.close();
}
catch (IOException e)
{
throw new StreamTransformationException("Unable to read payload", e);
}
}
}
You would just need to figure out how to handle and route the two message types but theoretically you should be able to achieve it with something like this...
Regards,
Ryan Crosby
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.