cancel
Showing results for 
Search instead for 
Did you mean: 

create JCO Client in JSP

Former Member
0 Kudos
196

Hi all,

I have the following problem: How I can create the JCOClient in the JSP? In the AbstractPortalContent I use this code

IJCOClientService clientService = (IJCOClientService request.getService("jcoclient");

IJCOClientPoolEntry poolEntry;

try

{

poolEntry = clientService.getJCOClientPoolEntry("SAP_cFolders", request);

}catch (Exception e)

{

response.write("Error obtaining connection: " + e);

return;

}

JCO.Client client = null;

client = poolEntry.getJCOClient();

client.connect();

In the JSP I don't able to create the JCO.Client.

Someone can help me?

Thanks in advance,

Stefano

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

I am giving u the sample code of the application which i had done in Abstract portal component u try this for establishing JCO connection

hope this helps...

public class calingrfc extends AbstractPortalComponent

{

private JCO.Client jcoClient;

Rfccaling_PortType insFunc = new Rfccaling_PortType();

Ztrng_Show_Input ip = new Ztrng_Show_Input();

Ztrng_Show_Output op = new Ztrng_Show_Output();

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

//

// try {

// this.connect();

// insFunc.messageSpecifier.setJcoClient(jcoClient );

// String temp = request .getParameter("text1");

// ip.setTrainingid1(temp);

//

//} catch (RuntimeException e) {

// // TODO Auto-generated catch block

// e.printStackTrace();

//}

//

// }

// private void connect() {

// try {

// jcoClient =

// JCO.createClient("700","developer","satyam","EN","sap02","01");

// jcoClient.connect();

//

// } catch (Exception e) {

// System.out.println("Error connecting to SAP ::" + e.getMessage());

// e.printStackTrace();

// }

// }

// private void disconnect() {

// try {

// jcoClient.disconnect();

//

// } catch (Exception e) {

// System.out.println(

// "Error dis-connecting to SAP ::" + e.getMessage());

// e.printStackTrace();

// }

// }

}

Former Member
0 Kudos

Hi Vinod, thank you for your reply; it's very helpfull but how I can create the JCO client without passing the connection parameter(userID, password, SID...)? My problem consists of get information parameter of user connected to the portal. It's possible to get parameter connection from the poolManager in the JSP?

Thanks in advance,

Stefano

Former Member
0 Kudos

Hi Stefano,

You will have to pass the connection parameters. How ever you can get the logged in user id dynamically using the following method

portalRequest.getUser().getUserId().

If you have configued SSO between Portal and R/3, no need of passing the password it can be empty.

Also the best way of doing it would be that you keep all the connection parameters in IView properties file and pick it up from there.

Regards,

Vivek

Answers (1)

Answers (1)

Former Member
0 Kudos

Avoid JCOClient for EP6 and above. JCA is the recommended way to connect to SAP.