ecology调用SAPRFC接口的第一种写法(不生成配置文件)

RFC第一种写法:不生成配置文件,直接连接

java 复制代码
package com.kaka.workflow.utils;

import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.ext.DestinationDataEventListener;
import com.sap.conn.jco.ext.DestinationDataProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Properties;
  class ConnSAPProperties implements DestinationDataProvider {
    public Properties getDestinationProperties(String destinationName) {
        Properties properties = new Properties();
        properties.setProperty(DestinationDataProvider.JCO_ASHOST, "IP地址");
        properties.setProperty(DestinationDataProvider.JCO_SYSNR, "编号");
        properties.setProperty(DestinationDataProvider.JCO_CLIENT, "客户端");
        properties.setProperty(DestinationDataProvider.JCO_USER, "账户名");
        properties.setProperty(DestinationDataProvider.JCO_PASSWD, "密码");
        properties.setProperty(DestinationDataProvider.JCO_LANG, "ZH");
        return properties;
    }
    public void setDestinationDataEventListener(DestinationDataEventListener eventListener) {}
    public boolean supportsEvents() { return false; }
}

/***
* @MethodName: ConnSAP
* @Description: 连接SAP
* @Param:
* @return:
* @Author: kaka
* @Date: 2023/9/18 17:33
*/
public class ConnSAP {
    private static Log log = LogFactory.getLog(ConnSAP.class);

    public static JCoDestination Connect() {
        ConnSAPProperties provider = new ConnSAPProperties();
        com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(provider); //实例化
        JCoDestination destination = null;
        try {
            destination = JCoDestinationManager.getDestination("ABAP_AS_POOLED");
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("provider>>"+provider);
        return destination;
    }

    public static void main(String[] args) {
        JCoDestination connect = ConnSAP.Connect();
        System.out.println("connect>>>>>"+connect);
    }

}

运行结果:成功了>>>

相关推荐
optimistic_chen4 天前
【Java EE进阶 --- SpringBoot】Spring IoC
spring boot·后端·spring·java-ee·mvc·loc
hy.z_7775 天前
【JavaEE】网络编程套接字2: TCP流 套接字编程
网络·java-ee·tcp
小羔羊的官方学习账号5 天前
整理期初数据用到的EXCEL里面的函数操作
excel·sap·期初数据整理
编啊编程啊程5 天前
Netty从0到1系列之Selector
java·spring boot·spring cloud·java-ee·kafka·maven·nio
天若有情6736 天前
《JAVA EE企业级应用开发》第一课笔记
java·笔记·后端·java-ee·javaee
翻斗花园刘大胆6 天前
JavaSE之String 与 StringBuilder 全面解析(附实例代码)
java·开发语言·jvm·git·java-ee·intellij-idea·html5
多读书1937 天前
JavaEE初阶网络原理-初识
网络·java-ee
手握风云-7 天前
JavaEE 进阶第一期:开启前端入门之旅(上)
java·前端·java-ee
一枚小小程序员哈8 天前
基于微信小程序的诊所信息系统的设计与实现
spring boot·struts·spring·spring cloud·java-ee·maven·intellij-idea
编啊编程啊程8 天前
响应式编程框架Reactor【7】
java·spring boot·spring cloud·java-ee·maven