开发者

RFC_READ_TABLE concatenates columns in row results

The following query concatenates the columns results for each row. I need to seperate 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())
            {             开发者_JAVA百科           
                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 klunky 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?


it works for me.

ADD this --> in your script:

   @DELIMITER ='|'

"exec rfc_read_table @query_table='VBAK', @rowcount=50, @DELIMITER ='|', @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'"


Im not sure but in Version 3 of SAP .NET connector such problem should be resolved.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