cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping error in UDF

Former Member
0 Kudos

I am receiving errors when trying to activate my MM. I believe the issues are in one of two UDF's. These UDF's do work in another MM without error. Below are the error's and UDF's.

ERRORS:

Activation of the change list canceled Check result for Message Mapping MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE | http://wawa.com/xi/erp/pos: Starting compilation Source code has syntax error: /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map5420e070cabe11dcab4b00306ef38da9/source/com/sap/xi/tf/_MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE_.java:3291: cannot resolve symbol symbol : variable container location: class com.sap.xi.tf._MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE_ map = container.getTransformationParameters(); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map5420e070cabe11dcab4b00306ef38da9/source/com/sap/xi/tf/_MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE_.java:3293: cannot return a value from method whose result type is void return constant; ^ 2 errors

UDF's:

public String getSender(Container container){

String constant;

java.util.Map map;

// get constant map

map = container.getTransformationParameters();

constant = (String) map.get (StreamTransformationConstants.SENDER_SERVICE);

return constant;

IMPORTS: com.sap.xi.mapping.parse.dom.;javax.xml.parsers.;java.io.;com.sap.aii.mapping.lookup.;org.w3c.dom.*;

public String getSeqNum(String fileType,String objNum,String Sender,Container container){

String request = "<ns0:ZRFC_NUMBER_GET_NEXT xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><NR_RANGE_NR>" + fileType + "</NR_RANGE_NR><OBJECT>" + objNum + "</OBJECT><QUANTITY/></ns0:ZRFC_NUMBER_GET_NEXT>";

InputStream isRequest = new ByteArrayInputStream(request.getBytes());

SystemAccessor accessor = null;

String num = null;

try{

// 1. Determine a channel.

Channel channel = LookupService.getChannel(Sender, "R_RFC_ERP");

// 2. Get a system accessor for the channel.

accessor = LookupService.getSystemAccessor(channel);

// 3. Create a payload according to the data type which the adapter expects.

// Use service.getBinaryPayload() for binary payload,

// and service.getTextPayload() for text payloads.

Payload payload = LookupService.getXmlPayload(isRequest);

// 4. Execute lookup.

Payload response = accessor.call(payload);

//Parse response

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

InputStream resStream = response.getContent();

Document doc = builder.parse(resStream);

Element sequence = doc.getDocumentElement();

NodeList number = sequence.getElementsByTagName("NUMBER");

//Extract Number

num = DOMUtil.getSimpleElementText((Element) number.item(0));

} catch (Exception e) {

return e.getMessage();

} finally {

try {

if (accessor != null) accessor.close();

} catch (Exception e) {

return e.getMessage();

}

}

GlobalContainer gc = container.getGlobalContainer();

gc.setParameter("Num", num);

return num;

Any help is appreciated.

Regards,

Darrell

Accepted Solutions (1)

Accepted Solutions (1)

Jitendra_Jeswan
Contributor
0 Kudos

hi

Answers (4)

Answers (4)

Former Member
0 Kudos

Check what kind of UDF you are using :simple/advanced ie Check whether it is Value/Context/Queue

If it is Context/queue,then the target element is populted using ResultList object.

Regards

Priyanka

stefan_grube
Active Contributor
0 Kudos

Check the import statements:

com.sap.xi.mapping.parse.dom.;javax.xml.parsers.;java.io.;com.sap.aii.mapping.lookup.;org.w3c.dom.*;

There are missing stars (*)

com.sap.xi.mapping.parse.dom.;javax.xml.parsers.;java.io.;com.sap.aii.mapping.lookup.;org.w3c.dom.*;

Former Member
0 Kudos

Hi,

Your first UDF seems to be ok but the error is thrown for it. You could try out following things:

1. Do compilation check on UDF 1. This would ensure if the error is thrown from this.

2. If the compilation check gives same error on statement return constant; then ensure that definition of UDF is correct i.e. it returns a string. Make sure that you have not created a UDF passing queue or context in cache. It should pass value, only then the return type would be string.

3. If none of above works, try restarting repository again.

Thanks,

Bhavish

Reward points if comments helpful

justin_santhanam
Active Contributor
0 Kudos

Darrell,

I can't see any errors with UDF-1.It seems to be perfect, even I copied and executed the same. Do one thing, just right click

on the UDF1 and use display queue, see whether it's throwing out the error. If there is no error then go to UDF-2 and check the same.

First we will figure it out which one causes the issue, then we proceed further.

raj.

Former Member
0 Kudos

The error happens when I display the queue for UDF-1. I checked the rest of the mapping to compare it to the other mapping where these UDF's are used. Everything else seems to be mapped correctly.

Regards,

Darrell

former_member214364
Active Contributor
0 Kudos

Hi Darrell,

Could you please check(character cases) map = container.getTransformationParameters(); statement in your UDF code and also check UDF Cache (i.e it should be Value ).

You would get these 2 errors because of above statement in UDF code and UDF Cache Type.

Cheers,

Jag

Former Member
0 Kudos

Fauver,

Just to narrow down the problem first remove the first udf and only use the 2nd user defined function. Also in the 2nd udf you have to change this line:

try{

// 1. Determine a channel.

Channel channel = LookupService.getChannel(Sender, "R_RFC_ERP");

In the above line instead of Sender you use the business service or business system where R_RFC_ERP RFC communication channel is created in Integration Directory. So you are hardcoding it first.

Once you have done this changes do save and test it once again. If this works then you can change back to original and your first udf needs to be checked.

Regards,

---Satish

Former Member
0 Kudos

Hi Jag,

I checked my Cache and it is set to Value. I'm not sure what you mean by checking the character cases. Can you please expand on that statement.

Thank you,

Darrell

former_member214364
Active Contributor
0 Kudos

Hi Darrell,

After changing Cache to Value how many errors you are getting i guess it should be one error.

As you know Java is case sensitive, So check

map = container.getTransformationParameters(); statement and other statements in UDF.

Thanks,

Jag