RFC Connector Help

Introduction to RFC Connector

What is RFC Connector?

secept RFC Connector is a COM library which enables easy and language-independent access to SAPTM systems from Microsoft OfficeTM and Microsoft WindowsTM programs.

  • Overview
  • Examples
  • Reference
  • Getting Support


RFC Connector Overview

RFC Connector consists of several COM objects which facilitate calling Function Modules and BSP Applications from SAP Systems.

Function Modules can be called using either SAP's own RFC protocol, or SOAP (SOAP is not available with Basis Releases prior to 4.6C).

To use RFC, you must have LIBRFC32.DLL installed and registered at your system, either by installing SAPGUI or the RFC SDK, which are both available for download to SAP customers at the SAP Service Marketplace

Quick Start

To call a Function Module using RFC, create an Instance of RfcSession, fill its LogonData and RfcSystemData properties, and connect to the SAP System using the connect() method:

  Dim session as new RfcSession

  session.RfcSystemData.ConnectString = "ASHOST=myhost SYSNR=00"

  session.LogonData.Client = "000"
  session.LogonData.User = "TEST"
    session.LogonData.Password = "***"
  session.LogonData.Language = "EN"

  session.Connect

Use ImportType to import data structures from the server:

  Dim tBAPISFLDAT As RfcType
  Set tBAPISFLDAT = session.ImportType("BAPISFLDAT")

Defining the necessary parameters:

  Dim func As FunctionCall
  Set func = session.CreateCall
  func.Function = "BAPI_FLIGHT_GETLIST"
  func.Tables.AddTable "FLIGHT_LIST", tBAPISFLDAT

Calling the function:

  session.CallFunction func

Processing retrieved data:

  For i = 1 To func.Tables("FLIGHT_LIST").Rows.Count
    Debug.Print func.Tables("FLIGHT_LIST").Rows(i).Item("FLIGHTDATE").Value
  Next i

Tasks in Detail

  • Calling Function Modules
  • Using Parameters
  • Using BSP Applications
  • Advanced Topics


Calling Function Modules

In this chapter, we will show step by step how to call a function module in SAP with RFC Connector.

Note: This example is written using Visual Basic 6, however you can use any language which supports COM with RFC Connector. See the Example Section for examples how RFC Connector is used with other languages.

Preparations

Determining connection parameters

To be able to connect a SAP system, you need to know the connection parameters. In our example, we assume that you have a system named EX1 located at the server myserver with system number 00. If you are not sure what your hostname and system number are, you can look them up in SAPLogon:

Screenshot: Using SAPLogon to determine the hostname and system number

If you are using a message server (load balancer), your connection string will be

MSHOST=msgserver MSSERV=myservice
If you are using an appserver without message server instead, use
ASHOST=myserver SYSNR=00

Determining function module parameters

To call a Function Module, you must know its signature, that means the type and name of the parameters. To find out about a module's signature, open transaction SE37 in SAPGUI and navigate to the module you are going to call.

Screenshot: transaction SE37 shows parameter names and types

In this example, we will call the Function Module BAPI_FLIGHT_GETLIST with the following parameters (there are more, but we want to keep the example code short and simple):

  • Importing
    • AIRLINE - a scalar field of type CHAR(3)
  • Tables
    • FLIGHT_LIST - a table with row type BAPISFLDAT

Writing the code

Before writing the code, you must tell the IDE to use the RFC Connector Type Library. In Visual Basic, select "Project" -> "References" from the menu and mark the checkbox left to "secept RFC Connector".

Now that we have identified the System and Function Module parameters, we can implement our function call.

First, we'll create an instance of RfcSession, and fill its LogonData and RfcSystemData properties. After having done so, the backend is connected by calling the connect() method.

  Dim session as new RfcSession

  session.RfcSystemData.ConnectString = "ASHOST=myhost SYSNR=00"

  session.LogonData.Client = "000"
  session.LogonData.User = "TEST"
    session.LogonData.Password = "***"
  session.LogonData.Language = "EN"

  session.Connect

Being connected to the server, we can use ImportType to import data structures from the server. Since RFC Connector caches imported type definitions automatically, it is always preferrable to import the structure from the server, instead of defining them manually.

  Dim tBAPISFLDAT As RfcType
  Set tBAPISFLDAT = session.ImportType("BAPISFLDAT")

With the imported type data, we can create the function module and define the parameters. The parameter AIRLINE is scalar. We assign it a type and set it to the value LH.

  Dim func As FunctionCall
  Set func = session.CreateCall
  func.Function = "BAPI_FLIGHT_GETLIST"
  func.Importing.AddScalar "AIRLINE", TYPE_CHAR, 3, , "LH"
  func.Tables.AddTable "FLIGHT_LIST", tBAPISFLDAT

After all preparations are done, it is time to call the function. Note that the function is called synchronously here, which means that CallFunction only returns after the results have been fetched from the backend.

  session.CallFunction func

Alternatively, we could use the asynchronous call feature of RFC Connector. If the second parameter of CallActive is set to False, the function returns immediately, allowing us to call DoEvents while polling whether the results are in, thus keeping the UI usable.

  session.CallFunction func, False
  While session.CallActive
    DoEvents
  Wend
Instead of polling the session state, it is also possible to intercept the CallFinished-Event.
This example shows how to use asynchronous calls to have a cancel button in a program.

Either way, the results are now waiting to be processed. The simplest method of working with tables is to use the For Each command, which is available in all Visual Basic dialects:

    Dim row As RfcFields
    For Each row In func.Tables("FLIGHT_LIST").Rows
        Debug.Print row("FLIGHTDATE").Value & " " & row("AIRPORTFR").Value
    Next

In the next section we'll be looking at parameters in more detail.


Using Parameters

In this section, we'll take a deeper look at the different kinds of parameters and how they are used.

Scalar Parameters

Scalar parameters are parameters which have only one value. They can be defined using the AddScalar method of the Parameter object, which can optionally also assign a value.

In the current version, it is not possible to import scalar parameters with ImportType. You must always define your scalar parameters locally.

RFC Connector automatically converts values between SAP Types and VARIANT. For TYPE_BYTE and TYPE_XSTRING, use VARIANT arrays of type Byte (or in C:VT_ARRAY|VT_UI1).

For date and time values, always use ISO format ("YYYY-MM-DD" / "HH:MM:SS"), if possible, but any localized formats ("YY/DD/MM") accepted by VariantChangeType of the Win32 API will work, too. Never try to use the internal SAP format ("YYYYMMMDD") directly, this will fail.
 func.Importing.AddScalarParam "MYCHAR", TYPE_CHAR, 32, , "MyValue"

 func.Importing.AddScalarParam "MYDATE", TYPE_DATE, , , "2005-12-01"

 Dim myByteArray(10) as Byte
 func.Importing.AddScalarParam "MYARRAY", TYPE_BYTE, , , myByteArray

 Debug.Print func.Exporting("MYCHAR").Value

Structs

Unlike scalar parameters, structs must be explicitly defined. You can either import a struct definition from the backend system (the recommended method), or defined statically in your code, if you are very concerned about performance or using a WAN connection where every single byte counts.

 Dim tMYSTRUCT1 As RfcType, tMYSTRUCT2 As RfcType

 Set tMYSTRUCT1 = session.ImportType("MYSTRUCT1")

 Set tMYSTRUCT2 = session.CreateType
 tMYSTRUCT2.DefineStruct "MYSTRUCT2"
 tMYSTRUCT2.AddScalarStructField "FIELD1", TYPE_CHAR, 10
 tMYSTRUCT2.AddScalarStructField "FIELD1", TYPE_CHAR, 20

 func.Importing.AddParameter "MYPARAM1", tMYSTRUCT2
 func.Importing("MYPARAM1").Fields("FIELD1").Value = "MyVal1"
 func.Importing("MYPARAM1").Fields("FIELD2").Value = "MyVal2"

Tables

In RFC Connector, tables are modeled as arrays of structures. Therefore, you always need a struct type to define a table.

Once the table is created, you can add rows with AddRow, and access rows with Rows(index)

In RFC Connector, numerical indexes to arrays are always based on 1, not 0, as in many programming languages.
 Dim tbl as RfcParameter, row As RfcFields
 Set tbl = func.tables.AddTable("MYTABLE", tMyStruct2)

 Set row = tbl.Rows.AddRow
 row("FIELD1").Value = "val1"
 Set row = tbl.Rows.AddRow
 row("FIELD2").Value = "val2"

 For Each row In func.Tables("MYTABLE").Rows
     Debug.Print row("FIELD1").Value
 Next

 For i = 1 to func.Tables("MYTABLE").Rows.Count
     Debug.Print func.Tables("MYTABLE").Rows(i).Fields("FIELD1").Value
 Next


Using BSP Applications

RFC Connector offers a simple and straightforward way of integrating Web applications.

Using the BSPApplication object offers several advantages in comparison to launching the application in the web browser:

  • You can preset user and password; SSO is also supported
  • You have complete control about the window size, title and position
  • BSPApplication windows are modal (blocking the UI of the host application)
  • BSPApplication windows have no back buttons or address bar, so the user cannot navigate away
  • BSPApplication can return parameters from the web app to the host application
  • The web app can close itself, and you can (optionally) warn the user if he uses the close button

Creating a BSPApplication object

Before calling the web application, you must create the BSPApplication object, and set its HttpSystemData, LogonData and Window properties:
The port number is normally Sysnr+8000. You can look it up in the system with transaction SMICM (use "GoTo" -> "Services")

 Dim bsp As New BSPApplication

 bsp.HttpSystemData.Host = "myhost"
 bsp.HttpSystemData.Port = "myport"

 bsp.Window.Left = 100
 bsp.Window.Top = 100
 bsp.Window.Height = 800
 bsp.Window.Width = 600
 bsp.Window.Title = "My BSP Window"

 bsp.LogonData.Client = "000"
 bsp.LogonData.User = "myuser"
 bsp.LogonData.Password = "mypassword"
 bsp.LogonData.Language = "en"

Optionally, you can define a warning message which is displayed when the user clicks on the close button:

 bsp.Window.CloseWarning = "Do you really want to close this window?" & vbCrLf & "Data loss may occur"

Calling the Application

Before you can use a BSP Application, you need to activate it in the SAP System using transaction SICF

To launch a BSP Application, we call the ShowApplication method:

 bsp.ShowApplication "/sap/bc/bsp/sap/htmlb_samples/default.htm"

Exit Pages

Sometimes it is useful for a web application to return values to the caller, and/or to close itself when the user has finished working with it. With RFC Connector, these functionality can be implemented by using exit pages.

The idea behind exit pages is that a web application contains links or buttons which link to a special page (the exit page). If the user navigates to that page, the BSPApplication object intercepts that navigation, closes the window and returns the parameters submitted.

In the following section, we implement a simple BSP application which contains an input field and a button. If the user presses the button, the value entered in the input field is transmitted to the calling program.

Source Code for the BSP Application

The following code must be entered in the SAP system. To create the web application in SAP, use transaction SE80. In SE80, choose "Workbench" -> "Edit Object" -> "Web Objects" -> "BSP Application" and enter Z_EXITPAGE as name. After the application is created, create a page named index.htm by right-clicking the Z_EXITPAGE node on the left and choosing "Create" -> "Page" from the context menu. Select "Page with Flow Logic" as page type, then paste the following source code

Source Code (Plain HTML)

<html>
 <body>
  <form action="ExitPage.htm">
   <input type="text" name="input1" />
   <input type="submit" value="Exit Application" />
  </form>
 </body>
</html>

Alternative Source Code (HTMLB)

If you are using HTMLB, the code is slightly more complicated, because you need to call the exit page in an event handler. Here's the sample page source in HTMLB:

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>

<htmlb:content>
 <htmlb:page title = "Exit Page Example">
  <htmlb:form>
   <htmlb:inputField   id            = "Input1" />
    <htmlb:button      text          = "ExitApplication"
                       onClick       = "ExitButtonClick" />
   </htmlb:form>
 </htmlb:page>
</htmlb:content>

Note that we do not navigate to the exit page here, because that happens in the OnInputProcessing event handler:

* event handler for checking and processing user input and
* for defining navigation

DATA: event TYPE REF TO cl_htmlb_event,
      value TYPE string.

event = cl_htmlb_manager=>get_event( runtime->server->request ).
IF event->name = 'button' AND event->event_type = 'click'.
  value = request->get_form_field( 'input1' ).

  navigation->set_parameter( name = 'input1' value = value ).
  navigation->goto_page( 'ExitPage.htm' ).
ENDIF.

Source Code for the calling program

Regardless of whether you went for the plain HTML or HTMLB solution above, the coding on the client side is the same: Call ShowApplication with the name of your exit page as the second parameter, and read out the Parameters property after the method has returned:

 bsp.ShowApplication "/bc/bsp/sap/z_exitpage/index.htm", "ExitPage.htm"

 MsgBox "You have entered " & bsp.Parameters("input1").Value

Using Single Sign On (SSO)

Single Sign On with BSPApplication is not different to Single Sign On with sessions. Just set the SSO cookie to LogonData.SSO2Ticket and call the application.

More Information about SSO


