ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SAP JCO 备份

SAP JCO 备份

原创 Linux操作系统 作者:shyy1231 时间:2011-01-20 13:31:53 0 删除 编辑

package com.mg.sap.ui;

import com.sap.mw.jco.*;
import com.sap.mw.jco.JCO.PoolManager;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
 *
 * @author fred
 */
public class SAPQuery {

    //private static JCO.Client mConnection;
    private static final String SAPHR_POOL_NAME = "SAP_Poolssss";

 

    public static void getSAPPoolConnection() throws IOException {
  PoolManager clientPoolManager = JCO.getClientPoolManager();
  //JCO.Client mClient =null;
  
  try{
   JCO.Pool pool = clientPoolManager.getPool(SAPHR_POOL_NAME);
   if (pool == null) {
    Properties props = new Properties();
    InputStream is = SAPQuery.class.getResourceAsStream("SAPLogon.properties");
    props.load(is);
//    JCO.addClientPool(SAPHR_POOL_NAME, // pool name
//      22, // maximum number of connections
//      "100",
//      "VSC066",
//      "123888",
//      "en",
//      "192.168.163.6",
//      "00"); // properties
    JCO.addClientPool(SAPHR_POOL_NAME, // pool name
      10, // maximum number of connections
      props); // properties    
   }
   //mConnection = JCO.getClient(SAPHR_POOL_NAME);


  }catch (Exception ex) {
   System.err.println(ex.getMessage());
  }
  finally{
   //JCO.releaseClient(mConnection);
  }
  
  //return mClient;
 }


    public static void setConnection(){
        try{
//            mConnection = JCO.createClient("100",
//                                           "vsc066",
//                                           "123888",
//                                           "en",
//                                           "192.168.163.6",
//                                           "00");
        }catch(Exception ex){
           
        }

    }
   
 
    public static void queryPurchse() throws IOException{
      //setConnection();
      JCO.Client client; 
     
      getSAPPoolConnection();
  

      IRepository myRepository = JCO.createRepository("MYRepository", SAPHR_POOL_NAME);
      System.out.println(myRepository.toString());
      String strFunc = "Z_DDXI_RFC";
      IFunctionTemplate ft = myRepository.getFunctionTemplate("Z_DDXI_RFC");
      JCO.Function funGetList = ft.getFunction();
      JCO.ParameterList input = funGetList.getImportParameterList();
      input.setValue("AA", "CARRID");

      client = JCO.getClient(SAPHR_POOL_NAME);
      client.execute(funGetList);

      JCO.Table tDateRange = funGetList.getTableParameterList().getTable("DATA");
      System.out.println("tDateRange:"+tDateRange.getNumRows());
      for (int i = 0; i < tDateRange.getNumRows(); i++) {
        tDateRange.setRow(i);
        System.out.println("Record ["
                            + tDateRange.getString("CARRID")    + "] NUMBER= "
                            + tDateRange.getString("CONNID")    + " COUNTYFR= "
                            + tDateRange.getString("COUNTRYFR") + " CITYFROM= "
                            + tDateRange.getString("CITYFROM"));
      }   
    }


    public void closeConnection(){

        //mConnection.disconnect();

    }
   


    public static final void main(String[] args){  
     try {
      queryPurchse();
  } catch (IOException e) {
   e.printStackTrace();
  }
    }    
   
}

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22367662/viewspace-684351/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-08-18

  • 博文量
    12
  • 访问量
    13867