huysentruitw / SapNwRfc

SAP NetWeaver RFC library for .NET 5, .NET Core and .NET Framework
MIT License
149 stars 43 forks source link

RFC_READ_TABLE -> get only one row for Table FIELDS #6

Closed masc-be closed 4 years ago

masc-be commented 4 years ago

first, thanks for this project (netcore and RFC). This is very helpful for my application. Unfortunately I still have a problem with the function "RFC_READ_TABLE". Maybe you can help faster. I have declared 2 classes, which represent the input and the output. They represent completely (without exceptions) the tables and parameters of the Fuba himself. But if I look at the result then I can not cleanly resolve the entries from DATA->WA. The 4 important parameters FIELDS->TYPE, FIELDS->FIELDNAME, FIELDS->OFFSET and FIELDS->LENGTH are not completely present. There is always only one entry regardless of the number of columns you want.

Example:

public class ClassRfcReadTableInput
{
        [SapName("QUERY_TABLE")]
        public string QueryTable { get; set; }

        [SapName("DELIMITER")]
        public string Delimiter { get; set; }

        [SapName("NO_DATA")]
        public string NoData { get; set; }

        [SapName("FIELDS")]
        public RFC_DB_FLD[] Fields { get; set; }

        [SapName("OPTIONS")]
        public RFC_DB_OPT[] Options { get; set; }
}

public class ClassRfcReadTable
{
        [SapName("QUERY_TABLE")]
        public string QueryTable { get; set; }

        [SapName("DELIMITER")]
        public string Delimiter { get; set; }

        [SapName("NO_DATA")]
        public string NoData { get; set; }

        [SapName("ROWSKIPS")]
        public int RowSkips { get; set; }

        [SapName("ROWCOUNT")]
        public int RowCount { get; set; }

        [SapName("FIELDS")]
        public RFC_DB_FLD[] Fields { get; set; }

        [SapName("OPTIONS")]
        public RFC_DB_OPT[] Options { get; set; }

        [SapName("DATA")]
        public TAB512[] Data { get; set; }
 }

and the execution:

ClassRfcReadTableInput fc = new ClassRfcReadTableInput();
fc.QueryTable = table; // maybe "MAPL"  or other tables
fc.Delimiter = "↨"; // an exotic delimiter :-)
fc.NoData = "";

// fill the fields and option tables
string fields  = "PLNNR;PLNTY;PLNAL" // for the example with table MAPL
string[] af = fields.Split(';');
fc.Fields = new RFC_DB_FLD[af.Length];
for (int i = 0; i < af.Length; i++)
{
    fc.Fields[i] = new RFC_DB_FLD();
    fc.Fields[i].Fieldname = af[i];
}
string filter = ""MATNR = ' ????? ' AND WERKS = ' ????  '; AND ( PLNTY = 'N' OR PLNTY = 'S' )" // as example 
string[] ao = filter.Split(';');
if (ao != null && ao.Length > 0) fc.Options = new RFC_DB_OPT[ao.Length]; 
for (int i = 0; i < ao.Length; i++)
{
    fc.Options[i] = new RFC_DB_OPT();
    if (!string.IsNullOrEmpty(ao[i]))
    {
        if (ao[i].Length > 72)
        {
            throw new Exception("Error by rfc_read_table:; an option string is longer as 72 -> " + ao[i]);
        }
        fc.Options[i].Text = ao[i];
    }
}
using var func = dest.CreateFunction("RFC_READ_TABLE");
ClassRfcReadTable data = func.Invoke<ClassRfcReadTable>(fc);

data.Data.Wa: is fine. data.Fields: has only one entry. If you specify 3 columns, 3 entries would also be normal.

huysentruitw commented 4 years ago

Can you run your code while setting a breakpoint at this point ?

Before you do this, I would temporarely remove the Data and Options arrays from the output model, so only the Fields array needs to be read as a table. After that, check what value you're getting back as rowCount.

masc-be commented 4 years ago

Thank you ... for the quick Response. I will try in the next days so i find some free moments. To debug the source i have to implement that first. ;-)

huysentruitw commented 4 years ago

Hi, were you already able to debug this?

huysentruitw commented 4 years ago

Since I haven't heard back, I'll be closing this issue as it is not clear what has to be fixed. When the problem persists, feel free to reopen the issue.