Advanced Topics

Single Sign On

RFC Connector can retrieve SAP SSO2 tickets via RFC, and can use them to authenticate against an SAP backend using RFC or BSP.

Recommended reading about Single Sign On: Single Sign On in the SAP Library, Note 352295, Note 595341. Access to SAP Notes requires a SAP customer ID.

To retrieve a SSO2 ticket, use the following code:

Dim sess As new RfcSession, ticket As String

sess.RfcSystemData.ConnectString = "ASHOST=myhost SYSNR=mysysnr SNC_MODE=1 SNC_PARTNERNAME=p:SAPServiceXXX@mydomain SNC_LIB=gsskrb5.dll GETSSO2=1"

sess.Connect
ticket = sess.GetSSO2Ticket
sess.Disconnect

To use an existing SAPSSO2 cookie to authenticate, just set the SSO2Ticket property of the LogonData object:

sess.LogonData.SSO2Ticket = ticket

Creating Traces

RFC Connector has some tracing capabilities which can be used to track down problems when debugging is not possible.

To enable tracing, use the following code:

session.Option("trace.file") = "C:\tracefile.txt"

Debugging with SAPGUI

It is possible to use SAPGUI debugging with RFC Connector in RFC, SOAP and BSP. To use debugging, you must set a breakpoint in SAPGUI (SE80). Setting an external breakpoint is the preferred method for debugging, since it works always (with RFC, SOAP and BSP), and does not need require changes to the client coding.

If you want to use session breakpoints instead, you must set the RfcSystemData.Debug and RfcSystemData.Visual properties accordingly. Session breakpoints do not work with SOAP and BSP.


Examples

Visual Basic Examples

  • Visual Basic: Simple Call
  • Visual Basic: Asynchronous operation
  • Visual Basic: Visual RFC
  • Visual Basic: BSP Application

Office Basic Examples

  • Retrieving SAP Data in Excel

Other Languages

  • Visual C++: Simple Call
  • Visual C#: Simple Call


Visual Basic: Simple Call

This example shows how to call a function module with either RFC or SOAP and how to send and receive parameters.

Click here to open this example


Visual Basic: Asynchronous operation

This example shows how to implement an interruptable call.
For demonstrating the asynchronous functionality, you must implement a function module, Z_WAIT in the SAP system. The following block lists the source-code for this function module:
FUNCTION Z_WAIT.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(IM_DELAY) TYPE  INT4 DEFAULT 15
*"----------------------------------------------------------------------

wait up to im_delay seconds.

ENDFUNCTION.
Due to limitations in the underlying library, it is not possible to abort SOAP calls. If AbortCall is called on SOAP sessions, control returns to the caller only after the call is finished or timed out.

Click here to open this example


Visual Basic: Visual RFC

This example shows how to call a function which contains a dialog (dynpro).

Click here to open this example


Visual Basic: BSP Application

The BSP Application example shows how a BSP page is called from Visual Basic. Exit page support is also integrated, but for this to work you must implement the Z_EXITPAGE BSP Application, as described in the Documentation on Exit Pages

Click here to open this example


Retrieving SAP Data in Excel

This example shows how you can extract data from SAP into Excel with RFC Connector

Depending on your settings, you might have to activate macros in Excel manually

Click here to open this example


Visual C++: Simple Call

A simple call of RFC Connector library, written in Visual C++

Click here to open this example


Visual C#: Simple Call

Show how a function is called from Visual C#


API Reference

  • ABAPTYPE
  • ERRORGROUP
  • RFCTYPEKIND
  • BSPApplication
  • BSPParameter
  • FunctionCall
  • HttpSystemData
  • LicenseData
  • LogonData
  • RfcError
  • RfcField
  • RfcParameter
  • RfcRows
  • RfcSystemData
  • RfcType
  • TypeCache
  • WindowProperties
  • Session
  • RfcSession
  • SoapSession


ABAPTYPE

Description

This enumeration contains a list of the supported scalar types:

Internal Type | Numeric Value
TYPE_CHAR | 0x00
TYPE_BCD | 0x01
TYPE_DATE | 0x02
TYPE_TIME | 0x03
TYPE_BYTE | 0x04
TYPE_NUM | 0x06
TYPE_FLOAT | 0x07
TYPE_INT | 0x08
TYPE_INT2 | 0x09
TYPE_INT1 | 0x0A
TYPE_STRING | 0x1D
TYPE_XSTRING | 0x1E

Use the following table to map builtin ABAP types to RfcConnector types:

