SapQuery Bean
Properties Methods Events Configuration Settings Errors
The SapQuery provides an easy way to execute queries on a remote R/3 (NetWeaver) system.
Syntax
InERP.Sapquery
Remarks
The purpose of this bean is to make executing a query on a SAP server extremely simple.
There are just a few steps you need to make before you can begin executing a query: first you set your connection credentials and connect to the SAP system (see Setting Up a Connection with a SAP System for details). Next set the QueryName as well as the UserGroup and WorkSpace and then call GetQueryInfo to populate the QueryFields and Selection Parameters. Once populated, you can then set the Selection Parameters and QueryFields you want and then call ExecuteQuery. This will populate the Query Result Rows, and the QueryResultRowIndex and QueryResultColumns can be used to access the results.
The following example shows how to execute a query on the SAP system. First we provide login credentials and connect.
SapClient1.SapConnection.ConnectionType = ConnectionTypes.ctNetWeaver; SapClient1.SapConnection.Client = "000"; SapClient1.SapConnection.Destination = ""; SapClient1.SapConnection.Host = "localhost"; SapClient1.SapConnection.User = "BCUSER"; SapClient1.SapConnection.Password = "minisap"; SapClient1.SapConnection.SystemNumber = 0; SapClient1.OpenConnection();Note that the credentials above are for connecting to a trial NetWeaver installation. You will need to provide your own credentials when connecting to your own SAP installation.
Now we need to specify the query we want to execute and get the information about the query from the SAP system using
the method GetQueryInfo.
SapQuery1.UserGroup = "/SAPQUERY/QD"; SapQuery1.QueryName = "CONNECTIONS_02"; SapQuery1.WorkSpace = SapqueryWorkSpaces.wsGlobalArea; SapQuery1.GetQueryInfo();Now that you have retrieved the structure of the query, you may set the Selection Parameters as you see fit and then call ExecuteQuery.
SapQuery1.MaxRows = 100; SapQuery1.SelectionParameterIndex = 0; SapQuery1.SelectionParameterRanges.Add(new QueryRange("NW", "AC", RangeOptions.roBetween, Signs.snInclude)); SapQuery1.ExecuteQuery();The results of executing the query "CONNECTIONS_02" are now contained in the Query Result Rows starting at QueryResultRowIndex 0, and may be accessed like this:
for (int i = 0; i < query.QueryResultRowCount; ++i) { SapQuery1.QueryResultRowIndex = i; foreach (SapColumn col in SapQuery1.QueryResultColumns) { Console.Write("{0}\t", col.Value); } Console.WriteLine(); }The above code will output something very similar to this:
Dependency Notes
If the bean is not configured to use the SOAP interface, it will use the sapnwrfc.dll, librfc32.dll, librfc32u.dll, or the Java Connector (JCo) to connect to the SAP system. Although the Java Connector is only available when programming in Java on Windows.
The NetWeaver RFC SDK (sapnwrfc.dll) offers both a 32 bit and 64 bit version. Likewise, the SAP RFC SDK offers as 32 bit and 64 bit version of both a unicode (librfc32u.dll) and non-unicode (librfc32.dll) library.
The NetWeaver RFC SDK will be used if the ConnectionType is set to ctNetWeaver (0). The following libraries from the NetWeaver RFC SDK must be available at runtime:
- sapnwrfc.dll
- icudt30.dll
- icuin30.dll
- icuuc30.dll
- libicudecnumber.dll
- libsapucum.dll
The non-unicode library will be used if the ConnectionType is set to ctClassic (1). This simply requires that the librfc32.dll be placed in a location that is accessible at runtime. (0).
The unicode library will be used if the ConnectionType is set to ctClassicUnicode (2). The following libraries from the SAP RFC SDK must be available at runtime:
- librfc32u.dll
- icudt30.dll
- icuin30.dll
- icuuc30.dll
The Java Connector (JCo) will be used if the ConnectionType is set to ctJavaConnector (4). In order to use this, you must first add the sapjco3.jar file to your project.
The 32 bit and 64 bit versions do not require any special settings within the beans. The only requirement is that your application target the same platform as the DLL.
Property List
The following is the full list of the properties of the bean with short descriptions. Click on the links for further details.
Connected | Indicates whether or not the component is connected to the SAP system. |
MaxRows | Max number of rows in the query result. |
QueryFields | The fields returned by GetQueryInfo. |
QueryMetaDatas | The meta data for the query. |
QueryName | The name of the query. |
QueryResultColumns | Columns of the current QueryResultRow . |
QueryResultRowCount | The number of rows returned. |
QueryResultRowData | The raw binary data of the current row. |
QueryResultRowIndex | The index of the current row in the query results. |
QueryUserGroups | The user groups for the query. |
SapAttributes | Describes the SAP R/3 system you're connected to. |
SapConnection | These properties are used to connect to the SAP system. |
SelectionParameterCount | The number of the selection parameters. |
SelectionParameterDataType | The data type of the current selection parameter. |
SelectionParameterDescription | The description of the current selection parameter. |
SelectionParameterFieldName | The field name of the current selection parameter. |
SelectionParameterIndex | The index of the current selection parameter. |
SelectionParameterLength | The length of the current selection parameter. |
SelectionParameterName | The name of the current selection parameter. |
SelectionParameterRanges | Query ranges of current selection parameter. |
SelectionParameterType | The kind of the current selection parameter. |
SSLAcceptServerCert | Instructs the component to unconditionally accept the server certificate that matches the supplied certificate. |
SSLCert | The certificate to be used during SSL negotiation. |
SSLServerCert | The server certificate for the last established connection. |
Timeout | Length of time in seconds the component waits for a response from the SAP system. |
UserGroup | The name of the user group. |
Variant | Variant value of the Query. |
WorkSpace | Work Area of the Query. |
Method List
The following is the full list of the methods of the bean with short descriptions. Click on the links for further details.
abortConnection | Used to terminate a connection to the SAP system. |
closeConnection | Closes a connection to the SAP system. |
config | Sets or retrieves a configuration setting . |
doEvents | Processes events from the internal message queue. |
executeQuery | Execute the query. |
getAttributes | Retrieves attributes about the SAP system you're currently connected to. |
getQueryInfo | Get Query information. |
interrupt | Interrupt the current method. |
openConnection | Opens a connection to the SAP system. |
reset | Resets the component to its initial state. |
retrieveQueries | Retrieves queries from the user group. |
retrieveUserGroups | Retrieves user groups. |
Event List
The following is the full list of the events fired by the bean with short descriptions. Click on the links for further details.
Error | Information about errors during data delivery. |
SSLServerAuthentication | Fired after the server presents its certificate to the client. |
SSLStatus | Shows the progress of the secure connection. |
Status | Detailed status messages for debugging purposes. |
Configuration Settings
The following is a list of configuration settings for the bean with short descriptions. Click on the links for further details.
LogPerformanceData | Logs the performance information when a function is called. |
LogRawData | Logs the raw data being sent and received. |
ParseTables | Indicates whether to parse tables into rows and columns. |
ResponseParamText[i] | The value of the PARAMTEXT for the specified reponse parameter. |
RequestParamText[i] | The value of the PARAMTEXT for the specified request parameter. |
Group | The logon group. |
MessageServer | Service name of load balancer service. |
SncLibPath | The external security product's library. |
SncMode | The SNC activation indicator. |
SncName | The Initiator's SNC name. |
SncPartnerName | The communication partner's SNC name. |
SncQop | The quality of protection level. |
SystemID | The system ID of the SAP system. |
LocalHost | The IP address of the local interface. |
ProxyAutoDetect | Whether or not to automatically detect and use proxy system settings, if available. |
ProxyAuthorization | The authorization string to be sent to the proxy server. |
ProxyAuthScheme | The authorization scheme to be used for the proxy. |
ProxyPassword | A password if authentication is to be used for the proxy. |
ProxyPort | Port for the proxy server (default 80). |
ProxyServer | Name or IP address of a proxy server (optional). |
ProxyUser | A user name if authentication is to be used for the proxy. |
FirewallAutoDetect | Tells the component whether or not to automatically detect and use firewall system settings, if available. |
FirewallHost | Name or IP address of firewall (optional). |
FirewallPassword | Password to be used if authentication is to be used when connecting through the firewall. |
FirewallPort | The TCP port for the FirewallHost;. |
FirewallUser | A user name if authentication is to be used connecting through a firewall. |
FirewallType | Determines the type of firewall to connect through. |
CodePage | The system code page used for Unicode to Multibyte translations. |