Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between SAP and C#

Tags:

c#

I'm just a beginner and I'm trying to understand the communication between SAP and for example a C# application using the SAP-connector. I've searched numerous sites, but I really can't find an answer to my question! I hope someone here can help me.

I have a function in SAP for example getProducts(String = " "). This function works perfectly in SAP, it is not written by me and I don't have access to it so I can't give you any code (I'm sorry). I have to communicate with SAP using a C# application.

What I want to do is give SAP a parameter, for example "Shirts". And SAP will give back all the shirts. I can't do this with Function.GetValue() (or at least I think I can't) because GetValue only expects integers. But if I enter GetValue(0), it gives me all the products (which is normal) and not just the shirts.

This is the code I use to get the data:

IRfcFunction function = fRepository.CreateFunction("GetProducts");
function.Invoke(destination);
String products = function.GetValue(0).ToString();
result = Functions.Instance.GetData(result);

Is there a way to give a string parameter (instead of an integer, in this case 0) to the SAP-function and retrieve the data I want?

like image 597
Storm Avatar asked Sep 16 '11 12:09

Storm


1 Answers

If the GetProducts function takes a parameter called for instance Category, you can set that before invoking the function:

IRfcFunction function = fRepository.CreateFunction("GetProducts");
function.SetValue("Category", "Shirts");
function.Invoke(destination);

Check out the A Spotlight on the New .NET Connector 3.0 blog entry for more details, links and examples.

like image 108
Mat Avatar answered Sep 23 '22 09:09

Mat