ABAP Type | Internal Type
ACCP | TYPE_CHAR
CHAR | TYPE_CHAR
CLNT | TYPE_CHAR
CUKY | TYPE_CHAR
CURR | TYPE_BCD
DATS | TYPE_DATE
DEC | TYPE_BCD
FLTP | TYPE_FLOAT
INT1 | TYPE_INT1
INT2 | TYPE_INT2
INT4 | TYPE_INT
LANG | TYPE_CHAR
NUMC | TYPE_NUM
PREC | TYPE_NUM
QUAN | TYPE_BCD
RAW | TYPE_BYTE
RAWSTRING | TYPE_XSTRING
STRING | TYPE_STRING
TIMS | TYPE_TIME
UNIT | TYPE_CHAR

Further information can be found in the SAP Online Help


ERRORGROUP

Description

This enumeration contains a list of possible RFC errors:

RFCERROR_NO_ERROR | 0 | No error
RFCERROR_PROGRAM | 101 | error in RFC program
RFCERROR_COMMUNICATION | 102 | Error on network level
RFCERROR_LOGON_FAILURE | 103 | Could not log on to system (e.g. wrong credentials or locked user)
RFCERROR_SYSTEM_FAILURE | 104 | System error (e.g. SAP system exception raised)
RFCERROR_APPLICATION_EXCEPTION | 105 | The called function module raised an exception
RFCERROR_RESOURCE | 106 | Resource not available
RFCERROR_PROTOCOL | 107 | RFC protocol error
RFCERROR_INTERNAL | 108 | RFC internal error
RFCERROR_CANCELLED | 109 | The operation was cancelled
RFCERROR_BUSY | 110 | System is busy, try later


RFCTYPEKIND

Description

This enumeration contains a list of possible parameter types:

RFCTYPEKIND_UNDEFINED | 0 | type not defined
RFCTYPEKIND_SCALAR | 1 | scalar type (a single value)
RFCTYPEKIND_STRUCT | 2 | scalar type (a single value)
RFCTYPEKIND_TABLE | 3 | scalar type (a single value)


BSPApplication

Description

This object allows you to host a BSP Application.

See Using BSP Applications for details.

Properties

Name | Type | Description | Read-only
HttpSystemData | HttpSystemData | HTTP data of the SAP system which hosts the BSP |
LogonData | LogonData | Logon data for the SAP system |
Window | WindowProperties | Defines the window parameters (title and position) |
Parameters | BSPParameter [] | HTTP GET Parameters which are forwarded to the BSP application/page |
Option | string [] | Allows you to set and retrieve additional options, such as trace file location |
LicenseData | LicenseData | Allows you to set the license data programmatically (instead of using Registry keys) |

Method Summary

Method | Description
About | Show information about RFC Connector
ShowApplication | Show the BSP application

Method Details

About

Show information about RFC Connector

Parameters

none

Return Value

none

ShowApplication

Show the BSP application

Parameters

Parameter | Type | Description
application | string | application to call
exitPage | string | Optional: allows you to define an exit page)

Return Value

none


BSPParameter

Description

A single GET parameter for BSP application

Properties

Name | Type | Description | Read-only
Name | string | Name of parameter |
Value | string | Value of parameter |


FunctionCall

Description

This object represents a single function call

Properties

Name | Type | Description | Read-only
Function | string | name of the function module, e.g. RFC_PING |
Importing | RfcParameter [] | importing parameters of function module |
Exporting | RfcParameter [] | exporting parameters |
Changing | RfcParameter [] | changing parameters |
Tables | RfcParameter [] | table parameters |


HttpSystemData

Description

Connection data for HTTP connection (SOAP, BSP).

Note that some parameters (SoapEndpoint, Stateful) only apply to SoapSession, and are ignored by BSPApplication.

Properties

Name | Type | Description | Read-only
Protocol | string | Protocol to use, either HTTP or HTTPS. Defaults to HTTP |
Host | string | full qualified hostname of the SAP System, e.g. mysaphost.mydomain.com |
Port | integer | port the SOAP/HTTP server listens to (this is typically 8000+SYSNR, but may be changed by SAP admin) |
SoapEndpoint | string | Path to the SOAP service on the SAP server as defined in SICF. Under normal circumstances, there should be no need to change the default value "sap/bc/soap/rfc" |
Timeout | integer | Timeout (in milliseconds) for the HTTP request. Default is 60.000 (1 minute) |
ProxyHost | string | full qualified hostname of the proxy, if necessary |
ProxyPort | integer | port of the proxy |
ProxyUser | string | user for the proxy, if necessary |
ProxyPassword | string | password for the proxy |
Stateful | bool | If set to true, the SAP server is told to keep its state between SOAP requests. Default is false. Note: this property has no effect on BSP applications (in BSP, statefulness is defined by the application, not the client) |


