2014-10-17 290 views
0

我有一個.Net應用程序,用於通過它創建SAP銷售訂單。當我使用(通用)單個SAP用戶帳戶創建rfcDestination時,它可以與多個用戶完美協作。 但是,當我使用登錄用戶的用戶帳戶時,它會給出以下例外。SAP .NET連接器,使用多個SAP用戶帳戶連接到單個RFC目標

RfcInvalidStateException:Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.Provider.SapException: destination MAQ is invalid ---> SAP.Middleware.Connector.RfcInvalidStateException: destination MAQ is invalid 
    at SAP.Middleware.Connector.RfcFunction.Invoke(RfcDestination destination) 
    at Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.Provider.SapConectionProvider.Invoke[T](IDataRequet request, String username, String password, IRfcFunction& rfcFunction) 
    --- End of inner exception stack trace --- 
    at Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.Provider.SapConectionProvider.Invoke[T](IDataRequet request, String username, String password, IRfcFunction& rfcFunction) 
    at Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.SapDataRepository2.Invoke[T](IDataRequet request, String user, String password) 
08:20:52.016 [23] ERROR General - ATP Check Exception:Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.Provider.SapException: destination MAQ is invalid ---> SAP.Middleware.Connector.RfcInvalidStateException: destination MAQ is invalid 
    at SAP.Middleware.Connector.RfcFunction.Invoke(RfcDestination destination) 
    at Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.Provider.SapConectionProvider.Invoke[T](IDataRequet request, String username, String password, IRfcFunction& rfcFunction) 
    --- End of inner exception stack trace --- 
    at Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.Provider.SapConectionProvider.Invoke[T](IDataRequet request, String username, String password, IRfcFunction& rfcFunction) 
    at Portal.Infrastructure.Data.BoundedContext.ScreenPop.SAP.SapDataRepository2.Invoke[T](IDataRequet request, String user, String password) 

而這隻發生在多個用戶同時調用rfc時。

SAP .Net連接器是否支持多個SAP用戶帳戶?

回答

2

你需要使用RfcCustomDestination多個登錄:

的web.config

<configSections> 
    <sectionGroup name="SAP.Middleware.Connector"> 
     <sectionGroup name="ClientSettings"> 
     <section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/> 
     </sectionGroup> 
    </sectionGroup> 
    </configSections> 


    <SAP.Middleware.Connector> 
    <ClientSettings> 
     <DestinationConfiguration> 
     <destinations> 
      <!-- multiple ways to do this ... --> 
      <add NAME="DEV" SYSID="DEV" ASHOST="mysapashost.com" SYSNR="00" CLIENT="0000" LANG="EN" MAX_POOL_SIZE="5" IDLE_TIMEOUT="10" USER="anything it is not used" PASSWD="anything it is not used"/> 

     </destinations> 
     </DestinationConfiguration> 
    </ClientSettings> 
    </SAP.Middleware.Connector> 


</configuration> 

應用代碼:

private static RfcCustomDestination mydestination() 
{ 
    //"DEV" is the name of the destination in the web.config 
    RfcDestination rfcDest = RfcDestinationManager.GetDestination("DEV"); 

    RfcCustomDestination _customDestination = rfcDest.CreateCustomDestination(); 
    _customDestination.User = "LoggedOnSAPUserid"; 
    _customDestination.Password = "LoggedOnSAPPassword"; 

    return _customDestination; 
} 

public string runMyRFC(string myInput) 
{ 
    RfcCustomDestination _customDestination = mydestination(); 
    IRfcFunction Results = _customDestination.Repository.CreateFunction("Z_SOME_RFC"); 

    Results.SetValue("RFCInput", myInput); 

    Results.Invoke(_customDestination); 

    string threResult; 

    //. . . 

    return theResult; 

} 
+0

感謝您的回答,我試過,但得到了同樣的結果與不同的SAP登錄信息。所以我使用這個RfcCustomDestination與我的普通SAP用戶,似乎它的工作正常...因爲我得到了以上的例外與普通用戶與我以前的做法。 – tarzanbappa 2014-10-27 09:10:47