cancel
Showing results for 
Search instead for 
Did you mean: 

XI custom lookup function in mapping - error

hashtag_siva
Explorer
0 Kudos

Hi,

I created custom function to do RFC lookup with ECC. We are on PI 7 with service pack level 14. The custom function takes value of 4 attributes from source and does RFC call to do lookup.

The below is the import of classes I used in the function

javax.xml.parsers.DocumentBuilder;java.io.*;

org.xml.sax.*;

javax.xml.transform.dom.DOMSource;

javax.xml.parsers.*;

org.w3c.dom.*;

com.sap.aii.mappingtool.tf3.rt.ResultList;

com.sap.aii.mapping.*;

com.sap.aii.mapping.lookup.*;

com.sap.aii.mapping.lookup.Payload;

javax.xml.transform.stream.StreamResult;

javax.xml.transform.*;

in the code I put warning trace as below -

trace.addWarning("INSIDE");

//determine the communication channel

Channel channel = LookupService.getChannel("DE1CLNT301", "RFC_O_FPATH" );

trace.addWarning("CHANNEL LOOKUP DONE");

//get RFC Accessor for the channel

accessor = LookupService.getRfcAccessor(channel);

trace.addWarning("ACESSOR LOOKUP DONE");

when I test run I get the below error:

Compilation of MM_O_MQ_I_SAP successful

INSIDE

CHANNEL LOOKUP DONE

Errorjava.lang.StringIndexOutOfBoundsException: String index out of range: -1

Can anyone help?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

hashtag_siva
Explorer
0 Kudos

I checked the integration builder (configuration) and the communication channel created as RFC Adapter type (reciever channel) was properly attached to the Service.

Can I please know how to change the log messages.

I am testing mapping when this error occured. After changing the log trace messages in the code, the trace shows like:

INSIDE

CHANNEL LOOKUP DONE RFC_O_FPATH (Party: , Service: DE1CLNT301, Object ID: f9f592e7e0b3316480afcaa8d462a140)

BEFORE ACCESSOR GET CHANNEL

Errorjava.lang.StringIndexOutOfBoundsException: String index out of range: -1

I added a constant function and passing the service name and channel name to my custom function. The changed code is

try

