cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Connectivity in Netweaver developer studio...

david_fryda2
Participant
0 Kudos

Hi everyone,

I am trying to use the feature of "SAP connectivity" in the NDS.

I created a proxy for a simple RFC.

What I am trying to do is to call the RFC from a Java code.

Here is what I wrote :

try {

Z_Rfc_Ws_Test2_Input input = new Z_Rfc_Ws_Test2_Input();

input.setInput("Salut la compagnie");

SAPProxy_PortType proxy = new SAPProxy_PortType();

Z_Rfc_Ws_Test2_Output output = proxy.z_Rfc_Ws_Test2(input);

} catch (Exception e) {

e.printStackTrace();

}

I get an exception because I didn't specify the username and its credentials. Of course, I have to specify the server and the client number.

Here is the exception :

com.sap.aii.proxy.framework.core.BaseProxyException: JCoClient connection missing

at com.sap.aii.proxy.framework.core.AbstractProxy.send$(AbstractProxy.java:150)

at com.proxy.SAPProxy_PortType.z_Rfc_Ws_Test2(SAPProxy_PortType.java:16)

at Client.main(Client.java:45)

Can someone help with this issue ?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You first have to create a JCO client:

//create client

JCO.Client client = JCO.createClient("client", "username", "password", "language", "server", "sysnr");

//connect to the SAP system

client.connect();

Then your code to create the Input object.

Z_Rfc_Ws_Test2_Input input = new Z_Rfc_Ws_Test2_Input();

input.setInput("Salut la compagnie");

SAPProxy_PortType proxy = new SAPProxy_PortType();

Next you have to pass the cieltn to the proxy class:

proxy.messageSpecifier.setJCOClient(client);

Now you can get the output using your own code:

Z_Rfc_Ws_Test2_Output output = proxy.z_Rfc_Ws_Test2(input);

And finally close the client if you're done:

client.disconnect();

Now you can write some code to display the results.

Answers (3)

Answers (3)

guru_subramanianb
Active Contributor
0 Kudos

Also I fotget to mention that after getting connection place your code which calls the BAPI/RFC in another try block and finally close your connection.

Hope it has helped you.

Regards,

Guru

Former Member
0 Kudos

I think you are missing this (see my previous post):

Next you have to pass the client to the proxy class:

proxy.messageSpecifier.setJCOClient(client);

david_fryda2
Participant
0 Kudos

Hi Peter,

Thanks it works.

You are right : I miss your post...sorry.

It works as good as with C# or VB.NET.

Thanks to everyone that helped me.

Nice day.

guru_subramanianb
Active Contributor
0 Kudos

Hi David,

In your below code the JCO configurations is missing I mean ur JCO client. Try some thing like this which is self explanatory.

(ur package name here if u have any)

import com.sap.mw.jco.*;

public class Jco {

public static void main(String[] args) {

// Necessary fields for Connection

JCO.Client myConnection = null;

JCO.Repository myRepository = null;

JCO.Function myFunction = null;

JCO.Field myHostName = null;

// Establishing a connection

try{

// Defining the connection parameters

myConnection = JCO.createClient("Client","User","Password","Lang","ServerIP","Sys Number");

myConnection.connect();

// Creating a repository

myRepository = new JCO.Repository(attribute,myConnection);

}catch(Exception e){

System.out.println(e.toString());

System.exit(1);

}

// Finally closing the connection

finally{

myConnection.disconnect();

}

}

}

david_fryda2
Participant
0 Kudos

Hi Guru,

I tried it but I get the exact same exception.

I know that in .Net I create a Proxy and a Destination class.

In the Destination class, I define all the user and server parameters. After, I pass the Destination class to the Proxy.

I think that we must do the same thing : how to pass the JCO connection to the proxy ?

Thanks.