cancel
Showing results for 
Search instead for 
Did you mean: 

Exception Handler

Former Member
0 Kudos

Hi All,

I have a scenario where i am doing a value mapping Look up From MDM,Whenever the Value Mapping look Up fails for some reason, May be the MDM system is Down or, Value Mapping Failed because of no matching data, I need to raise an Alert To the Operation Support Team, I am not Using BPM, Please suggest me How would i Achieve this using The Alert Configuration Mechanism, Step by Step procedure would be of much Help. thanks a lot.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Infact I want to raise the Alert for Both the cases,

1.In the else case, When MDM has no data for particular look Up,

2. When any Error Occurs ex: MDM connection Loss.

kindly Suggest.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Please find the code,

//write your code here

try{
MappingTrace trace = container.getTrace();
//write your code here
trace.addInfo("input is ("+strLocalCurrency+","+strForeignCurrency+")");
Vector vt = null;
if(strLocalCurrency.trim().length() >0 && 
strForeignCurrency.trim().length() > 0)
{
trace.addInfo("input is valid ");
MDMLookup lookupHandle = new MDMLookup();
vt = lookupHandle.getNumbers(strLocalCurrency, strForeignCurrency);//String strLocalCurrency, String strForeignCurrency

int total = vt.size();
trace.addInfo("value mapping lookup returned =>"+total+" values");
if (total>0){
counter = counter + total;
htPOSNumbers.put(strLocalCurrency+"#"+strForeignCurrency, vt);
trace.addInfo("hashtable updated for key .. "+strLocalCurrency+"#"+strForeignCurrency);
}else{

trace.addWarning("Exception: value mapping returned 0 matching records");

}// if size is more than 0

}else{
// Business Service --BS_UDFALERT 
// RFC Comm Channle -- CC_UDFALERT_RFC 
 
Channel channel = LookupService.getChannel("BS_UDFALERT", "CC_UDFALERT_RFC" );
 
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>ALRTFRMWRKTEST</IP_CAT> <IT_CONTAINER><item><ELEMENT>DOCNUMBER</ELEMENT> <TAB_INDEX>0</TAB_INDEX> <ELEMLENGTH>250</ELEMLENGTH> <TYPE>C</TYPE> <VALUE>12345</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);

// raise error for faulty input
trace.addWarning("Exception: Incorrect input local currency, foreign currency => ("+strLocalCurrency+","+strForeignCurrency+")");

}// if input is correct.
}
catch(Exception e){
// Business Service --BS_UDFALERT 
// RFC Comm Channle -- CC_UDFALERT_RFC 
 
Channel channel = LookupService.getChannel("BS_UDFALERT", "CC_UDFALERT_RFC" );
 
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>ALRTFRMWRKTEST</IP_CAT> <IT_CONTAINER><item><ELEMENT>DOCNUMBER</ELEMENT> <TAB_INDEX>0</TAB_INDEX> <ELEMLENGTH>250</ELEMLENGTH> <TYPE>C</TYPE> <VALUE>12345</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);

}

Assumptions , data that should be filled by your,

1. In the line , Channel channel = LookupService.getChannel("BS_UDFALERT", "CC_UDFALERT_RFC" );

BS_UDFALERT --> Should be replaced with your Business Service,

CC_UDFALERT_RFC --> SHould point to your Receiver RFC adapter

2. 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><b>ALRTFRMWRKTEST</b></IP_CAT> <IT_CONTAINER><item><ELEMENT><b>DOCNUMBER</b></ELEMENT> <TAB_INDEX>0</TAB_INDEX> <ELEMLENGTH>250</ELEMLENGTH> <TYPE>C</TYPE> <VALUE>12345</VALUE> </item> </IT_CONTAINER></ns0:SALERT_CREATE>";

i ALRTFRMWRKTEST ---> This is the Alert Category you have created in ALRTCATDEF.