LicenseData

Description

Object which holds license data, consisting of a user and a license key. This can be used instead of storing the license data in the registry.

Properties

Name | Type | Description | Read-only
Owner | string | Owner of the license. Must be entered exactly as in the registration |
Key | string | Licensed key, as received from secept |

Method Summary

Method | Description
IsValidLicense | Check whether the license data is valid

Method Details

IsValidLicense

Check whether the license data is valid

Parameters

none

Return Value

Type | Description
bool | true if the license data is correct


LogonData

Description

This object holds all the data necessary to authenticate the client to the SAP server

Properties

Name | Type | Description | Read-only
Client | string | SAP Client (always a three-letter, numeric string) |
User | string | SAP User |
Password | string | Password |
Language | string | Two-letter SAP language code (EN, DE, ...) |
SSO2Ticket | string | SAPSSO2Ticket as returned by RfcSession.GetSSO2Ticket Note: SAPSSO2Ticket is currently not supported by SOAPSession |
Option | string [] | Additional options for authentication (used for later extensions) |


RfcError

Description

This object contains extended error information

Properties

Name | Type | Description | Read-only
ErrorGroup | ERRORGROUP | The ERRORGROUP of this error |
ErrorGroupText | string | Textual representation of the numeric ERRORGROUP property |
Message | string | Error message |
ModuleName | string | The name of the module in which the error occured |


RfcField

Description

This object represents a field value. Depending on the type of the field, the values can be accessed through the Value, Fields or Rows property

Properties

Name | Type | Description | Read-only
name | string | Name of the field |
Type | RfcType | Type of the field |
Value | variant | Value of the field, if it is of scalar type (plain field, e.g. no struct or table) |
Fields | RfcField [] | Values of the field, if the field type is a struct |
Rows | RfcRows | Contains the table rows, if the field type is table |


RfcParameter

Description

This object represents a function module's parameter.

See Using Parameters for more information.

Properties

Name | Type | Description | Read-only
Name | string | Name of the parameter |
Type | RfcType | Type of the field | yes
Value | variant | Value of the parameter, if it is of scalar type (plain field, e.g. no struct or table) |
Fields | RfcField [] | Values of the field, if the parameter type is a struct |
Rows | RfcRows | Contains the table rows, if the parameter type is table |

Method Summary

Method | Description
DefineScalar | Assign this parameter a scalar type and optionally a value.
Define | Assign this parameter a complex type (struct or table)

Method Details

DefineScalar

Assign this parameter a scalar type and optionally a value.

Parameters

Parameter | Type | Description
name | string | name of the parameter
type | ABABTYPE | type of the parameter
length | integer | lenght of the parameter (only relevant for TYPE_CHAR, TYPE_BYTE, TYPE_NUM and TYPE_BCD. Ignored in all other cases). Default value is 0
decimals | integer | number of decimals (only relevant for TYPE_BCD, ignored in all other cases). Default value is 0
value | variant | value of this parameter (optional, defaults to empty string or 0, depending on the parameter type)

Return Value

none

Define

Assign this parameter a complex type (struct or table)

Parameters

Parameter | Type | Description
name | string | name of the parameter
type | RfcType | type of the parameter, as returned by Session.ImportType

Return Value

none


RfcRows

Description

This object represents the rows of a table.

See Using Tables for more information

Properties

Name | Type | Description | Read-only
Item[index] | RfcField [] | Access an existing row of the table by (numeric) index. Use AddRow or AddRows to append rows |
Type | RfcType | type of the table | yes
FileMode | bool | True if file mode is set | yes
DataCol | integer | If in file mode, contains the index of the data column |
IndexCol | integer | If in file mode, this field contains the index of the index column (if any) |

Method Summary

Method | Description
AddRow | Add a single row to the table
AddRows | Add count rows to the table
SetFileMode | Enable FileMode for this table
RemoveAll | Remove all rows from this table

Method Details

AddRow

Add a single row to the table

Parameters

none

Return Value

Type | Description
RfcField [] | the newly created row

AddRows

Add count rows to the table

Parameters

Parameter | Type | Description
count | integer | number of rows to add

Return Value

none

SetFileMode

Enable FileMode for this table

Parameters

Parameter | Type | Description
dataCol | integer | index of the column where the file data should be stored (mandatory)
indexCol | integer | index of the column where the index (autoincrement) should be stored (optional, default 0=no index)

Return Value

none

RemoveAll

Remove all rows from this table

Parameters

none

Return Value

none


RfcSystemData

Description

Connection data for RFC connection

Properties

Name | Type | Description | Read-only
ConnectString | string | Connect String (e.g. "ASHOST=host SYSNR=00...") for the system. Refer to documentation for RfcOpenEx() in the RFC SDK for details. |
VisualMode | integer | This value controls whether SAPGUI screens are enabled. Possible values are 0 (no GUI), 1 (GUI always open) and 2 (show GUI only if dialog appears) |
Debug | bool | Enables or disables remote debugging using SAPGUI (just set a breakpoint in SE80 and call the function module) |


RfcType

Description

Definition of RFC type

Properties

Name | Type | Description | Read-only
Name | string | Name of the type (only relevant for tracing etc.) |
Kind | RFCTYPEKIND | Defines which kind the type is (scalar, struct or table) |
ScalarType | ABAPTYPE | The scalar type (if type is scalar, not struct or table) |
ScalarLength | integer | The scalar type length (only relevant if ScalarType is TYPE_CHAR, TYPE_BYTE, TYPE_NUM or TYPE_BCD) |
ScalarDecimals | integer | number of decimals (only relevant if ScalarType is TYPE_BCD) |
StructOffset | integer | If the type is part of a struct, this field contains its offset |
StructLength | integer | If the type is a struct, this field contains the total length in bytes |
StructFields | RfcType [] | If the type is a struct, this collection contains its member fields |
RowType | RfcType | The structure of a table row, if the type is a table |

Method Summary

Method | Description
DefineScalar | Define this type as scalar
DefineStruct | Define this type as a struct (use AddScalarStructField and AddComplexStructField to add members)
DefineTable | Define this type as a table
AddScalarStructField | Append a scalar member to the struct
AddComplexStructField | Append a complex field as member of the struct

Method Details

DefineScalar

Define this type as scalar

Parameters

Parameter | Type | Description
name | string | name of the type (only relevant for logging)
abapType | ABAPTYPE | Type of the scalar
length | integer | length of the scalar field (only for CHAR, BYTE, NUM, BCD; defaults to 0)
decimals | integer | count of decimals (only for BCD)
structOffset | integer | Offset of this field, if the scalar is part of a struct

Return Value

none

DefineStruct

Define this type as a struct (use AddScalarStructField and AddComplexStructField to add members)

Parameters

Parameter | Type | Description
name | string | name of the struct (only relevant for logging)

Return Value

none

DefineTable

Define this type as a table

Parameters

Parameter | Type | Description
name | string | name of the table (only relevant for logging)
rowType | RfcType | Type for the table rows

Return Value

none

AddScalarStructField

Append a scalar member to the struct

Parameters

Parameter | Type | Description
name | string | name of the member
abapType | ABAPTYPE | Type of the member
length | integer | length of the scalar member (only for CHAR, BYTE, NUM, BCD; defaults to 0)
decimals | integer | count of decimals for scalar member (only for BCD)
structOffset | integer | Offset of this field in struct

Return Value

none

AddComplexStructField

Append a complex field as member of the struct

Parameters

Parameter | Type | Description
name | string | name of the member
type | RfcType | type of the field

Return Value

none


TypeCache

Description

The type cache is used to share cached type definitions between sessions.

Under normal circumstances, an application programmer does not use the methods of this class directly, but assigns a cache object to a session instead:

        session2.typeCache = session1.typeCache
Important note: Please use caution when sharing caches between connections to different systems, since RFC Connector does not check if the cached type is the same in the other system, so if the types differ in detail, transmission errors may occur.

Method Summary

Method | Description
GetType | Retrieve a type from the cache
AddType | Retrieve a type from the cache
Clear | Remove all cached types

Method Details

GetType

Retrieve a type from the cache

Parameters

Parameter | Type | Description
name | string | name of the type to retrieve

Return Value

Type | Description
RfcType | cached type

AddType

Retrieve a type from the cache

Parameters

Parameter | Type | Description
name | string | name of the type
type | RfcType | type to add to cache

Return Value

none

Clear

Remove all cached types

Parameters

none

Return Value

none


WindowProperties

Description

