cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Error

Former Member
0 Kudos

Dear All,

I have the UDF error in the Message mapping it doesn't tranform the values finally mapping failing

Input values are

TYPE = E

MESSAGE = Order129602 and JobID28948 with Material000000000000000468 - Returned Quantity exceeds Shipment Quantity !!

UDF:

import com.sap.aii.mapping.api.*;

public void throwAlert(String[] type, String[] message, ResultList result, Container container) throws StreamTransformationException{

String outputStr = "";
Map map;
String filename = "";
MappingTrace importanttrace = null;

/*****  Concatenating all the error messages *****/
for ( int i = 0; i < type.length; i++ )
{
if (type[i].equals("E")){
  outputStr = outputStr + "  " + message[i];
}
}

try{
map = container.getTransformationParameters();
importanttrace = container.getTrace();

// Get the Filename.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
filename = conf.get(key);

createAlertMessage.throwAlert(": Shipped Tool List  Execution Error",outputStr,filename,map,"TCTP001A3_STL_001");
}
catch(Exception e){
  importanttrace.addWarning("Error In UDF throwAlert " + e.getMessage() );
  throw new RuntimeException(" Runtime Exception thrown",e);
//  System.out.println(e.getMessage());
//   throw new RuntimeException(" Error Occured In UDF",e);
}
result.addValue("");

}

Could you please suggest me where it was wrong?

Thank you.
Sateesh

Accepted Solutions (0)

Answers (3)

Answers (3)

ambrish_mishra
Active Contributor
0 Kudos

Hi Sateesh,

I don't see a problem with the code other than the definition of class for createAlertMessage. I assume it is an object handler. How you imported the relevant classes in the UDF?

Does this code compile?

In debug trace, where do you see the code execution failing ?

Hope it helps!

Ambrish

Harish
Active Contributor
0 Kudos

Hi Satish,

Adding to the Indrajit suggestion please also check length of message[i] in below loop.

for ( int i = 0; i < type.length; i++ )

{

if (type[i].equals("E")){

  outputStr = outputStr + "  " + message[i];

}

Regards,

Harish

Former Member
0 Kudos

Hi Sateesh

In your udf I can see this line

createAlertMessage.throwAlert(": Shipped Tool List  Execution Error",outputStr,filename,map,"TCTP001A3_STL_001");

where is the defination of the function createAlertMessage ??

Also change the line

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

Remove the space infront of container.

Also remove the line

throw new RuntimeException(" Runtime Exception thrown",e);