ii DOCNUMBER ---> This is the Container Element created in ALRTCATDEF.

Regards

Bhavesh

Former Member
0 Kudos

Hi,

I am a bit weak in java, I have Pasted the UDF that retrieves the Look Up value from Hash table, Please let me know

1. where to Wrap the TRY-CATCH, And Moreover If the MDM connection Fails how would I capture it and pass to the RFC.

2.Is there any other Configuration that has to be done in RWB.Please let me know

would be very Gratefull Thank you.

UDF- getNumbers

==============

//write your code here

MappingTrace trace = container.getTrace();

//write your code here

trace.addInfo("input is ("strLocalCurrency","strForeignCurrency")");

Vector vt = null;

if(strLocalCurrency.trim().length() >0 &&

strForeignCurrency.trim().length() > 0)

{

trace.addInfo("input is valid ");

MDMLookup lookupHandle = new MDMLookup();

vt = lookupHandle.getNumbers(strLocalCurrency, strForeignCurrency);//String strLocalCurrency, String strForeignCurrency

int total = vt.size();

trace.addInfo("value mapping lookup returned =>"total" values");

if (total>0){

counter = counter + total;

htPOSNumbers.put(strLocalCurrency"#"strForeignCurrency, vt);

trace.addInfo("hashtable updated for key .. "strLocalCurrency"#"+strForeignCurrency);

}else{

trace.addWarning("Exception: value mapping returned 0 matching records");

}// if size is more than 0

}else{

// raise error for faulty input

trace.addWarning("Exception: Incorrect input local currency, foreign currency => ("strLocalCurrency","strForeignCurrency")");

}// if input is correct.

return "";

bhavesh_kantilal
Active Contributor
0 Kudos

John,

Can you let me know where you want to trigger the Alert?

Is it in your ELSE condition? Or is it when some exception / error ooccurs?

Regards

Bhavesh

Former Member
0 Kudos

Hi ,

The Scenario is Using a MDM Look Up API(Value Mapping Replication) which updates the XI Cache, By using a UDF I pick up the Cached Values to be used in My mapping. , Could you please tell me how would I go about creating Alerts in this kind of a Scenario.I have Gone thru your Web Log "/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function

" However got confused a Bit Kindly help

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

><i> By using a UDF I pick up the Cached Values to be used in My mapping</i>

Wrap your UDF with a TRY -- CATCH block and inside the CATCH , use the code I have given in my blog to triiger your XI alert.

import com.sap.aii.mapping.lookup.*; 
import java.io.*;

// Business Service --BS_UDFALERT 
// RFC Comm Channle -- CC_UDFALERT_RFC 

Channel channel = LookupService.getChannel("BS_UDFALERT", "CC_UDFALERT_RFC" );

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>ALRTFRMWRKTEST</IP_CAT> <IT_CONTAINER><item><ELEMENT>DOCNUMBER</ELEMENT> <TAB_INDEX>0</TAB_INDEX> <ELEMLENGTH>250</ELEMLENGTH> <TYPE>C</TYPE> <VALUE>12345</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);

The IP_CAT --> Will contain the Alert Category created in ALRTCATDEF.

ITCONTAINER --> WIll contain any container element that you want to fill up in your alert.

To understand how to create an Alert Category , look into the first part of the blog pointed by Shabrish.

Read through the blog and let us know if you need any specific pointers

Regards

Bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

how are you doing the ValueMapping lookup?

Are you using a RFC lookup in a User DFefined Mapping?

If yes, you can trigger alerts from a user defined function itself.

Look into my blog and check if this is what you want,

/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function

Regards

Bhavesh

Shabarish_Nair
Active Contributor
0 Kudos

You could look into these blogs to get an idea on alerts !!!

/people/michal.krawczyk2/blog/2005/09/09/xi-alerts--troubleshooting-guide

/people/michal.krawczyk2/blog/2005/09/09/xi-alerts--step-by-step