Determines position, size, and appearance of a BSPApplication window

Properties

Name | Type | Description | Read-only
Left | integer | Space between the left of the screen and the window (in pixels) |
Top | integer | Space between the top of the screen and the window (in pixels) |
Width | integer | Width of window in pixels |
Height | integer | Height of window in pixels |
IconPath | string | Absolute path to the window's icon (defaults to "" = no icon) |
CloseWarning | string | Text which will be displayed if the user closes the window with the close button. Setting this makes only sense if you use the exitPage feature of BSPApplication |


Session

Description

Session is an abstract class, which means that you cannot instantiate a Session object directly. To get a Session object, you must create a RfcSession or SoapSession instead (see examples).

Properties

Name | Type | Description | Read-only
CallActive | bool | True if there is an asynchronous call currently running | yes
Error | bool | True if error occured Note: This property is cleared after reading, e.g. the second call always returns False | yes
ErrorInfo | ErrorInfo | This property contains extended error information | yes
IsConnected | bool | True if currently connected to SAP system | yes
LicenseData | LicenseData | Allows you to set the license data programmatically (instead of using Registry keys) |
LogonData | LogonData | Use this property to specify logon data, such as client, user and language |
Option | Option | Allows you to set and retrieve additional options, such as trace file location | yes
SessionType | string | Evaluates to RFC or SOAP, depending on the session type | yes
SystemID | string | ID (e.g. "T01") of the SAP system you are connecting to |
TypeCache | TypeCache | The TypeCache of this session (this property can be used to share type information between two sessions) |

Method Summary

Method | Description
AbortCall | Abort currently running asynchronous call
About | Show information about RFC Connector
CallFunction | Call a function module
ChangePassword | Change the user's password
CheckPasswordExpired | Checks whether the user must change his password
Connect | Connect to SAP system
CreateCall | Create a new FunctionCall
CreateType | Create a new RfcType
Disconnect | Disconnect from System
ImportType | Import a struct definition from the SAP system.

Method Details

AbortCall

Abort currently running asynchronous call

Parameters

none

Return Value

none

About

Show information about RFC Connector

Parameters

none

Return Value

none

CallFunction

This function allows you to call a function module

Parameters

Parameter | Type | Description
call | FunctionCall | the call to execute
synchronous | bool | Call a function module

Return Value

none

ChangePassword

Change the user's password

Parameters

Parameter | Type | Description
newPass | string | new password for user

Return Value

none

CheckPasswordExpired

Checks whether the user must change his password

Parameters

none

Return Value

Type | Description
bool | True if user must change his password

Connect

Connect to SAP system

Parameters

none

Return Value

none

CreateCall

Create a new FunctionCall

Parameters

none

Return Value

Type | Description
FunctionCall | new FunctionCall object

CreateType

Create a new RfcType

Parameters

none

Return Value

Type | Description
RfcType | new RfcType object

Disconnect

Disconnect from System

Parameters

none

Return Value

none

ImportType

This is the preferred method of working with complex types. Imported types are automatically cached to reduce overhead.

Parameters

Parameter | Type | Description
type | string | name of the type to import

Return Value

Type | Description
RfcType | the imported type

Events

CallFinished

This event is fired when an asynchronous call has returned from the system


RfcSession

Description

This object represents a session using the SAP RFC protocol, and implements all methods and properties of Session.

Note: To use RfcSession, you must have LIBRFC32.DLL in your path (e.g. in C:\WINDOWS\SYSTEM32). This library is NOT included with RFC Connector, since it is copyrighted by SAP. If you install SAPGUI or the RFC SDK, LIBRFC32 is automatically installed. SAP customers can obtain these installs from the SAP Service Marketplace.

Properties

Name | Type | Description | Read-only
RfcSystemData | RfcSystemData | connection data for this session |

Method Summary

Method | Description
GetSSO2Ticket | Retrieves an SSO2 ticket from the SAP system

Method Details

GetSSO2Ticket

Retrieves an SSO2 ticket from the SAP system

Parameters

none

Return Value

Type | Description
string | the MYSAPSSO2 ticket, which can be used with BSPApplication objects


SoapSession

Description

This object represents a session using the SOAP protocol.

This component uses the PocketSOAP library written by Simon Fell, which is licensed under the MPL. See http://pocketsoap.com for details.

Properties

Name | Type | Description | Read-only
HttpSystemData | HttpSystemData | connection data for this session |


Licensing and Support

For support options and licensing options, check out our website at

http://rfcconnector.com