{

trace.addWarning("INSIDE");

//determine the communication channel

Channel channel = LookupService.getChannel(businessPartner, communicationChannel );

trace.addWarning("CHANNEL LOOKUP DONE "+ channel);

//get RFC Accessor for the channel

trace.addWarning("BEFORE ACCESSOR GET CHANNEL");

RfcAccessor accessor = LookupService.getRfcAccessor( channel );

trace.addWarning("ACCESSOR GET CHANNEL DONE");

Edited by: developer on Jun 27, 2008 12:42 AM

Former Member
0 Kudos

Hi,

Is there any other properties in RFC Chanel which you have set or can you let me know the parameters you have set for your RFC Channel? Is it an Receiver RFC Channel?

Thanks

Amit

hashtag_siva
Explorer
0 Kudos

The communication channel was created as reciever and adatper was RFC. I gave the following parameters

RFC server type = SAP system

application server = our ecc system address

system number = 01

authentication mode = use logon data for SAP system

logon use = rfc user created in ECC

password = password of rfc user

languge = en

client = ecc client

maximum connections = 1

Former Member
0 Kudos

Hi,

First test a simple File to RFC scenario using the same RFC Adapter and see if the connection is able to establish using the RFC channel. It might be possible that there is some communication problem while connecting to SAP System.

As per the Lookup aapi there it can either throw nullpointerexception or lookupexception. YOu need to debug more.

Pls have try catch block and do printStackTrace(); or getMessage() and see where the exception is exactly being thrown from.

Thanks

Amit

former_member190389
Active Contributor
0 Kudos

Could you post the source and target structure?

The error might be in that...

In order to test whether the RFC lookup is proper. do this

1. create an RFC in R3 with single string parameter in both import and export.

2. asign the import parameter to the export parameter in source code of RFC

3. save and activate

4.import this RFC in PI

5. in Interface mapping test your mapping.

6. if that works perfectly then the structure you are using is having something that stops rfc from executing.

Edited by: Progirl Progirl on Jun 27, 2008 6:15 AM

hashtag_siva
Explorer
0 Kudos

Amit,

I put the below code

catch (Exception e)

{

trace.addWarning("Error" + e);

e.printStackTrace();

e.getMessage();

}

the trace shows

INSIDE

CHANNEL LOOKUP DONE RFC_O_FPATH (Party: , Service: DE1CLNT301, Object ID: f9f592e7e0b3316480afcaa8d462a140)

BEFORE ACCESSOR GET CHANNEL

Errorjava.lang.StringIndexOutOfBoundsException: String index out of range: -1

Edited by: developer on Jun 27, 2008 6:49 AM

Former Member
0 Kudos

Hi,

I wanted to see the whole stack from where the error is coming. Can you please change the code as I am giving below and let me know the result. Let the rest code be as it is.

try

{

trace.addWarning("BEFORE ACCESSOR GET CHANNEL");

RfcAccessor accessor = LookupService.getRfcAccessor( channel );

}catch (Exception e)

{

StackTraceElement[] stack= e.getStackTrace();

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

{

StackTraceElement stackTrace = stack<i>;

trace.addWarning("Exception is at : "+stackTrace.toString());

}

}

trace.addWarning("ACCESSOR GET CHANNEL DONE");

Thanks

Amit

Former Member
0 Kudos

Hi,

One quick question the same? Have you used this channel in any of the Receiver Agreement. If so please remove it and try.

Thanks

Amit

hashtag_siva
Explorer
0 Kudos

I put changed the code as below. I have not used this RFC channel anywhere in reciever agreement

String returnValue = null;

String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZRFC_VALUE_TABLE_READ" + "xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_DIRECTION>" + CBOUND + "</I_DIRECTION><I_RECIEVER_ID>" + WF_RPARTID +"</I_RECIEVER_ID><I_SENDER_ID>" + WF_SPARTID +"</I_SENDER_ID><I_SEQNO>" +WF_SEQNO "</I_SEQNO><I_TRANS_TYPE>" WF_TRNTYP + "</I_TRANS_TYPE></ns0:ZRFC_XI_MQ_VALUE_TABLE_READ>";

AbstractTrace trace = container.getTrace();

ByteArrayOutputStream out = null;

RfcAccessor accessor = null;

try

{

trace.addWarning("INSIDE");

//determine the communication channel

Channel channel = LookupService.getChannel(businessPartner, communicationChannel );

trace.addWarning("CHANNEL LOOKUP DONE "+ channel);

//get RFC Accessor for the channel

try

{

trace.addWarning("BEFORE ACCESSOR GET CHANNEL");

accessor = LookupService.getRfcAccessor(channel);

}

catch (Exception e)

{

StackTraceElement[] stack= e.getStackTrace();

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

{

StackTraceElement stackTrace = stack;

trace.addWarning("Exception is at : "+stackTrace.toString());

}

}

trace.addWarning("ACCESSOR GET CHANNEL DONE");

//create XML input stream

InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());

trace.addWarning("INPUTSTREAM CREATED");

//create XML Payload

XmlPayload payLoad = LookupService.getXmlPayload(inputStream);

trace.addWarning("PAYLOAD XML ");

//execute lookup

Payload payloadResult = null;

payloadResult = accessor.call(payLoad);

trace.addWarning("PAYLOAD CALLED");

InputStream in = payloadResult.getContent();

trace.addWarning("PAYLOAD MOVED TO INPUTSTREAM");

//DOM structure for input XML

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

trace.addWarning("DOCUMENT BUILDER");

Document document = builder.parse(in);

trace.addWarning("DOCUMENT BUILDER PARSER");

NodeList list = document.getElementsByTagName("E_FILE");

Node node = list.item(0);

if ( node != null )

{

node = node.getFirstChild();

if ( node != null )

{

returnValue = node.getNodeValue();

}

}

//free resources

if ( accessor != null )

{

try

{

accessor.close();

}

catch (LookupException e)

{

trace.addWarning("Error while closing accessor" + e.getMessage() );

}

}

}

catch (Exception e)

{

trace.addWarning("Error" + e);

}

return returnValue;

but i get error when activating

/classpath_resolver/Mapb7663d60447b11ddb1d700101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:102: incompatible types found : java.lang.StackTraceElement[] required: java.lang.StackTraceElement StackTraceElement stackTrace = stack;

Edited by: developer on Jun 27, 2008 9:05 PM

Former Member
0 Kudos

Hi,

I am not sure how but there was just one thing got missed in the code which I sent. Please modify accordingly and let me know the result.

It should be :

StackTraceElement stackTrace = stack<i>;

Thanks

Amit

Former Member
0 Kudos

Hi,

Surprisingly it got removed again, After I Post Message, this gets removed automatically. ok do like this

StackTraceElement stackTrace = stack [ i ] ;

Hope you understood what I mean to say.remove all the spaces between stack and rectangle brackets

the code should be stack followed by rectangular open braces , than i and close rectangular braces.

Thanks

