The following query concatenates the columns results for each row. I need to separate columns with either some kind of delimiter or unique row[i]
results.
Query: "exec rfc_read_table @query_table='VBAK', @rowcount=50, @FIELDS= '<FIELDS><RFC_DB_FLD xmlns="http://Microsoft.LobServices.Sap/2007/03/Types/Rfc/"><FIELDNAME>MANDT</FIELDNAME></RFC_DB_FLD><RFC_DB_FLD xmlns="http://Microsoft.LobServices.Sap/2007/03/Types/Rfc/"><FIELDNAME>VBELN</FIELDNAME></RFC_DB_FLD></FIELDS>,@fields=@flds output'"
.NET
using (SAPCommand cmd = conn.CreateCommand())
{
cmd.CommandText = //See query above
SAPDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.Write(" {0} ", rdr[0]);
//Console.Write(" {0} ", rdr[1]);//null...
Console.WriteLine();
}
UPDATE
I am able to separate the columns by following the indexes returned by
DataTable dtFields = (DataTable)cmd.Parameters["@flds"].Value;
(updated query)
The process is so clunky and tosses up exceptions because the indexes become unreliable when the last columns in the query return empty results (also found a length indicator that was wrong). I worked around most of it, but this is so bad. Is there a better supported method to query SAP with .NET?