Closed jensweller closed 8 years ago
Hello,
You need to override the Parameters property. Take a look at this example.
public class SumOfTwoNumbersFunction : RfcFunctionObject<int>
{
public int First { get; private set; }
public int Second { get; private set; }
public int Total { get; private set; }
public SumOfTwoNumbersFunction(int first, int second)
{
this.First = first;
this.Second = second;
}
public override string FunctionName
{
get { return "Z_SSRT_SUM"; }
}
public override int GetOutput(RfcResult result)
{
return result.GetOutput<int>("e_result");
}
public override object Parameters
{
get
{
return new
{
i_num1 = this.First,
i_num2 = this.Second
};
}
}
}
And this is how you use it.
using (SapRfcConnection conn = GetConnection())
{
int value = conn.ExecuteFunction(new SumOfTwoNumbersFunction(2, 8));
Assert.Equal(10, value);
}
Oh sorry. After I posted this I found the solution. :-). Thanks for you description.
Hi
How is it possible to pass parameters like you do in your first example
var result = conn.ExecuteFunction("Z_SSRT_SUM", new { i_num1 = 2, i_num2 = 4 });
if I use the rfc funktion object like your example
var customers = conn.ExecuteFunction(new GetAllCustomersFunction());