1

私は現在、SAP からいくつかのデータを読み取る必要がある小さな Java アプリケーションを開発しています。ほとんどすべてが正常に機能しています。SAP に接続でき、BAPI を呼び出して結果を取得でき、指定された結果を処理することもできます。しかし....

2 つの異なる SAP システム (システム A とシステム B) があります。

アプリケーションを起動してシステム A に接続すると、すべて問題ありません。しかし、システム A からのすべてのデータが処理された後、システム B を呼び出したいと思います (アプリケーションを停止/再起動せずに)。この状況では、システム B に接続できません。

SAP システムへの接続を確立する部分に何か問題があるに違いないと思います。

誰かがこれを正しく行う方法を教えてもらえますか?

これは私のコードです:

これが接続を確立する方法です (SapLogOn と SapSystem は、必要なパラメーターのラッパー クラスのみです)。

private void connectToSap(ISapLogOn logOn, ISapSystem system)
            throws JCoException {

        connectProperties = new Properties();
        connectProperties.setProperty("ACTION", "CREATE");
        connectProperties.setProperty(DestinationDataProvider.JCO_DEST, "POOL_DE");
        connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, system.getAsHost());
        connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, system.getSysNr());
        connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, system.getClient());
        connectProperties.setProperty(DestinationDataProvider.JCO_USER, logOn.getUserName());
        connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, logOn.getPassword());
        connectProperties.setProperty(DestinationDataProvider.JCO_LANG, system.getLanguage());
        connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, system.getSapRouterString());
        connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, system.getPoolCapacity());
        connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, system.getPeakLimit());

        MyDestinationDataProvider myProvider = new MyDestinationDataProvider();

        if (!com.sap.conn.jco.ext.Environment
                .isDestinationDataProviderRegistered()) {
            com.sap.conn.jco.ext.Environment
                    .registerDestinationDataProvider(myProvider);
        }
        myProvider.changePropertiesForABAP_AS(connectProperties);
    }

パート 2 は次のとおりです。

public class MyDestinationDataProvider implements DestinationDataProvider {

    public static Logger LOGGER = Logger.getLogger(MyDestinationDataProvider.class.getName());
    @SuppressWarnings("unused")
    private DestinationDataEventListener eL;
    private Hashtable<String, Properties> propertiesTab;

    public MyDestinationDataProvider() {
        this.propertiesTab = new Hashtable<String, Properties>();
        this.eL = new DestinationDataEventListener() {

            @Override
            public void updated(String arg0) {}

            @Override
            public void deleted(String arg0) {}
        };
    }

    public Properties getDestinationProperties(String destinationName)
    {
        if(propertiesTab.containsKey(destinationName)){
            return propertiesTab.get(destinationName);
        }
        LOGGER.error("Destination " + destinationName + " is not available");
        throw new RuntimeException("Destination " + destinationName + " is not available");
    }

    public void setDestinationDataEventListener(DestinationDataEventListener eventListener)
    {
        this.eL = eventListener;
    }

    public boolean supportsEvents()
    {
        return true;
    }

    void changePropertiesForABAP_AS(Properties pConProps)
    {
        if(pConProps.getProperty("ACTION").equalsIgnoreCase("CREATE")){
            propertiesTab.put(pConProps.getProperty("jco.client.dest"), pConProps);              
        }
        else if(pConProps.getProperty("ACTION").equalsIgnoreCase("DELETE")){
            propertiesTab.remove(pConProps.getProperty("jco.client.dest"));
        }
    }
}

Java 6 と JCo3 を使用しています。

よろしくLStrike

4

0 に答える 0