cancel
Showing results for 
Search instead for 
Did you mean: 

XI Alerts from UDF using file adapter.

Former Member
0 Kudos

I need to send alerts from XI message mapping. I have the file ---> file scenario but don't want he stop the process if any failures in the mapping. If I find any failures, I need to catch the those failures and send as alerts/email report. As per the link /people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function, I am not sure whether I can use LookupService for file adapter or not. Can anyone give me some idea on how to send the alerts from UDF using he file adapter ?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Try this...

public String Mail_Test(String input,Container container){

      // Recipient's email ID needs to be mentioned.

      String to = "<Recipient mail ID>";

        // Sender's email ID needs to be mentioned

      String from = "<Sender mail ID>";

       // Assuming you are sending email from localhost

       String host = "<Hostname of the SMTP server>";

     

       // Get system properties

       Properties properties = System.getProperties();

     

      // Setup mail server

      properties.setProperty("mail.smtp.host", host);

      // Get the default Session object.

      Session session = Session.getDefaultInstance(properties);

       try{

             // Create a default MimeMessage object.

            MimeMessage message = new MimeMessage(session);

             // Set From: header field of the header.

             message.setFrom(new InternetAddress(from));

             // Set To: header field of the header.

             message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));

             // Set Subject: header field

             message.setSubject("Check the problem dude...");

             // Now set the actual message

             message.setText("You did blunder correct that...");

             // Send message

             Transport.send(message);

             System.out.println("Sent message successfully....");

      }

      catch (MessagingException mex) {

            mex.printStackTrace();

            throw new RuntimeException(mex.getMessage());

      }

      return input;

  }

Former Member
0 Kudos

Hi Satya,

Its very much possible to use RFC Lookup Api's in ur scenario .

Once u have configured ur reciever RFC adapter u can refer that in ur Message mapping .

As already told u can catch soft / data validation errors

In case u want to catch exception and then throw alert u can use these blogs

along with the other blog u have mentioned

/people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping

/people/sap.user72/blog/2005/02/23/raising-exceptions-in-sap-xi-mapping

Regards

Kavitha

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

depends on what kind of errors you want to catch:

- if you want to catch simple errors (like wrong value) you can send alert from UDF

- if you want to catch all errors (even critical) you can either use

a BPM with a catch block (which will catch all errors) and enable you to process

the flow - or you can create a java mapping inside which you will validate if the

mapping was ok or not and send alert from there

so the approach depends on:

message volume

type of errors you need to handle

Regards,

michal

Former Member
0 Kudos

Try to send the alerts from UDF but could not call the adapter from UDF. Here is the error 'Cannot invoke call from within a transactional context.'.

com.sap.aii.mapping.lookup.LookupException: Problem when calling an adapter by using communication channel FILESENDER (Party: , Service: TestFileReceive, Object ID: 9dafdbe501163068a7594caf04124f2d) XI AF API call failed. Module exception: 'senderChannel '9dafdbe501163068a7594caf04124f2d': Catching exception calling messaging system'. Cause Exception: 'Cannot invoke call from within a transactional context.'.

Former Member
0 Kudos

Satya,

Error : com.sap.aii.mapping.lookup.LookupException: Problem when calling an adapter by using communication channel FILESENDER

Or u trying to call a FileCC from UDF ?

Former Member
0 Kudos

The following code used to trigger alerts. It is failed when it calls .rfcOutPayload = accessor.call(payload);

Channel channel = LookupService.getChannel("TestFileReceive", "FILESENDER" );

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

String rfcxml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:SALERT_CREATE xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><IP_APPLICATION_GUID/> <IP_CAT>XI_DUP_ALETS</IP_CAT> <IT_CONTAINER><item><ELEMENT>DOCNUMBER</ELEMENT> <TAB_INDEX>0</TAB_INDEX> <ELEMLENGTH>250</ELEMLENGTH> <TYPE>C</TYPE> <VALUE>Duplicates</VALUE> </item> </IT_CONTAINER></ns0:SALERT_CREATE>";

InputStream inputStream =new ByteArrayInputStream(rfcxml.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload rfcOutPayload = null;

rfcOutPayload = accessor.call(payload);

strresult = "Success";

Former Member
0 Kudos

Hi Satya,

<b>Channel channel = LookupService.getChannel("TestFileReceive", "FILESENDER" );</b>

can u cross check if u have done these :

1)in LookupService.getChannel ( "BusinessSystem","Reciever RFCCommunication channel")

2) mapping lookup api added

3) put a try /catch block to know the exact exception

Hope u resolve

Kavitha