调用jco访问sap的rfc资料参考

上传人:宝路 文档编号:23516679 上传时间:2017-12-01 格式:DOC 页数:3 大小:32.77KB
返回 下载 相关 举报
调用jco访问sap的rfc资料参考_第1页
第1页 / 共3页
调用jco访问sap的rfc资料参考_第2页
第2页 / 共3页
调用jco访问sap的rfc资料参考_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《调用jco访问sap的rfc资料参考》由会员分享,可在线阅读,更多相关《调用jco访问sap的rfc资料参考(3页珍藏版)》请在金锄头文库上搜索。

1、调用 jco 访问 sap 的 rfc 资料参考2008-11-17 15:21之前没有约定传入参数,直接同 function.getTable()来实现,对某个 sap 表的结果抓取。由于数据量过大,协同增加了过滤参数的方案;现在该 rfc 已经增加了参数传入参数,访问 rfc 时,相应的代码也进行适当改动。主要是:由于传入参数为 table 型inParm = function.getTableParameterList();JCO.Table tableIn = inParm.getTable(DATA);/得到 SAP 函数中的表。 tableIn.appendRow();/添加一行t

2、ableIn.setValue(要放入的信息, RFC 字段名);tableIn.setValue(消防栓, QNAME);。/追加多条查询参数记录到表中function.setTableParameterList(inParm); /放入 rfc 中mConnection.execute(function);/执行配置好的 function参考文档:/=/0.调用 sapjco.jar 299296 个字节 292KB/=/import com.sap.mw.jco.JCO;import com.sap.mw.jco.IFunctionTemplate;/=/1.配置客户端链接 SAP cr

3、eateClient/=/端口号 /用户名/密码/语言/sap 服务器 ip/系统编号JCO.Client mConnection = JCO.createClient(800,user,pass,zh1,192.168.1.1,10);/mConnection = JCO.createClient(端口号,用户名,密码,语言,sap服务器 ip,系统编号);/=/2.创建客户端 mConnection.connect();/=/try mConnection.connect();catch (Exception ex)/* 用户名密码、端口号、IP 错误在此报错* 用户名密码错误报错信息:*

4、 com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: #.#,#* 端口号错误报错信息:* com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: # 502 #* IP 错误报错信息:* com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed*/System.out.println(创建 JCO 失败);return;/=/3.创建

5、SAP 仓库/=/JCO.Repository mRepository = new JCO.Repository(neusoft, mConnection);/=/4.从仓库中获得执行函数名的 函数模板/=/IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase();/name:大写的 RFC函数名if(ft=null)System.out.println(SAP_RFC 中没有此函数);else/=/5.从函数模板(IFunctionTemplate)中获得 function/=/JCO.Function

6、 function = ft.getFunction();/=/6.1 输入值是普通值/=/JCO.ParameterList inParm = function.getImportParameterList();inParm.setValue(要放入的信息, RFC 字段名);inParm.setValue(灭火器, MHQI);/如果是别了类型 setValue 方法支持很多输入值;例如浮点数录入: inParm.setValue(Double.parseDouble(1234.125), GWSL);/=/6.2 输入值是 Table/=/inParm = function.getTab

7、leParameterList();JCO.Table tableIn = inParm.getTable(DATA);/得到 SAP 函数中的表tableIn.appendRow();/添加一行tableIn.setValue(要放入的信息, RFC 字段名);tableIn.setValue(消防栓, QNAME);/=/7.赋值传入参数,执行/=/function.setTableParameterList(inParm);mConnection.execute(function);/执行配置好的 function/=/8.1.输出参数/=/JCO.ParameterList outPa

8、rm = function.getExportParameterList();String SAP_RFC_NAME = function.getExportParameterList().getString(SAP_RFC_NAME);/=/8.2.输出表/=/JCO.Table ret = function.getTableParameterList().getTable(TABLE_NAME);for (int i = 0; i ret.getNumRows(); i+) ret.setRow(i);/指定行String row_id = ret.getString(SAPROWID);/end for/=/9.关闭链接/=/if(mConnection!=null)/ JCO.Client mConnectionmConnection.disconnect();

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号