Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

.NET connector: How to create a RfcTable in C# that is passed as a return value to SAP

Former Member
0 Kudos

First of all, I am not sure if I posted my question under the correct tag. So, if it should be wrong please advise me.

I created an RFC server in C# .net with the .NET connector. This works great for simple functions that return a string value. Now I have the following requirement for a function:

IMPORTING 
   VALUE(FI_T_VAL) TYPE YSSTRING_TT 
EXPORTING 
   VALUE(FE_T_VAL) TYPE YSSTRING_TT 
   VALUE(FE_ERROR) TYPE INT4

So, I have to provide a table as a return value but I have noe idea how to construct this in code. What I have is an IRfcFunction object on which I would like to call the following method:

SetValue(string name, IRfcTable table);

Can someone give a sample how to table a C# List<string> and ceate an object of type IRfcTable that contains the elements of that List<string>?

Any help is very much appreciated.

Regards,

Dirk.

1 ACCEPTED SOLUTION

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dirk,

did you already have a look at the tutorial, which is available from https://support.sap.com/nco? You simply fetch the table from the function and append all rows to it that should reflect the response

Best regards,
Markus

4 REPLIES 4

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dirk,

did you already have a look at the tutorial, which is available from https://support.sap.com/nco? You simply fetch the table from the function and append all rows to it that should reflect the response

Best regards,
Markus

Former Member
0 Kudos

Hi Markus,

thank you very much for your answer. I really appreciate it. Yes, I am aware of this tutorial. My program throws an RfcInvalidParameterException when executing the following line:

var rfcTable = function.GetTable(Consts.ResultTableName, true);

Const.ResultTableName is the string "RFCRESULT".

What I don't understand is: isn't it necessary to create the table beforehand (if yes, how?) or can I just call GetTable and give it an arbitrary name and SAP will create it?

My task is just to create a table with a single string column, populate some rows and pass the table as a return value.

Any ideas what I am doing wrong?

Regards,

Dirk.

Former Member
0 Kudos

The details of the RfcInvalidParameterException are:

Message: Element RFCRESULT of container metadata Y_S_PAN_ENCRYPT_LIST unknown

Error Code: 8


Y_S_PAN_ENCRYPT_LIST is my server function name.

Former Member
0 Kudos

Ah, now I understand. The table for the return value already exists and I don't have to create it myself. I can just get it by calling GetTable(FE_T_VALUE) and the populate it. I tried it and it worked.

So, thank you Markus for your support.

Regards,

Dirk.