SAP Java Connector - Excample 1: Simple RFC call
来源:互联网 发布:uk国家域名缩写 编辑:程序博客网 时间:2024/05/21 22:56
SAP Java Connector - Excample 1: Simple RFC call
Scenario
We will call the RFC function module ZNAS_HIE1_GET_MEMBER_FARM.that returns members that have owned a farm. Input to the function is a farm number, and output is a table of members that have owned the farm and Owner number (Sequence number of owners).
- Class testJCO is excuted and calls class GetMemberFarm method GetMemberFarmFromSap. Input parameters to GetMemberFarm are Farm and Owner number.
- GetMemberFarmFromSap executes RFC ZNAS_HIE1_GET_MEMBER_FARM, that returns a table of members that have owned the farm from the input parameters.
- GetMemberFarmFromSap loops through the table and finds the member where ZZCHCODE (Owner numer), is equal owner number from the input-parameters. and returns the member.
Code
Class testJCO
public class testJco{ public static void main(String[] args) { GetMemberFarm testGetMemberFarm = new GetMemberFarm(); String memberFarm= testGetMemberFarm.GetMemberFarmFromSap("0111020155","02"); System.out.println("Memberfarm: " + memberFarm); }}
Class GetMemberFram
import 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 GetMemberFarm
- SAP Java Connector - Excample 1: Simple RFC call
- SAP Java Connector - Excample 1: Simple RFC call
- SAP Java Connector(JCo) RFC
- asp.net 调用SAP RFC(基于sap.connector.dll和sap.connector.rfc.dll)
- VB.NET通过SAP.Connector调用SAP的RFC
- SAP Java Connector(JCo)
- SAP Java Connector(JCo)
- SAP Java Connector(JCo)
- SAP Java Connector(JCo)
- SAP Java Connector(JCo)
- sap java connector(JCO)
- java sap rfc
- SAP学习日志--RFC remote function call
- .net 4.0通过sap connector 4.0调用RFC
- SAP Java Connector(JCo) (转)
- JAVA 与SAP RFC连接
- java调用SAP RFC函数
- Java 调用SAP RFC函数
- SpiderMonkey
- 指令并行的问题
- 需 求 规 格 说 明 书
- scriptmanage js调用后台方法
- 函数说明(MultiByteToWideChar 、WideCharToMultiByte) 08.11.3
- SAP Java Connector - Excample 1: Simple RFC call
- 【转帖】深入浅出Dll(介绍函数导出、类导出、钓子dll、不同语言混合编程方法、插件等的实现方法)
- C#常用日期格式处理转换[C#日期格式转换大全]
- Numenta可能会推动web3.0
- ext和asp.net交互
- 老板爱炒的15种员工
- 全局变量的引用
- 中关村没有规则
- “我们弄清了大脑的大部分活动”Numenta公司公开研究成果