RFC Java交互例子
来源:互联网 发布:linux man手册英文版 编辑:程序博客网 时间:2024/05/22 14:16
Class testJCOpublic class testJco { public static void main(String[] args) { GetMemberFarm testGetMemberFarm = new GetMemberFarm(); String memberFarm = testGetMemberFarm.GetMemberFarmFromSap( "0111020155", "02"); System.out.println("Memberfarm: " + memberFarm); }}
Class GetMemberFramimport com.sap.mw.jco.*; //The JCO public class GetMemberFarm { public String GetMemberFarmFromSap(String farm, String OwnerNumber){ String zzmemb =""; String memberFarm = ""; JCO.Repository mRepository; JCO.Client mConnection = null; JCO.Function myFunction = null; // --------------------------------------------------------- //Create // Connection to SAP // //--------------------------------------------------------- try { mConnection = JCO.createClient("800", // SAP client "HFR", // User ID "vimmer3", // Password "EN", // Language "53.205.22.71", // Host "03"); // System mConnection.connect(); System.out.println("Connection OK"); } catch (Exception ex) { System.out.println(ex); } // --------------------------------------------------------- // // Create function and parameters // //--------------------------------------------------------- try { // Create repository mRepository = new JCO.Repository( "GetMember", mConnection ); // Get a function template from the repository IFunctionTemplate ftemplate = mRepository.getFunctionTemplate("ZNAS_HIE1_GET_MEMBER_FARM"); // Create function myFunction = new JCO.Function(ftemplate); System.out.println("Function created"); // Set import parameter JCO.Field zzfarm = myFunction.getImportParameterList().getField("ZZFARM"); zzfarm.setValue(farm); System.out.println("Parameters ok"); } catch (Exception ex) { System.out.println(ex); } // --------------------------------------------------------- // // Execute function // //--------------------------------------------------------- try { mConnection.execute(myFunction); System.out.println("RFC Call OK"); } catch (Exception ex) { System.out.println(ex); // Exception from function } // --------------------------------------------------------- // Handle return table GT_HIERARCHY // Loop over the table and find the record that // has ZZCHCODE = OwnerNumber from the // method parameters, and return Member for the // record // --------------------------------------------------------- JCO.Table gt_HIERARCHY = null; try { gt_HIERARCHY=myFunction.getTableParameterList().getTable("GT_HIERARCHY"); // Loop thhrough table and return the member that has // changecode (ZZCHCODE) = 02 for (int i = 0; i < gt_HIERARCHY.getNumRows(); i++) { gt_HIERARCHY.setRow(i); String zzchcode = gt_HIERARCHY.getString("ZZCHCODE"); if (zzchcode.equals(OwnerNumber)) { zzmemb = gt_HIERARCHY.getString("ZZMEMB"); } } } catch (Exception ex) { System.out.println(ex); } // --------------------------------------------------------- // // Disconnect from SAP // //--------------------------------------------------------- try { mConnection.disconnect(); System.out.println("Disconnected from SAP"); } catch (Exception ex) { System.out.println(ex); } return zzmemb; } } // public class GetMemberFarmLast Updated (Thursday, 29 January 2009 // 05:58) } }}
0 0
- RFC Java交互例子
- Lua与Java相互交互的例子
- asp调用rfc的例子
- java sap rfc
- java 调用rfc 错误
- java調用RFC
- socket连接 java服务器端 C#客户端进行交互 简单例子
- Java网路编程____TCP协议客户端服务器信息交互例子
- ABAP--一个极好的调用外部java程序的Search Help Exit的实例(RFC好例子)
- ABAP--一个极好的调用外部java程序的Search Help Exit的实例(RFC好例子)
- ABAP--一个极好的调用外部java程序的Search Help Exit的实例(RFC好例子)
- SAP Java Connector(JCo) RFC
- JAVA 与SAP RFC连接
- java调用SAP RFC函数
- Java 调用SAP RFC函数
- java调用SAP RFC函数
- java调SAP RFC接口
- rfc
- python用BeautifulSoup抓取知乎小药丸
- 即将正式关闭MSN中文网
- CSS
- Android 主线程 子线程
- 网页上传文件获取地址的问题
- RFC Java交互例子
- 剑指offer之面试题12打印1到最大的n位数
- jquery attr与prop 的区别
- mac平台下LuaJIT-2.1.0-beta2 编译android i686-linux-android-clang: Command not found
- android 开发技巧、问题汇总
- Android全局的一些设置
- float 左右布局,左右div等高
- ansible离线安装(自动化)
- html5 postMessage解决跨域、跨窗口消息传递