Anfang des Inhaltsbereichs

Funktionsdokumentation Data Binding with SAPClient Dokument im Navigationsbaum lokalisieren

SAPTables implement the proper .NET interfaces that allow them to be data-bound to any .NET data aware control such as a data grid, combo-box or list control. To databind to a .NET control set the datasource property to the name of the SAP table.

 

dataGrid1.DataSource = BRFCKNA1Table1;

 

In Windows forms there is no need to call this.Databind() but you must do so in ASP .NET datagrid to update the datagrid.

 

Coding Recommendations for SAPTable Parameters in Your Code

·        Pass OUTPUT Tables uninitialized

If you do not need all TABLE parameters you can remove them from the RFC signature in the Visual Studio .NET designer. This only works when the table is also OPTIONAL.

For example, to call RFC_CUSTOMER_GET which has an OUTPUTtable of customer records, the table variable tblCust is passed unitialized.

 

SAPProxy1  proxy = new SAPProxy1();

// create an SAP table but as it's an in parameter don't need to instantiate it for the rfc call BRFCKNA1Table tblCust = new BRFCKNA1Table();

using(proxy.Connection =  SAP.Connector.SAPConnectionPool.GetConnection(this.destination1.ConnectionString))                {

      // call the RFC with the signature defined by SAP proxy.Rfc_Customer_Get(CustNo, CustName, ref tblCust);

             }

 

·        Fill INPUT TABLES With Values

A TABLE is always passed by REF and is therefore both an IN and OUT parameter. Since a table is a collection you can fill it in a loop for example:

 

for(int i = 0; i < number_of_lines; i++)

{

        IDRANGE mySelection = new IDRANGE();

        IDRANGE.Sign = "I"

        IDRANGE.Option = "BT"

        IDRANGE.Low= "0000001000"

        IDRANGETable.Add(mySelection);

}

 

Alternatively you can create an additional constructor with the parameters you want to fill.

 

for(int i = 0; i < number_of_lines; i++)

{

        IDRANGETable.Add(new IDRANGE(“I”,”BT”,”0000001000”));

}

 

 

For TABLES that are input parameters you have to populate the values yourself before calling the SAP RFC. For TABLES that are output parameters the SAP marshalling code populates the values for you automatically.

·        Clearing Values From the Table

When an exception is returned, the TABLE object is not reinitialized. If you had made a previously successful method call and the TABLE contains values, these will not be reinitialized after an exception has occurred. In this case you can keep the last (good) results. You can use the table’s clear() method to initialize the values yourself.

·        Getting Runtime Information About the RFC TABLES

SAP Tables are built on the .NET CollectionBase class. Therefore they support indexers and other array operations to allow for easy management of the members in the array.

Field metadata information can be determined from the structure using the static method: GetSAPFieldsSchema(System.Type t).

The type parameter is the data type of SAPStructure (in this case the type of BAPICUSTOMER_IDRANGE).     

 

SAPField[ ] myFields = BAPICUSTOMER_IDRANGE.GetFieldsSchema(typeof(BAPICUSTOMER_IDRANGE));

 

You can get metadata information about each field either with a foreach statement or using the length property of the SAPField array.

 

Ende des Inhaltsbereichs