cancel
Showing results for 
Search instead for 
Did you mean: 

How to use JCO and RFC

Former Member
0 Kudos

Hi guys, please help me out

I'm new to JCO and do not have any idea about it.

Here is my situation, for testing, I want to call an ABP RFC FM in SAP just to return a single text message to Java application through parameter.

(Of course, I have access to SAP from my company and I do not have any Java compiler in my computer).

From my understanding, there 2 main things to concern (Please correct me if i'm wrong and please tell me the steps I should do)

1) Software installation and configuration

What software do I need to install on my computer, is

it JCO, SAPGUI, Java Compiler? What kind of

configurations do I need for JCO?

2) Programming

a) SAP side

Write an ABAP RFC FM just to return a text message

to Java application through parameters (No problem

with this step)

b) My computer side

Write a Java application to call ABP RFC FM

Do you guys have any simple source code example for

this?? Please remember that this Java application

simply call an ABAP RFC FM to get just a single

text message.

I really appreciate your help

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dean,

Please check this link :

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/frameset.htm">JCO documentation</a>

It has examples and answers what needs to be installed.

HTH

Peter

Former Member
0 Kudos

Dean,

regarding Java Resource Adapter (JRA) try to read this pdf:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933...

Hope this help you. Bye,

Vito

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Dean Thong That ,

If your question is answered, please close the thread and mark helpful answers.

Regards,

Tanveer.

Former Member
0 Kudos

Hi,

If you need further assistance, i will send you the necessary documentation. Give me your email id.

Regards,

Tanveer.

Please award points if found helpful.

Former Member
0 Kudos

Hi Dean,

USe Eclipse for Java programming.

If you are downloading the latest version of JCO, make sure you have latest version of SAP Gui as there are version issues as the librfc.dll needs to be of compatible version.

As far as your sample code is concerned, here it is ...

import com.sap.mw.jco.*;

public class CallFunction extends Object {

public static void main(String args[]) {

CallFunction app = new CallFunction();

}

int count;

JCO.Client mConnection;

JCO.Repository mRepository;

public CallFunction() {

try {

// Logon info

mConnection = JCO.createClient("500", // SAP client

"username", // userid

"password", // password

null, // language

"server name", // application server host name

"00"); // system number

mConnection.connect();

mRepository = new JCO.Repository("MY_connection", mConnection);

} catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

JCO.Function function = null;

try {

function = this.createFunction("ABAP_FM");

mConnection.execute(function);

System.out.println(

function.getTableParameterList().getValue("Exporting_Message"));

} catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

}

public JCO.Function createFunction(String name) throws Exception {

try {

IFunctionTemplate ft =

mRepository.getFunctionTemplate(name.toUpperCase());

if (ft == null)

return null;

return ft.getFunction();

} catch (Exception ex) {

throw new Exception("Problem retrieving JCO.Function object.");

}

}

}

Here in this mention ur function module in place of ABAP_FM and exporting parameter in place of Exporting_Message.

Regards,

Tanveer.

Please please reward some points if found helpful.

Former Member
0 Kudos

Thanks a lot Kishor

My case is to create a sample Java(Console application - java application with main) like you mentionned (I`m using Window 2000). I would like to confirm with you my undersdanding :

1) Download JCO from SAP service market place

I found it and already download version Sap JCo 2.1.6

I assume that sapjco.jar files and other DLL are with

the installation (If not then I have too look at OSS

note 549268)

2) Java installation

Info on JCO download from Service Market Place says

that SUN JDK 1.4.2 or later is needed. Is it the term

SUN JDK is same as the term JSDK you wrote???

3) Any kind of text editor e.q NotePad for example for

writing JAVA aaplication

I really appreciate it

Thank you for kindness

kishorg
Advisor
Advisor
0 Kudos

Hi Dean Thong That ,

for console applications,

<<1>>

u have to set class path to this sapjco.jar files before executing the applications . this classpath is required at design time also . for console applications , there is no need for NetWeaver Developer Studio(using this u can create standard GUI applications ). u can use any of the text editors for creating ur java files.

u have to copy that DLL files to the <Drive>:\Windows\System32 folder in windows. this is required at runtime .

<<2>>

right now u r not using Developer Studio , so i think u can use jdk1.3 or greater versions . SUN JDK1.4.2 (u r right ) thats what i mentioned.

Regards

Kishor Gopinathan

kishorg
Advisor
Advisor
0 Kudos

Hi Dean Thong That ,

JCO, a middleware for connecting SAP and Java applications.Hope u have general idea regarding JCO.

<<What software do I need to install on my computer, is

it JCO, SAPGUI, Java Compiler? What kind of

configurations do I need for JCO?

>>

The softwares have to install on ur computer depending upon the type of java application u r using for connection.

I) If u want to create a sample Java(Console application - java application with main) , then u need

a) Java installation(j2sdk or)

b) sapjco.jar file ( u have to download that from service market place)

c) DLL files ( 2 DLL files . that will we along with this download from service market place).

d) one editor - u can use notepad for java coding ...

II) If u want to use GUI applications like WebDynpro , Swing applications ,and JSP or other J2EE applications..

then u need.

a) Java installation(j2sdk or)

b)NetWeaver Derveloper Studio(trial version is available in SDN itself).

details of various GUI applications we can use for JCO , i have already explained in this forum.. please go through these

Some sample codes are discusses in these forums

Some basic issues are discussed here . u can use these forums when u stuck with some common issues.

Regards

Kishor Gopinathan