天天看點

RFC SDK 指南 用戶端程式的編寫

An external RFC client program calls a remote RFC function. The following steps have to be conducted by an external RFC client:

1. Open an RFC-Connection. In this phase a valid RFC client handle will be created.

2. Call one or more remote RFC functions.

3. Close or terminate an RFC connection. The valid RFC handle will invalidate. All connection data is lost.

一個外部RFC用戶端程式調用遠端RFC函數。通過以下步驟使外部用戶端通路SAP R/3:

    1.打加一個RFC連接配接。這一階段,一個有效的RFC客戶句柄被建立。

    2.調用一個或多個遠端RFC函數。

    3.關閉或終止一個RFC連接配接。有效的RFC句柄将失效。所有連接配接資料将丢失。

 Open an RFC-Connection(打開一個RFC連接配接)

To create a valid RFC client handle, it is necessary to establish an RFC connection to an RFC partner. The following connection types are possible:

    • Connection to a R/2-System

    • Connection to an R/3 System

    • Connection to an external RFC server

建立一個有效的RFC客戶句柄,是建立一個RFC連接配接必須的。可能有下列連接配接類型:

連接配接到R/2系統

連接配接到R/3系統

連接配接到外部RFC伺服器

Every RFC connection will be established in two steps:

    • Connection from an RFC program to an SAP gateway

    • Connection from the SAP gateway to an RFC server

建立一個RFC連接配接需要執行以下兩步:

    從用戶端連接配接到SAP網關

    從SAP網關連接配接到RFC伺服器

A connection to a remote RFC server has to be established via RfcOpenEx API-call. This API takes as input parameter a zero terminated string with connection data and returns an RFC handle. If the connection was successfully established, the handle is valid. If the handle is returned, it is invalid and has the value RFC_HANDLE_NULL.

使用RfcOpenEx API建立一個到遠端RFC伺服器的連接配接。這個API的輸入參數是一個包含連接配接資訊的以0結尾的字元串并且傳回一個RFC馇。如果這個連接配接成功建立,這個句柄就是有效的,否則傳回一個值為RFC_HANDLE_NULL的無效句柄。

It is possible to precede the logon check during opening of an RFC connection.

To create an RFC connection the following data is needed:

• Connection data. This data is necessary to establish the connection to the RFC server.

• Logon data (user identity, client and logon language). This data is used for logon to the given R/3 system.

• Additional data. By using this data, some connection features can be customized. For example, it is possible to turn the RFC trace on, start SAPGUI to open time etc.

在打開一個RFC連接配接之前需要進行登入驗證。建立一個有效的連接配接需要以下資料:

  連接配接資料(使用者辨別,用戶端和登入語言).這些資料對于給定的R/3系統是有用的。

  附加資料。使用這些資料,可定義一些連接配接的特性。比如:打開RFC的調試功能,當打開連接配接時顯示SAP界面等。

Abbreviator BAER2 (B - load Balancing, A - explicit Application server, E - External RFC program, R - Registered RFC server, 2 - R/2 connection) could describe the connection kinds.

The connection string has to have the following format: “ID=value ID=value ... ID=value”.

縮寫 BAER2(B:負載均衡,A:明确的應用伺服器,E:擴充RFC應用程式,R:注冊的RFC伺服器,2:R/2連接配接器)可以描述連接配接的類型。

連接配接字元串格式如下:“ID=value ID=value ... ID=value”.

RFC_HANDLE handle = RFC_HANDLE_NULL;

RFC_ERROR_INFO_EX error_info_ex;

rfc_char_t connect_string[] = “ … “;

handle = RfcOpenEx (connect_string, &error_info_ex);

SAP AG

SAP RFCSDK Guide 5

if (handle == RFC_HANDLE_NULL)

{

/* Connection could not be established

...

}

It is possible to only declare the data in the connection string. In this case all necessary connection data is defined as input parameter of RfcOpenEx API.

聲明的資料僅在連接配接字元串中使用。在這種情況下,所有連接配接資料均在RfcOpenEx API的輸入參數中聲明。

Another way is to declare the data in the saprfc.ini file. To use the saprfc.ini file, the connection parameter string must have the following entry: “DEST=<your destination in saprfc.ini file>”. In this case the corresponding entries from the sapRFC.ini file will be used to establish the connection.

另一種方法是在saprfc.ini檔案中聲明連接配接資料,連接配接字元串必須擁有如下入口:“DEST=<your destination in saprfc.ini file>”. 如果是這樣,在saprfc.ini檔案中相應的入口用來建立連接配接。

A third possibility is to use the SAPLOGON data (this is available for Windows platforms only). To use the connection data from sapmsg.ini file, the connection string must have the following entry: “SAPLOGON_ID=<entry from saplogon> “.

第三種訪求就是使用SAPLOGON(僅在Windows平台使用)使用sapmsg.ini檔案中的連接配接資料,連接配接字元串必須有如下聲明:“SAPLOGON_ID=<entry from saplogon> “.