Amit

Edited by: Amit Gupta on Jun 27, 2008 9:16 PM

Former Member
0 Kudos

Hi,

Did you tried that ? Is it working now?

Amit

hashtag_siva
Explorer
0 Kudos

Amit,

As it is not working, I changed it to use integration scenario. when I test using RWB, I get below error

<SAP:Category>XIAdapter</SAP:Category>

<SAP:Code area="BPE_ADAPTER">SYNCHONOUS_MESSAGE</SAP:Code>

<SAP:P1 />

<SAP:P2 />

<SAP:P3 />

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>The process does not support the given synchronous interface or does not support synchronous messages Exception CX_WAPI_DEF_PROPERTY_NOT_FOUND occurred (program: SAPMHTTP, include: , line: 0).</SAP:Stack>

<SAP:Retry>N</SAP:Retry>

Former Member
0 Kudos

Hi,

Looks like there is some problem in your RFC Channel while communicating with SAP System. As I asked you please try a simple File to RFC scenario and see if your RFC channel is able to communicate with SAP System properly.

You can please try the above code as well. It will work now.

Also change the trace level to 1 by going to tcode sxmb_adm so that you can see some more error messages.

Thanks

Amit

Reward points if answer is useful

Edited by: Amit Gupta on Jun 28, 2008 12:13 AM

hashtag_siva
Explorer
0 Kudos

I changed the code to

try

{

trace.addWarning("INSIDE");

//determine the communication channel

Channel channel = LookupService.getChannel(businessPartner, communicationChannel );

trace.addWarning("CHANNEL LOOKUP DONE "+ channel);

//get RFC Accessor for the channel

try

{

trace.addWarning("BEFORE ACCESSOR GET CHANNEL");

accessor = LookupService.getRfcAccessor(channel);

}

catch (Exception e)

{

StackTraceElement stack= e.getStackTrace();

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

{

StackTraceElement stackTrace = stack;

trace.addWarning("Exception is at : "+stackTrace.toString());

}

}

trace.addWarning("ACCESSOR GET CHANNEL DONE");

//create XML input stream

InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());

trace.addWarning("INPUTSTREAM CREATED");

//create XML Payload

XmlPayload payLoad = LookupService.getXmlPayload(inputStream);

trace.addWarning("PAYLOAD XML ");

//execute lookup

Payload payloadResult = null;

payloadResult = accessor.call(payLoad);

trace.addWarning("PAYLOAD CALLED");

InputStream in = payloadResult.getContent();

trace.addWarning("PAYLOAD MOVED TO INPUTSTREAM");

//DOM structure for input XML

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

trace.addWarning("DOCUMENT BUILDER");

Document document = builder.parse(in);

trace.addWarning("DOCUMENT BUILDER PARSER");

NodeList list = document.getElementsByTagName("E_FILE");

Node node = list.item(0);

if ( node != null )

{

node = node.getFirstChild();

if ( node != null )

{

returnValue = node.getNodeValue();

}

}

//free resources

if ( accessor != null )

{

try

{

accessor.close();

}

catch (LookupException e)

{

trace.addWarning("Error while closing accessor" + e.getMessage() );

}

}

}

catch (Exception e)

{

trace.addWarning("Error" + e);

}

return returnValue;

but i still get error

classpath_resolver/Mapf3807f80449a11dd8b1400101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:99: incompatible types found : java.lang.StackTraceElement[] required: java.lang.StackTraceElement StackTraceElement stack= e.getStackTrace();

classpath_resolver/Mapf3807f80449a11dd8b1400101816a382/source/com/sap/xi/tf/_MM_O_MQ_I_SAP_.java:100: cannot resolve symbol symbol : variable length location: class java.lang.StackTraceElement for(int i=0;i<stack.length;i++)

Former Member
0 Kudos

Hi,

See there are some regtangular braces which are not displayed when i paste the code here. Now you should be able to see those.



StackTraceElement[] stack= e.getStackTrace();
for(int i=0;i<stack.length;i++)
{
StackTraceElement stackTrace = stack<i>;
trace.addWarning("Exception is at : "+stackTrace.toString());
}
}

Thanks

Amit

hashtag_siva
Explorer
0 Kudos

Thanks Amit. It worked. below is the trace error

CHANNEL LOOKUP DONE RFC_O_FPATH (Party: , Service: DE1CLNT301, Object ID: f9f592e7e0b3316480afcaa8d462a140)

BEFORE ACCESSOR GET CHANNEL

Exception is at : java.lang.String.substring(String.java:1444)

