-
Notifications
You must be signed in to change notification settings - Fork 14
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"RFC_READ_TABLE" #84
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. |
thanks, I know that RFC_READ_TABLE has some limitations and is not worth using but it is a good example for testing. M. |
I'm sorry, but I didn't get that. Do you mean in general how to fill input parameter? |
Yes, it's about the parameter SetTable(tableName , inputList , map) |
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);
} |
thanks for the help |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Can you give example how to use "RFC_READ_TABLE"
The text was updated successfully, but these errors were encountered: