-
Can you give example how to use "RFC_READ_TABLE" |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
try this example: var clientTable = await context.CallFunction("RFC_READ_TABLE",
Input: f => f.SetField("QUERY_TABLE", "T000"),
Output: f =>
from fields in f.MapTable("FIELDS", s=>
from fieldname in s.GetField<string>("FIELDNAME")
from offset in s.GetField<int>("OFFSET")
from length in s.GetField<int>("LENGTH")
select new { fieldname, offset, length }
)
from lines in f.MapTable("DATA", s=>s.GetField<string>("WA"))
select lines.Map(line =>
fields.ToDictionary(field => field.fieldname, field =>
{
//special handling for last field, as nwrfc truncates string at end
var length = field.offset + field.length > line.Length
? line.Length - field.offset
: field.length;
return line.Substring(field.offset, length);
})
)
).IfLeftAsync(l=>throw new Exception(l.Message));
foreach (var row in clientTable)
{
foreach (var column in row)
{
Console.Write($"{column.Value}\t");
}
Console.WriteLine();
} However, as an ABAP developer, I can only advise you against using RFC_READ_TABLE. |
Beta Was this translation helpful? Give feedback.
-
thanks, I know that RFC_READ_TABLE has some limitations and is not worth using but it is a good example for testing. M. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry, but I didn't get that. Do you mean in general how to fill input parameter? |
Beta Was this translation helpful? Give feedback.
-
Yes, it's about the parameter SetTable(tableName , inputList , map) |
Beta Was this translation helpful? Give feedback.
-
Ok, yes I know the signature looks tricky ;-) in input list you pass a IEnumerable of any type. The mapping function map will then be called for any entry in inputList and with a new structure entry for the input table. here a sample that returns all users that starts with A, B, or C. var userNamesSearch = new string[] {"A*", "B*", "C*"};
var userList = await context.CallFunction("BAPI_USER_GETLIST",
Input:f => f.SetTable("SELECTION_RANGE", userNamesSearch , (structure,userName) => structure
.SetField("PARAMETER", "USERNAME")
.SetField("SIGN", "I")
.SetField("OPTION", "CP")
.SetField("LOW", userName)
),
Output: f=> f.MapTable("USERLIST", s=>s.GetField<string>("USERNAME"))
).IfLeftAsync(l=>throw new Exception(l.Message));
foreach (var userName in userList)
{
Console.WriteLine(userName);
} |
Beta Was this translation helpful? Give feedback.
-
thanks for the help |
Beta Was this translation helpful? Give feedback.
try this example: