cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger/Generate an custom alert from UDF using CBMA to Solman

vijayakhanna_raman
Active Contributor
0 Kudos

Hi All,

How can i generate / trigger the custom alert message to send it alert rule created in ID when solman as consumer in CBMA?

This is a basically a kind of validation warning message from my message mapping program which i need to send it to Solman. As the interface message will not fail, the error message will not be automatically captured using Component Based Alerts to solman.


I have a requirement where i need to send a alert message from my mapping program UDF to the alert rule created in NWA with out failing the message mapping program.


so please provide a way to call the alert API to send the message to capture these warning/info message.


ex: Message payload of message ID 12344545 is having a wrong batch record value.

Please provide your input this.

Note:

   I am aware of creating Component Based Alerts rule in NWA and solman as a consumer to send alerts in case of mapping error or failures.

Thanks,

Vijay

Accepted Solutions (1)

Accepted Solutions (1)

vinaymittal
Contributor
0 Kudos

Hi

For calling the ALERT function module as you can see in this link

Triggering XI Alerts from a User Defined Function

Imports java.io.;com.sap.aii.mapping.lookup.;

Alerts can be sent by a UDF by calling RFC responsible for sending ALERTS

//sample code for RFC loopup

java.util.Map map;

try {

String msgid;

map = container.getTransformationParameters();

msgid = (String) map.get(StreamTransformationConstants.MESSAGE_ID);

Channel channel = LookupService.getChannel("DE1CLNTXXX","CC_RFC_R_PI");

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

String rfcXML= "<ns0:SALERT_CREATE xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">"+

      "<IP_ALIAS/>"+

      "<IP_APPLICATION_GUID/>"+

      "<IP_CAT>ALERT_TEST_UDF</IP_CAT>"+

      "<IP_XML_CONTAINER/>"+

      "<IT_CONTAINER>"+

         "<item>"+

            "<ELEMENT>ZCUSTOMER</ELEMENT>"+

            "<TAB_INDEX>0</TAB_INDEX>"+

            "<ELEMLENGTH>20</ELEMLENGTH>"+

            "<TYPE>C</TYPE>"+

            "<VALUE>"+pnum+"</VALUE>"+

         "</item>"+

           "<item>"+

            "<ELEMENT>ZMSGID</ELEMENT>"+

            "<TAB_INDEX>1</TAB_INDEX>"+

            "<ELEMLENGTH>70</ELEMLENGTH>"+

            "<TYPE>C</TYPE>"+

            "<VALUE>"+msgid+"</VALUE>"+

         "</item>"+

      "</IT_CONTAINER>"+

    "</ns0:SALERT_CREATE>";

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

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload rfcOutPayload = accessor.call(payload);

throw new  StreamTransformationException ( " Message Mapping Failed because of invalid Customer number");

}

catch(Exception e)

{

  throw new RuntimeException("Exception while checking for Distribution channel : "+e);

}

//************************************************

vijayakhanna_raman
Active Contributor
0 Kudos

Thank Vinay,

But i am planning to use CBMA and not RFC lookup as this might affects the performance.

Answers (1)

Answers (1)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Vijaya,

Can you refer the below links.

Trigger customized email on error in PI | SCN