SapReadTable Class
Properties Methods Events Configuration Settings Errors
The SapReadTable provides an easy way to read a table hosted on a remote R/3 (NetWeaver) system.
Class Name
InERP_SapReadTable
Procedural Interface
inerp_sapreadtable_open(); inerp_sapreadtable_close($res); inerp_sapreadtable_register_callback($res, $id, $function); inerp_sapreadtable_get_last_error($res); inerp_sapreadtable_get_last_error_code($res); inerp_sapreadtable_set($res, $id, $index, $value); inerp_sapreadtable_get($res, $id, $index); inerp_sapreadtable_do_abortconnection($res, $errormessage); inerp_sapreadtable_do_closeconnection($res); inerp_sapreadtable_do_config($res, $configurationstring); inerp_sapreadtable_do_doevents($res); inerp_sapreadtable_do_getattributes($res); inerp_sapreadtable_do_interrupt($res); inerp_sapreadtable_do_openconnection($res); inerp_sapreadtable_do_querytablefields($res); inerp_sapreadtable_do_readtable($res); inerp_sapreadtable_do_reset($res);
Remarks
The purpose of this class is to make reading a table that is hosted on a SAP server extremely simple.
There are just a few steps you need to make before you can begin reading tables: First you set your connection credentials and connect to the SAP system (see Setting Up a Connection with a SAP System for details). Then you will need to retrieve the table fields by calling QueryTableFields. Then set the QueryFields with the fields that you would like to query and the QueryOptions with any options you would like to set. Then call ReadTable and after the method successfully returns, ResultRowCount ResultRowData, and ResultColumns will be populated.
The following example shows how to read a table hosted on the SAP server. First we provide login credentials
and connect.
SapClient1.SapConnectionConnectionType = ctNetWeaver SapClient1.SapConnectionClient = "000" SapClient1.SapConnectionDestination = "" SapClient1.SapConnectionHost = "localhost" SapClient1.SapConnectionUser = "BCUSER" SapClient1.SapConnectionPassword = "minisap" SapClient1.SapConnectionSystemNumber = 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 you will need to provide the TableName that you wish read and then call QueryTableFields.
readTable.TableName = "ZCARS"; readTable.QueryTableFields(); Console.WriteLine("Name \tLength \tColumnType \tValue"); for (int i = 0; i < readTable.TableFields.Count; ++i) { SapColumn col = readTable.TableFields[i]; if (col.ColumnType == ColumnTypes.ctPackedDecimal) Console.WriteLine(col.Name + "\t" + col.Length + "\t" + col.ColumnType + "\t" + readTable.Config("TableFieldDecimal=" + i)); else Console.WriteLine(col.Name + "\t" + col.Length + "\t" + col.ColumnType + "\t" + col.Value); }After you have the TableFields you will need to select which fields you would like to query as well as select any additional options you would like to use before reading the table.
readTable.QueryFields = "CLIENT,CATEGORY"; readTable.QueryOptions = "CLIENT = '000' ,AND CATEGORY = 'A'"; readTable.ReadTable();To read the you would need to do something like this:
for (int i = 0; i < readTable.ResultRowCount; ++i) { readTable.ResultRowIndex = i; for (int j = 0; j < readTable.ResultColumns.Count; ++j) { SapColumn col = readTable.ResultColumns[j]; Console.Write(col.Value + "\t"); } Console.WriteLine(); }The above code will output something very similar to this:
000 A 000 A 000 A
Dependency Notes
If the class 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 SapConnectionType 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 SapConnectionType 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 SapConnectionType 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 SapConnectionType 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 classs. 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 class with short descriptions. Click on the links for further details.
Connected | Indicates whether or not the component is connected to the SAP system. |
MaxRows | The maximum number of rows. |
QueryFields | The fields to be queried. |
QueryOptions | Selection criteria for reading table lines. |
ResultColumnCount | The number of records in the ResultColumn arrays. |
ResultColumnType | The type of the column. |
ResultColumnLength | The maximum length of the data stored in Value . |
ResultColumnName | The name of the column. |
ResultColumnTableIndex | This should be set if the ColumnType is set to ctTable. |
ResultColumnValue | This is the actual data contained in the column. |
ResultRowCount | The total number of rows retrieved. |
ResultRowData | The raw binary data that makes up a row. |
ResultRowIndex | The index of the current row. |
RowOffset | The number of rows to be offset. |
SapAttributeApplicationName | The name of the calling program. |
SapAttributeClient | The client authenticating to the SAP system. |
SapAttributeDestination | Destination that you are currently connected to. |
SapAttributeKernelVersion | The release version of the kernel. |
SapAttributeLanguage | One character code indicating the language of the system. |
SapAttributeLanguageCode | Two-character ISO 639-1 code indicating the language of the system. |
SapAttributeOwnCodePage | The code page of your system. |
SapAttributeOwnHost | The name of the host you're connected to. |
SapAttributeOwnType | The type of your own system. |
SapAttributeOwnVersion | The release version of your system. |
SapAttributePartnerCharSize | The length of a character on the partner's system. |
SapAttributePartnerCodePage | The code page of your partner's system. |
SapAttributePartnerHost | Partner host name. |
SapAttributePartnerType | The type of the partner's system. |
SapAttributePartnerVersion | The release version of the partner's system. |
SapAttributePasswordState | The state of the password. |
SapAttributeReserved | This property may contain an additional 160 bytes of data which is reserved for future new attributes returned by the R/3 server. |
SapAttributeRole | Indicates whether you're connected as a client or server application. |
SapAttributeSystemName | The name or id of the R/3 system you're currently connected to. |
SapAttributeSystemNumber | The system number of the R/3 server you're connected to. |
SapAttributeTraceOn | Indicates whether debug tracing is active or not. |
SapAttributeUser | The login credential which was used to connect to the R/3 server. |
SapConnectionClient | The client authenticating to the SAP system. |
SapConnectionType | Specifies how the connection is made to the SAP server. |
SapConnectionDestination | Reference to an existing destination that is specified in a local saprfc. |
SapConnectionGatewayHost | The gateway host you wish to connect to. |
SapConnectionGatewayService | The gateway service you wish to connect to. |
SapConnectionHost | Host name of the target system. |
SapConnectionLanguage | The language value to be used when connecting SAP system. |
SapConnectionPassword | The password used to authenticate to the SAP system. |
SapConnectionSoapURL | The URL of the SOAP service on the SAP system. |
SapConnectionSystemNumber | The number by which the target system is defined. |
SapConnectionUser | The user that is authenticating to the SAP system. |
SSLAcceptServerCertEncoded | The certificate (PEM/base64 encoded). |
SSLCertEncoded | The certificate (PEM/base64 encoded). |
SSLCertStore | The name of the certificate store for the client certificate. |
SSLCertStorePassword | If the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store. |
SSLCertStoreType | The type of certificate store for this certificate. |
SSLCertSubject | The subject of the certificate used for client authentication. |
SSLServerCertEncoded | The certificate (PEM/base64 encoded). |
TableFieldCount | The number of records in the TableField arrays. |
TableFieldType | The type of the column. |
TableFieldLength | The maximum length of the data stored in Value . |
TableFieldName | The name of the column. |
TableFieldTableIndex | This should be set if the ColumnType is set to ctTable. |
TableFieldValue | This is the actual data contained in the column. |
TableName | The name of the table you wish to query. |
Timeout | Length of time in seconds the component waits for a response from the SAP system. |
Method List
The following is the full list of the methods of the class 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. |
GetAttributes | Retrieves attributes about the SAP system you're currently connected to. |
Interrupt | Interrupt the current method. |
OpenConnection | Opens a connection to the SAP system. |
QueryTableFields | Retrieves all fields meta data for a table. |
ReadTable | Retrieves the table data. |
Reset | Resets the component to its initial state. |
Event List
The following is the full list of the events fired by the class 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 class with short descriptions. Click on the links for further details.
TableFieldDecimal | Decimal value of table field. |
CustomReadTableFunction | Custom ReadTable function. |
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. |