Reputation: 61
I was already able to fetch data from SAP by calling a RFC into Excel Workbook using VBA. But now I like to do the same in an Excel AddIn (VSTO) with c#. There are little information about this. The microsoft.data.sapclient does not work really: https://msdn.microsoft.com/en-us/library/cc185499(v=bts.10).aspx
I first recognized that the RFC Exec command must be changed (token expected: Execute Function..). So I'm wondering if this documentation is old or something else changed? (Also explained in this question here: C# SapDataReader cmd.ExecuteReader() Error)
After this change I'm executing a simple RFC which updates a table - no import/export parameters, no tables. Even just executing this simple RFC ends in:
No results available for the given query command
Does anybody out there have solved this issue? Anyone has a proper working example?
My code is at the moment the following for the button on the custom task pane:
using System;
using System.Collections.Generic;
//using System.ComponentModel;
//using System.Drawing;
//using System.Data;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Data.SapClient;
namespace SupplierEvaluation
{
public partial class CTP_Uster_SupplierEvaluation : UserControl
{
public CTP_Uster_SupplierEvaluation()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string connstr = "ASHOST=Hostname; SYSNR=sysnr; CLIENT=client; LANG=EN; USER=username; PASSWD=password;";
using (SapConnection conn = new SapConnection(connstr))
{
conn.Open();
using (SapCommand cmd = (SapCommand)conn.CreateCommand())
{
cmd.CommandText = "EXECUTE Function ZTEST_RHE ";
using (SapDataReader dr = (SapDataReader)cmd.ExecuteReader())
{
}
conn.Close();
}
}
}
}
Upvotes: 0
Views: 331
Reputation: 3195
You can try using SQL Server Profiler to trace all calls made to the SQL Server, It will require priviliges on the server, impact server performance and you need to filter out your calls amongst all other calls.
Upvotes: 0