on 09-18-2007 4:43 PM
I'm looking for an example of how to call a SAP RFC from within a C#
program. I've tried numerous searches and have come up empty handed. If I have a function called "MyFunction" and it takes 1 input parameter and returns one output parameter (a table) how would it be coded. I have been able to code the connection and it works so once the connection is established I need to call the funcation. Any pointers are really appreciated. Environment is MS VS Developer 2003, Frameworks 1.1, SAP 4.6C Here is the code so far.
using System;
using SAP.Connector;
using SAP.Connector.Rfc;
using SAP.Connector.Internal;
namespace ConsoleApplication2
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
SAP.Connector.Destination dest = new SAP.Connector.Destination();
dest.AppServerHost = "NAFTATEST01.SAP.INTRA";
dest.Client = 300;
dest.SystemNumber = 0;
dest.Username = "myusername";
dest.Password = "mypassword";
SAP.Connector.SAPConnection connSAP = new
SAP.Connector.SAPConnection(dest);
using(connSAP)
{
try
{
connSAP.Open();
Console.WriteLine("SAP Connection was opened...");
connSAP.Close();
}
catch(SAP.Connector.RfcException rfcEx)
{
Console.WriteLine("SAP Connection was failed...");
Console.WriteLine( rfcEx.Message
+ rfcEx.StackTrace);
Console.WriteLine();
}
}
}
}
hi
Create a Windows Forms application.
Add an empty SAP Connection class with the ABAP functions
RFC_CUSTOMER_GET and RFC_CUSTOMER_UPDATE.
Leave the proxy designer open. Go to the SAP Proxy toolbox and drag the Proxy field icon to the designer.
Rename the new Field1 to Tab. Change the Type property to BRFCKNA1Table. To do this, use the drop down icon.
Note that the ReadOnly property automatically changes to true and the default value changes to new BRFCKNA1Table().
Add a second Proxy Field with the name Filter, the type String and the default value A*.
Select the Rfc_Customer_Get function and click on the button of the Parameters property.
Set the default values of the three parameters with the drop-down icon as follows:
Name1: Filter
Kunnr: Customer_T: _Tab
Save the proxy designer and switch to your Windows form. Add a TextBox, a Button and a DataGrid.
Add an instance of your SAP proxy to your Windows form, add a Destination and set the Connection property as described in A4.
Set the DataSource property of the datagrid to sapProxy11. Set the DataMember property of the datagrid to Tab. Alternatively you can set the DataSource to sapProxy11.Tab and leave the DataMember empty.
For textBox1 use the DataBinding feature to bind the Text property of the textbox to sapProxy11.Filter.
Double-click the button to create an event handler and add a single line:
this.sapProxy11.Rfc_Customer_Get_();
You are using sapProxy11 as a smart DataSet that contains the necessary state. You bind the state to the corresponding controls. The overload method Rfc_Customer_Get_() does not have any parameters, as the required state is already in the bound Proxy Fields.
above statments from standard helpfile,and
in my opinion you need
datagrid1.datasource = yourtable
regards
ajai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.