cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Microsoft .NET Data Provider for mySAP in VS 2003

Former Member
0 Kudos

Hi All,

I am trying to use Microsoft .NET Data Provider for mySAP with Visual studio 2003.

it's working fine with SQL 2005 import/Export wizard .but what is the proper way to use this adaptor to connect SAP using C#.

When i try to add reference for Microsoft.Adapter.SAP.SAPProvider.dll.I am getting Invalid assembly and component.

Their is different objects (SAPConnection,SAPCommand)in the code but i am not able to locate their reference .

I am hoping to get some some comments on this soon.

Thanks in advance,

Regards,

.NET Code

The following is an example of .NET code that illustrates how to invoke a BAPI (in this example) and retrieve the results:

<i>SAPConnection con = new SAPConnection("ASHOST=<SAPserver>; CLIENT=<client>;SYSNR=<sysnr>;USER=<user>;PASSWD=<password>;LANG=<logon language>");
con.Open();
SAPCommand cmd = new SAPCommand(con);
cmd.CommandText = "EXEC BAPI_CUSTOMER_GETLIST @IDRANGE=@param OUTPUT";

SAPParameter param = new SAPParameter("@param", ParameterDirection.InputOutput);
DataTable dt = new DataTable();
dt.Columns.Add("SIGN");
dt.Columns.Add("OPTION");
dt.Columns.Add("LOW");
dt.Columns.Add("HIGH");
DataRow row = dt.NewRow();
row["LOW"] = 1;
row["HIGH"] = 1000;
dt.Rows.Add(row);
param.Value = dt;
cmd.Parameters.Add(param);

SAPDataReader dr = cmd.ExecuteReader();
          
//retrieving returned datareaders
   do
     {
      Console.WriteLine("value of returned datareader: " +  dr.GetSchemaTable().TableName);
        while (dr.Read())
          {
            string line = "";
            for (int i = 0; i < dr.FieldCount; i++)
            line = line + "| " + dr.GetValue(i).ToString();
            Console.WriteLine(line);
           }
       }
       while (dr.NextResult());
       Console.WriteLine("Checking returned value of parameter @IDRANGE...");
        DataTable dt1 = (DataTable)param.Value;
            foreach (DataRow row1 in dt1.Rows)
            {
                string line = "";
                for (int i = 0; i < dt1.Columns.Count; i++)
                    line = line + "| " + row1<i>.ToString();
                Console.WriteLine(line);
            }</i>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shahbaz,

How are you doing ?

A simpler way to connect to a SAP system using VS 2003 would be to use the SAP .NET connector v 2.01

It has a gr8 proxy generator, which will do all the data structure tasks for you, leaving you to concentrate on the functionality, rather than the plumbing.

I would highly recommend you try the .NET connector NCo, as the help / documentation available is of good quality.

the development centre has all the tools required for self help, and additionally there is a whole community of users who will do their best to help ...

https://www.sdn.sap.com/irj/sdn/developerareas/dotnet?rid=/webcontent/uuid/3ecbe347-0a01-0010-5897-d... [original link is broken]

with respect,

amit

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Shahbaz,

How are you doing ?

I wanted to download the tool to get familiar with it, so that i could help out with querries on the tool here.

the document specifies that the tool is available for download.

The Microsoft .NET Data Provider for mySAP Business Suite is not included in SQL Server 2005, you must download it from http://msdn.microsoft.com/downloads/.

however i could not find it there or in the SQL server download page.

Please provide me with a link to be able to download the tool in order to be able to help developers use the tool efficently.

with respect,

amit

JayChan
Active Participant
0 Kudos

Hi Amit,

you could find the download on this hyperlink

Link:[http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=50b97994-8453-4998-8226-fa42ec403d17]

Former Member
0 Kudos

Hi Shahbaz,

How are you doing ?

reading from :-

http://msdn2.microsoft.com/en-us/library/ms141761.aspx

This is a connector which will effectively make an SAP system be viewed like any other SQL server / DB

It will allow you to use SQL commands to extract data.

To learn more about the functions avaliable on the SAP side, I would strongly recommend you install the SAP.NET connector, that will give you a design time knowledge of which rfc / bapi's you can consume.

alternatively, you could log on to the SAP system

and use the transactions bapi, se37 to learn more on the functions that you wish to consume.

se16 and se11 will tell you about the tables available.

also it is not recommended to directly perform transactions on tables in the SAP world, due to the high sensetivity / dependancies of the data and the programs which form the std functionality.

with respect,

amit