Skip to Content
author's profile photo Former Member
Former Member

Issue in RFCLookup UDF


Hi All,

Requesting your help in fixing an UDF issue.

This UDF is to check for a table entry and if not found it will create an alert with some source values.

Now the problem is, alert mails are getting created but the values are not getting passed.

Here is the source code:

AbstractTrace trace;
trace = container.getTrace();

MappingTrace trace1;
trace1 = container.getTrace();


Object cachedValue = null;
String result = null;
String sender = null;
String receiver = null;

//Check if source is null or blank. If so then pass blank value to target
if(((sourceValue1.trim()).equals("")) || ((sourceValue2.trim()).equals("")) || ((sourceValue3.trim()).equals("")))
{
result="";


}
else
{
Map map = container.getTransformationParameters();
//Sender System name which is the same as the Sender Business System name in Integration Directory
sender = (String) map.get(StreamTransformationConstants.SENDER_SYSTEM);
//Receiver System name which is the same as the Receiver Business System name in Integration Directory
receiver = (String) map.get(StreamTransformationConstants.RECEIVER_SYSTEM);

// Parameter for cache value. A semicolon is used as a separator between keys
String CONTAINER_PARAMETER = subCat.trim() + UDFReader.getString("PARAMETER_DELIMETER") +sourceValue1.trim() + UDFReader.getString("PARAMETER_DELIMETER") +sourceValue2.trim() + UDFReader.getString("PARAMETER_DELIMETER") +sourceValue3.trim();

trace1.addWarning("CONTAINER PARAMETER: " + CONTAINER_PARAMETER + "\n");

trace.addDebugMessage(UDFReader.getString("CACHE_CONTAINER_PARAMETER_TEXT") + CONTAINER_PARAMETER);

// Retrieve cached value
cachedValue = container.getParameter(CONTAINER_PARAMETER);
if(cachedValue!=null)
{
// Cached value found
result = cachedValue.toString();
trace.addDebugMessage(UDFReader.getString("CACHE_RESULT_TEXT") + result);
}
else
{
// Cached value not present. Fetch value from database
// Build key column names array to be passed to java class
String keyColNames[] =new String[6];
keyColNames[0]=UDFReader.getString("SAP_SYSTEM_COLUMN_NAME");
keyColNames[1]=UDFReader.getString("LEGACY_SYSTEM_COLUMN_NAME");
keyColNames[2]=UDFReader.getString("SUBCATEGORY_COLUMN_NAME");
keyColNames[3]=sourceField1;
keyColNames[4]=sourceField2;
keyColNames[5]=sourceField3;

trace1.addWarning("KeyColNames" + keyColNames[0] + "\n" + keyColNames[1] + "\n" + keyColNames[2] + "\n" + keyColNames[3] + "\n" + keyColNames[4] + "\n" + keyColNames[5] + "\n");

// Build key column values array to be passed to java class
String keyColValues[] = new String[6];

//Check whether sender system is SAP or Legacy
if(sourceField1.startsWith(UDFReader.getString("SAP_SYSTEM_PREFIX")))
{
//Sender system is SAP
keyColValues[0]=sender;
//Receiver system is Legacy
keyColValues[1]=receiver;
}
else
{
//Receiver system is SAP
keyColValues[0]=receiver;
//Sender system is Legacy
keyColValues[1]=sender;
}
keyColValues[2]=subCat.trim();
keyColValues[3]=sourceValue1.trim();
keyColValues[4]=sourceValue2.trim();
keyColValues[5]=sourceValue3.trim();

// Fetch result using java class
result=RfcLookupHandler.RFCLookup(table,keyColNames,
keyColValues,targetField,trace);

trace1.addWarning("Result:" + result);

if(!result.equals(RfcLookupHandler.VALNOTFOUND))
{
// Record found in database
container.setParameter(CONTAINER_PARAMETER,result);
}
else
{
// Record not found in database
//Autogenerated message id generated at runtime
String msgId = (String) map.get ( StreamTransformationConstants.MESSAGE_ID);

//Dynamic alert message details-Trigerred through RFC SALERT_CREATE
String element[] = new String[9];
String tabIndex[] = new String[9];
String elementLength[] = new String[9];
String type[] = new String[9];
String value[] = new String[9];

//Container names for alert message
element[0] = UDFReader.getString("CONTAINER_NAME_MESSAGE_ID");
element[1] =UDFReader.getString("CONTAINER_NAME_INTERFACE_NAME");
element[2] =UDFReader.getString("CONTAINER_NAME_OBJECT_TYPE");
//element[2]="SAP_MAT_NO";
element[3] =UDFReader.getString("CONTAINER_NAME_OBJECT_TYPE"); ;
element[4] =UDFReader.getString("CONTAINER_NAME_OBJECT_TYPE");
//element[4]="PLANT";
element[5] = UDFReader.getString("CONTAINER_NAME_OBJECT_VALUE");
element[6] = UDFReader.getString("CONTAINER_NAME_OBJECT_VALUE");
element[7] =UDFReader.getString("CONTAINER_NAME_OBJECT_VALUE");
element[8] ="TABLE";
trace1.addWarning("Warning: \n" + element[0] + "\n" + element[1] + "\n" + element[2] + "\n" + element[3] + "\n" + element[4] + "\n" + element[5] + "\n" + element[6] + "\n" + element[7] + "\n" + element[8]);
//Tab index of container variables in alert message
tabIndex[0] = "000001";
tabIndex[1] = "000002";
tabIndex[2] = "000003";
tabIndex[3] = "000004";
tabIndex[4] = "000005";
tabIndex[5] = "000006";
tabIndex[6] = "000007";
tabIndex[7] = "000008";
tabIndex[8] = "000009";

//Length of containers
elementLength[0] = elementLength[1] = elementLength[2] =elementLength[3] = elementLength[4] = elementLength[5] = elementLength[6] = elementLength[7]=elementLength[8]=UDFReader.getString("CONTAINER_VALUE_LENGTH");

//Data type of containers
type[0] = type[1] = type[2] = type[3] = type[4]=type[5] = type[6] =type[7] ="C";

//Values supplied to containers
value[0] =msgId;
value[1] =interfaceName;
value[2] = sourceField1;
value[3] = UDFReader.getString("MESSAGE_SEPARATOR_HYPHEN") + sourceValue1.trim();
value[4] = UDFReader.getString("MESSAGE_SEPARATOR_COMMA") + sourceField2;
value[5] = UDFReader.getString("MESSAGE_SEPARATOR_HYPHEN") + sourceValue2.trim();
value[6] = UDFReader.getString("MESSAGE_SEPARATOR_COMMA") + sourceField3;
value[7] = UDFReader.getString("MESSAGE_SEPARATOR_HYPHEN") + sourceValue3.trim();
value[8] =table;

trace1.addWarning("Table: "+table);

// Check error handling flag
if(errorHandlingFlag.equalsIgnoreCase("E"))
{
//Throw Error and generate alert message
trace.addInfo(UDFReader.getString("NO_RESULT_FLAG_E_TRACE"));

trace1.addWarning("Error Flag: E");
for (int i=0; i<9; i++){
trace1.addWarning("Parameters["+i+"]: " +value[i]);
}

result = SUPPRESS;
RfcAlertHandler.RFCAlert(alertCat,element,tabIndex,elementLength,type,value,trace);
throw new ValueMappingException(UDFReader.getString("NO_RESULT_FLAG_E_EXCEPTION"));


}
else if(errorHandlingFlag.equalsIgnoreCase("N"))
{
//Pass 'NA' value to target
result=UDFReader.getString("NO_RESULT_FLAG_N_VALUE_PASSED");
trace.addInfo(UDFReader.getString("NO_RESULT_FLAG_N_TRACE"));

trace1.addWarning("Error Flag: N");

}
else if(errorHandlingFlag.equalsIgnoreCase("B"))
{
//Pass blank value to target
result="";
trace.addInfo(UDFReader.getString("NO_RESULT_FLAG_B_TRACE"));

trace1.addWarning("Error Flag: B");

}
else
{
//Incorrect Error Handling Flag
trace.addInfo(UDFReader.getString("INCORRECT_FLAG_TRACE"));

trace1.addWarning("Error Flag: INCORRECT");

result = SUPPRESS;
throw new ValueMappingException(UDFReader.getString("INCORRECT_FLAG_EXCEPTION"));

}
}
}
}
return result;

Can someone check where could be the problem?

Thanks,

Glory.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jul 23, 2014 at 01:34 PM

    What is RfcLookupHandler? And where is RFC channel settings?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.