jco java_JCO Connection

JCO CONNECTION.

First of all, let me explain what is a JCO connection?

The JCO Connection or the SAP Java Connector is a middleware component that allows a JAVA application to call or communicate to any SAP systems and vice versa..

There are 2 types of calls that can be made to the SAP Server by the Sap JCO, They are

1)Inbound calls (Java calls ABAP)

2)Outbound calls (ABAP calls Java).

By using a JCO connection, one can call an RFC from the R/3.

It contains 2 .dll files. These are the 2 .dll files that help in calling an RFC.

A JCO connection to an R/3 system is represented by the JCO.Client Class. This class abstracts all functionalities that surround a connection.

First of all you need to import the JCO libraries into your class(es):

import com.sap.mw.jco.*;

The JCO class offers a static method that enables you to create a JCO.Client object

JCO.Client mConnection = CO.createClient("001", // SAP client

"", // userid

"****", // password

"EN", // language (null for the default language)

"", // application server host name

"XX"); // system number

Note: The userid, password etc can be hardcoded or you can create a .properties file and  use that particular file. Although its always recommended not to hardcode values.

After the client instance has been created, the connect() method has to be called and then only a connection will be established.

mConnection.connect();   //THe Function modules can be called here }

mConnection.disconnect(); //After the Function module has been executed, the connection has to be closed

JCO.Repository

The JCO.Repository's purpose is to store all meta data of function modules.

This is how a JCO.Repository is created.

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

Once this is created, do not think that it already contains the meta data. To read any meta data, the method getFunctionTemplate("Name of RMF") has to be called. This can  be called as given below.

IFunctionTemplate functionTemplate =mRepository.getFunctionTemplate("Name of RMF");

What does the method getFunctionTemplate() do?

The method getFunctionTemplate() returns an instance of IFunctionTemplate that contains all meta data of a remote function module. You can use this object to create an instance of a JCO.Function.

So now the connection has been done and the RFM has been called.

The next step is, how to get the RFM's table or the export data or if you are importing any data.

This can be achieved by the using the following functions as given below:

1)getExportParameterList() for getting the export parameters

2) getTableParameterList() for getting the table parameters

3)getImportParameterList() for getting the import parameters

You will use the above functions as per your requirement.

1) getTableParameterList()

JCO.Table ztable = function.getTableParameterList().getTable("MY_TABLE");

ztable.appendRow();

ztable.setValue("val1", "VALUE1");

ztable.setValue("val2", "VALUE2");

2)getExportParameterList()

String temp = new String();

temp = function.getExportParameterList().getString( "variable holding exported value" );

3)*getImportParameterList()*String myImportValue = "someValue";

function.getImportParameterList().

setValue(importedvalue, "IMPORTED_VALUE");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值