Please also have a look in our OnlineHelp for further information.
The first sample (RFC Server) only showed the exchange of scalar parameters. The following sample shows how to exchange tables between SAP and .NET using a RFC server.
A table with name NUMBERS is added to the Z_ADD function and the function is renamed to Z_ADD_2. All entries in table NUMBERS in column NUMB should be added by the .NET program.
The code below shows how to initialize the RFCServer object. Please have a close look on how to create the table NUMBERS. It is added to the Tables collection. The column NUMB is added to the empty Columns collection with Add(…).
The handling of the tables is done as always. We are using the object hierarchy to iterate through the rows and add the values. The result is returned in the scalar export parameter RES.
Here is the sample ABAP code to call the function in a foreign destination.
REPORT zaddtest2 . DATA res TYPE i. DATA numbs LIKE zaddstruc OCCURS 0 WITH HEADER LINE. numbs-numb = '1'. APPEND numbs. numbs-numb = '2'. APPEND numbs. numbs-numb = '3'. APPEND numbs. CALL FUNCTION 'Z_ADD_2' DESTINATION 'ERPTEST' IMPORTING res = res TABLES numbers = numbs. WRITE: / 'Result: ', res.