Exception is at : com.sap.aii.utilxi.hmi.api.HmiHttpClientImpl.extractCookieValue(HmiHttpClientImpl.java:318)

Exception is at : com.sap.aii.utilxi.hmi.api.HmiHttpClientImpl.extractCookie(HmiHttpClientImpl.java:307)

Exception is at : com.sap.aii.utilxi.hmi.api.HmiHttpClientImpl.getCookies(HmiHttpClientImpl.java:292)

Exception is at : com.sap.aii.utilxi.hmi.api.HmiHttpClientImpl.sendRequestAndReceiveResponseViaHttp(HmiHttpClientImpl.java:207)

Exception is at : com.sap.aii.utilxi.hmi.api.HmiHttpClientImpl.sendRequestAndReceiveResponse(HmiHttpClientImpl.java:108)

Exception is at : com.sap.aii.utilxi.hmi.api.HmiClientAdapter.invokeMethod(HmiClientAdapter.java:88)

Exception is at : com.sap.aii.ibrep.server.lookup.SystemAccessorHmiClient.<init>(SystemAccessorHmiClient.java:64)

Exception is at : com.sap.aii.ibrep.server.lookup.SystemAccessorHmiClient.getInstance(SystemAccessorHmiClient.java:112)

Exception is at : com.sap.aii.ibrep.server.lookup.LookupServiceProvider$RemoteClientDelegator.<init>(LookupServiceProvider.java:99)

Exception is at : com.sap.aii.ibrep.server.lookup.LookupServiceProvider$RemoteClientDelegator.<init>(LookupServiceProvider.java:89)

Exception is at : com.sap.aii.ibrep.server.lookup.LookupServiceProvider$RemoteClient.getSystemAccessor(LookupServiceProvider.java:76)

Exception is at : com.sap.aii.mapping.lookup.LookupService.getRfcAccessor(LookupService.java:249)

Exception is at : com.sap.xi.tf._MM_O_MQ_I_SAP_.RFC_GET_FILE$(_MM_O_MQ_I_SAP_.java:95)

Exception is at : sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Exception is at : sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

Exception is at : sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

Exception is at : java.lang.reflect.Method.invoke(Method.java:324)

Exception is at : com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.calculateCurrentValue(FunctionWrapper.java:76)

Exception is at : com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.cacheValue(FunctionWrapper.java:60)

Exception is at : com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.gotoNextContext(FunctionWrapper.java:40)

Exception is at : com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:266)

Exception is at : com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:326)

Exception is at : com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:415)

Exception is at : com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142)

Exception is at : com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:118)

Exception is at : com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431)

Exception is at : com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169)

Exception is at : com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52)

Exception is at : com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301)

Exception is at : com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146)

Exception is at : com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:319)

Exception is at : com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:200)

Exception is at : com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:136)

Exception is at : com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

Exception is at : com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

Exception is at : com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

Exception is at : java.security.AccessController.doPrivileged(Native Method)

Exception is at : com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)

Exception is at : com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)

ACCESSOR GET CHANNEL DONE

INPUTSTREAM CREATED

PAYLOAD XML

Errorjava.lang.NullPointerException

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi,

Any luck on the same, did it worked?

Thanks

Amit

hashtag_siva
Explorer
0 Kudos

It worked. Thanks Amit.

Former Member
0 Kudos

Hi,

Can you let me know what exactly you did to make it worked apart from rectifying the structure?

thanks

amit

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Sridevi,

you made my day thank you so much for your quick response. Will get this fix in place straight away.

Dieter

Former Member
0 Kudos

Hello All,

The fix is released now in patch 6 of XI TOOLS 7.00 SP14 and XI TOOLS 3.0 SP 20 Patch #9.

Please refer the Note : 1163293

With Regards,

Sridevi A S

Former Member
0 Kudos

Hi there,

does anybody know whether there is a fix available now for this in SP14.

Thanks. Dieter

Former Member
0 Kudos

Hello,

This is the bug introduced in one of the recent patches of SP14 (7.0) and SP22(3.0) .

This is being fixed now hope soon it will be released soon.

I will update here the note once its released.

Thanks,

Sridevi A S

Former Member
0 Kudos

Hi Sridevi,

From where you found it it is bug? Can you please give me some more info/link on the same.

thanks

amit

Former Member
0 Kudos

Hi,

Please make sure that you have given proper communication channel and Business system in getChannel method which exists. Check the name System name and make sure the channel exists inside that.

Also change the log messages you have added in order to make sure the latest class file is placed in the server.

I am pretty much sure the error is not coming form the lines of code you have mentioned, so please change the log messages and try again.

Thanks

amit

Reward points if suggestion helps