Skip to content
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

CallFunction: add a table row iterator function #15

Closed
fw2568 opened this issue Jun 13, 2019 · 0 comments · Fixed by #22
Closed

CallFunction: add a table row iterator function #15

fw2568 opened this issue Jun 13, 2019 · 0 comments · Fixed by #22
Labels
enhancement New feature or request
Milestone

Comments

@fw2568
Copy link
Contributor

fw2568 commented Jun 13, 2019

Getting values from table rows is currently quite complicated:

using (var context = new RfcContext(ConnFunc))
{
    await context.CallFunction("BAPI_COMPANYCODE_GETLIST",
        Output: func => func.BindAsync(f =>
            from companyTable in f.GetTable("COMPANYCODE_LIST")

            from row in companyTable.Rows.Map(s =>
              from code in s.GetField<string>("COMP_CODE")
              from name in s.GetField<string>("COMP_NAME")
              select (code, name)).Traverse(l => l)

        select row))
    .ToAsync().Match(
        r =>
            {
                foreach (var (code, name) in r)
                {
                    Console.WriteLine($"{code}\t{name}");
                }
            },
        l=> Console.WriteLine($"Error: {l.Message}"));
}

We should add a "MapStructure" method to simplify this:

using (var context = new RfcContext(ConnFunc))
{
    await context.CallFunction("BAPI_COMPANYCODE_GETLIST",
        Output: func => func.BindAsync(f =>
            from companyTable in f.GetTable("COMPANYCODE_LIST")

            from row in companyTable.MapStructure(s =>
              from code in s.GetField<string>("COMP_CODE")
              from name in s.GetField<string>("COMP_NAME")
              select (code, name))

        select row))
    .ToAsync().Match(
        r =>
            {
                foreach (var (code, name) in r)
                {
                    Console.WriteLine($"{code}\t{name}");
                }
            },
        l=> Console.WriteLine($"Error: {l.Message}"));
}
@fw2568 fw2568 added the enhancement New feature or request label Jun 13, 2019
@fw2568 fw2568 changed the title add a table row iterator function CallFunction: add a table row iterator function Jun 14, 2019
@fw2568 fw2568 added this to the next milestone Aug 7, 2020
@fw2568 fw2568 modified the milestones: next, Version 3.1 Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant