日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

JAVA通过JCO连接SAP例子

發布時間:2025/3/17 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JAVA通过JCO连接SAP例子 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.把librfc32.dll,sapjcorfc.dll 放到服務器的系統的c:\windows\system32目錄下

? ?(不然會報錯:sap Field IT_TABLnot a member of TABLES)

2.下載 sap.jar;sapjco.jar;sappool.jar加到JAVA應用下.
3.下面類代碼可以查物料數據
?
import com.sap.mw.jco.*;
import com.sap.mw.jco.JCO.Function;
class SAPServer extends JCO.Server
{
?
? ? public SAPServer(JCO.Repository repo)
? ? {
? ? ? ? super ("10.10.10.50", "sapgw00", "ABC", repo);
? ? } ? ?
}
class SAPLogon
{
?public JCO.Client mConnection;
?public JCO.Repository mRepository;
?public SAPLogon(String client, String userid, String password, String language,
? ? ? ? ? ? String ip, String system_number)
?{
? try {
??
? ? ? ? ?mConnection = JCO.createClient(client,?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?userid,?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?password,?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?language,?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ip,?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?system_number);
? ?mConnection.connect();
? ?mRepository = new JCO.Repository("Lee", mConnection);
? ?System.out.println("SAP連接成功");
?//調用RFC函數
?IFunctionTemplate ft = mRepository.getFunctionTemplate("BAPI_MATERIAL_GET_DETAIL");
?JCO.Function f = ft.getFunction();
?
?//1.傳入參數為Field
? ? f.getImportParameterList().setValue("931029BA", "MATERIAL");?
? ? f.getImportParameterList().setValue("1000", "PLANT"); ? ?
? ? mConnection.execute(f);
? ? //1.返回參數為Field
? ? JCO.Structure struct ?= f.getExportParameterList().getStructure("MATERIAL_GENERAL_DATA");
? ? String name = struct.getString("MATL_DESC");
?System.out.println("物料名:"+name);
? ? String MATL_TYPE = struct.getString("MATL_TYPE");
? ? System.out.println("物料類型:"+MATL_TYPE);
? ??
? ?
? ? mRepository = new JCO.Repository("my_repository", mConnection);
? ? mConnection.disconnect();
? } catch (Exception ex) {
? ?ex.printStackTrace();
? ?System.exit(1);
? ?
? }
??
}
?
}
public class Main {
? ??
? ? public static void main(String[] args) {
? ? ? ? SAPLogon mySAP = new SAPLogon("800", "userid", "passwork", "zh", "21.4.13.2", "00");
? ? ? ? SAPServer myServer = new SAPServer(mySAP.mRepository); ? ? ??
? ? ? ? myServer.start();
? ? }
}

總結

以上是生活随笔為你收集整理的JAVA通过JCO连接SAP例子的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。