Getting two values from one request #231
-
Hi, I have a RFC that returns two values, but I cannot seem to figure out how to get two values from the output section. It seems only one .GetField("VALUE1") is possible....... was thinking something like: .GetField("VALUE1") How is that managed? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello, it is possible, as you can simply perform multiple mappings within one mapping function. See an enhanced version of the company code sample from readme: using (var context = new RfcContext(connFunc))
{
await context.CallFunction("BAPI_COMPANYCODE_GETDETAIL",
Input: f => f
.SetField("COMPANYCODEID", "1000"),
Output: f => f
.MapStructure("COMPANYCODE_DETAIL", s =>
from code in s.GetField<string>("COMP")
from name in s.GetField<string>("COMP_NAME")
select new { code, name }
))
.Match(r => Console.WriteLine($"Result: {r.code} - {r.name}"),
l => Console.WriteLine($"Error: {l.Message}"));
} So here both the code and the name are assigned to an anonymous type (it could also be a defined type) and returned. The key to understanding this is that you can map the output to any type. Hope this helps, Best Regards, |
Beta Was this translation helpful? Give feedback.
-
same logic, but directly on output mapping function: Output: f =>
from field1 in f.GetField<string>("FIELD1")
from field2 in f.GetField<string>("FIELD2")
select new { field1, field2 }
|
Beta Was this translation helpful? Give feedback.
same logic, but directly on output mapping function: