cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP to Java - JCo error

Former Member
0 Kudos

I followed all the instructions in Gregor's blog: /people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection

This is based on the Example5.java that comes bundled with JCo software. I was able to start the server, I was able to successfully test my RFC destination, but when I actually run by ABAP program the return error is:

JCO.Server could not find server function 'JCOSERVER01'

I am running the java code on my local machine on eclipse. And in the console this is what I get after the call from the ABAP program:

Server JCOSERVER01 changed state from [ STOPPED ] to [ STARTED ]

Server JCOSERVER02 changed state from [ STOPPED ] to [ STARTED ]

Server JCOSERVER02 changed state from [ STARTED ] to [ STARTED LISTENING ]

Server JCOSERVER01 changed state from [ STARTED ] to [ STARTED LISTENING ]

Server JCOSERVER01 changed state from [ STARTED LISTENING ] to [ STARTED LISTENING BUSY ]

Exception in server JCOSERVER01:

com.sap.mw.jco.JCO$Exception: (120) JCO_: JCO.Server could not find server function 'JCOSERVER01'

com.sap.mw.jco.JCO$Exception: (120) JCO_: JCO.Server could not find server function 'JCOSERVER01'

at com.sap.mw.jco.rfc.MiddlewareRFC$Server.nativeListen(Native Method)

at com.sap.mw.jco.rfc.MiddlewareRFC$Server.listen(MiddlewareRFC.java:1395)

at com.sap.mw.jco.JCO$Server.listen(JCO.java:7067)

at com.sap.mw.jco.JCO$Server.run(JCO.java:6996)

at java.lang.Thread.run(Thread.java:534)

Server JCOSERVER01 changed state from [ STARTED LISTENING BUSY ] to [ STARTED LISTENING ]

Server JCOSERVER01 changed state from [ STARTED LISTENING ] to [ STARTED ]

Server JCOSERVER01 changed state from [ STARTED ] to [ STOPPED ]

Server JCOSERVER01 changed state from [ STOPPED ] to [ STARTED ]

Server JCOSERVER01 changed state from [ STARTED ] to [ STARTED LISTENING ]

Server JCOSERVER01 changed state from [ STARTED LISTENING ] to [ STARTED LISTENING BUSY ]

Pls help!

Thanks in adv

gs

Accepted Solutions (1)

Accepted Solutions (1)

prashil
Advisor
Advisor
0 Kudos

Hi,

Have you tested the connection using TEST program that is posted in the blog.

Is it giving the desired result?

Regards,

Prashil

Former Member
0 Kudos

Hi Prashil,

I am getting the error when I am testing using the test program from the blog.

Here it is:

***********************************************************

***********************************************************

DATA: REQUTEXT LIKE SY-LISEL,

RESPTEXT LIKE SY-LISEL,

ECHOTEXT LIKE SY-LISEL.

DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.

DATA: RFC_MESS(128).

REQUTEXT = 'HELLO WORLD'.

RFCDEST = 'Z_TEST_ABAP_TO_JCO'. "corresponds to the destination name defined in the SM59

CALL FUNCTION 'JCOSERVER01'

DESTINATION RFCDEST

EXPORTING

REQUTEXT = REQUTEXT

IMPORTING

RESPTEXT = RESPTEXT

ECHOTEXT = ECHOTEXT

EXCEPTIONS

SYSTEM_FAILURE = 1 MESSAGE RFC_MESS

COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.

IF SY-SUBRC NE 0.

WRITE: / 'Call STFC_CONNECTION SY-SUBRC = ', SY-SUBRC.

WRITE: / RFC_MESS.

ENDIF.

***********************************************************

***********************************************************

Also I have created and successfully tested the RFC destination: "Z_TEST_ABAP_TO_JCO" with the program id: "JCOSERVER01".

And "JCOSERVER01" is the name of one of the two servers started in the java program Example5.java.

Thanks

gs

0 Kudos

OK... but JCOSERVER01 it's the name of server, not the function.

In Example5,java check this:

repository = new Repository("TestRepository");

//------------------------------------------------------------------------------
//  Add function 'STFC_CONNECTION'
//------------------------------------------------------------------------------
JCO.MetaData fmeta = new JCO.MetaData("STFC_CONNECTION");
		fmeta.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255,   0,     0,       JCO.IMPORT_PARAMETER, null);
		fmeta.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255,   0,     0,       JCO.EXPORT_PARAMETER, null);
		fmeta.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255,   0,     0,       JCO.EXPORT_PARAMETER, null);
		repository.addFunctionInterfaceToCache(fmeta);

Remplace CALL FUNCTION 'JCOSERVER01' with CALL FUNCTION 'STFC_CONNECTION' and try again

Former Member
0 Kudos

Thanks Juda,

That fixed my problem. I had initially not got the complete picture with the Repository metadata, but now I do.

I have awarded the points.

Regards

gs

Message was edited by:

geserv 1

Answers (1)

Answers (1)

0 Kudos

Hi,

Example5.java set a JAVA program like server, this allow call functions in java from an ABAP program.

In SAP, an equivalent conection called JCOSERVER01 must exist. Check the transaction sm59 and make this conection.

If you need test access to SAP from a JAVA program, do it with demo program: TutorialBapi1.java

Former Member
0 Kudos

Seems like TutorialBapi1.java is not for ABAP to java but the other way round, java to ABAP.

Rgd

gs