cancel
Showing results for 
Search instead for 
Did you mean: 

To Create UDF for simple Graphical mapping.

former_member205100
Participant
0 Kudos

Hello All,

I would like to create an UDF copying an existing one used in another scenario and here is the code below.

This is used in simple graphical mapping.

' public String getMessageID(String a,Container container){

' //write your code here

// get runtime constant map

java.util.Map param = container.getTransformationParameters();

// get value of Message ID by using variable key

String MSGID = (String) param.get (StreamTransformationConstants.MESSAGE_ID);

return MSGID;

when i saved and activated i get the error as below.

Erro :

Source code has syntax error: /usr/sap/FXM/DVEBMGS33/j2ee/cluster/server0/./temp/classpath_resolver/Map919129ac273b11e1b2cc5611b8cdd010/source/com/sap/xi/tf/_MM_I1003_Shipment_SAP_TO_WMQ_.java:4914: cannot return a value from method whose result type is void return MSGID; ^ 1 error

since i dont know the JAVA, can any one guide on this?

1. shoud we need to declare anything globally?

2,or any JAVA program need to create and import ?

Regards,

Sethu.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

u cant test this UDF in message mapping..this will only output the message id when u do end to end testing

choose execution type as: single value and use below code:



String constant;
java.util.Map map;
map = container.getTransformationParameters();
constant = (String) map.get(StreamTransformationConstants.MESSAGE_ID); 
return constant;

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1321

Former Member
0 Kudos

a litle complement... you CAN test it in Message Mapping...

but for that, you have to go in tab "Parameters" of tab "Test", and to write something (e.g 1234) in the parameter called "MessageId"

Your UdF tested locally in MM will them pick this info (e.g 1234) and return it to you.

Tips: when we want get info from SOAP header, it's better to use a TRY...CATCH to wrap the java function. by this way when test the mapping target field (display queue), we have not a dump !

Mickael

Former Member
0 Kudos

>>you CAN test it in Message Mapping

Indeed, but u wont get the actual message id..and this is what i meant


this will only output the message id when u do end to end testing

Former Member
0 Kudos

of course AmitSri ))

Answers (4)

Answers (4)

former_member205100
Participant
0 Kudos

Yes the logic worked.

Ryan-Crosby
Active Contributor
0 Kudos

Hi Sethu,

The problem is with the method signature of your UDF. If you look at the error message it indicates that your UDF has a void return type, but you have a return type of String. You need to change the method signature so that the UDF is expecting to return a String and then you should be able to activate your code successfully.


' public String getMessageID(String a,Container container){
' //write your code here
// get runtime constant map
java.util.Map param = container.getTransformationParameters();
// get value of Message ID by using variable key
String MSGID = (String) param.get (StreamTransformationConstants.MESSAGE_ID);
return MSGID;

Regards,

Ryan Crosby

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,


public String getMessageID(String a,Container container){
//write your code here
// get runtime constant map
java.util.Map param = container.getTransformationParameters();
// get value of Message ID by using variable key
String MSGID = (String) param.get (StreamTransformationConstants.MESSAGE_ID);
return MSGID;

cannot return a value from method whose result type is void return MSGID

Your code looks okay. But are you sure that the UDF execution type is set to Single Values and not Context or Queue Type?

Hope this helps,

Mark

Former Member
0 Kudos

Hi,

The possibility depends on your requirement.

If you give us the source and target message that you want to achieve we can decide whether you need UDF or Java Mapping

ok

regards

Ramesh