cancel
Showing results for 
Search instead for 
Did you mean: 

Sample using NCo 3.0 with VS2010

Former Member
0 Kudos

Hello.

Please, when can I get a practical sample code or project of a webform or windows form (VS2010) using SAP Net Connector 3.0?

I need a sample for create a connection to a R/3 server instance, call a RFC FM for get data for a Z table or get parameters, and close the connection. Only need a sample, please. I dont know how start a NCo project.

I have VS2010 and NCO 3.0 already installed. Please, your cooperation.

Thanks in advance,

Best regards.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi..

Here i am giving a small code which contains the following scenario:

Whenever u login to SAp through .NET, in the page load you will all the packages in ABAP. When u click on button1, the programs list will be display checklistbox which contains in the package. When you select the button2, the programs will be display in the list view.

Here is the COde:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using SAP.Middleware.Connector;

using System.Data.SqlClient;

namespace Code_Optimization

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void panel1_Paint(object sender, PaintEventArgs e)

{

}

public class MyBackendConfig : IDestinationConfiguration

{

public RfcConfigParameters GetParameters(String destinationName)

{

if ("SE38".Equals(destinationName))

{

RfcConfigParameters parms = new RfcConfigParameters();

parms.Add(RfcConfigParameters.AppServerHost, "192.168.1.14");

parms.Add(RfcConfigParameters.SystemNumber, "02");

parms.Add(RfcConfigParameters.User, "abaper");

parms.Add(RfcConfigParameters.Password, "erp@1234");

parms.Add(RfcConfigParameters.Client, "800");

parms.Add(RfcConfigParameters.Language, "EN");

parms.Add(RfcConfigParameters.PoolSize, "5");

parms.Add(RfcConfigParameters.MaxPoolSize, "10");

parms.Add(RfcConfigParameters.IdleTimeout, "600");

return parms;

}

else return null;

}

public bool ChangeEventsSupported()

{

return false;

}

public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;

}

private void Form1_Load(object sender, EventArgs e)

{

RfcDestinationManager.RegisterDestinationConfiguration(new MyBackendConfig());

RfcDestination prd = RfcDestinationManager.GetDestination("SE38");

RfcRepository repo = prd.Repository;

IRfcFunction companyBapi = repo.CreateFunction("ZBAPI_PACKAGE_GETLIST");

companyBapi.Invoke(prd);

IRfcTable address = companyBapi\"ZPACKAGE\".GetTable();

for (int index = 0; index < address.RowCount; ++index)

{

comboBox1.Items.Add(addressindex\"DEVCLASS\".GetString());

}

}

private void button1_Click(object sender, EventArgs e)

{

checkedListBox1.Items.Clear();

RfcDestination prd = RfcDestinationManager.GetDestination("SE38");

RfcRepository repo = prd.Repository;

IRfcFunction companyBapi1 = repo.CreateFunction("ZBAPI_PACKAGE_OBJECTLIST");

string package = "EU_" + comboBox1.SelectedItem.ToString();

companyBapi1.SetValue("PACKNAME", package);

companyBapi1.Invoke(prd);

IRfcTable address1 = companyBapi1\"TOBJECTS\".GetTable();

if (address1.RowCount != 0)

{

for (int index = 0; index < address1.RowCount; ++index)

{

checkedListBox1.Items.Add(address1index\"PROGRAM\".GetString());

panel2.Visible = true;

}

}

else

{

MessageBox.Show("No Programs Found");

}

}

private void button2_Click(object sender, EventArgs e)

{

listView1.Visible = true;

listView1.Items.Clear();

RfcDestination prd = RfcDestinationManager.GetDestination("SE38");

RfcRepository repo = prd.Repository;

IRfcFunction companyBapi1 = repo.CreateFunction("ZBAPI_GET_PROGRAM_DETAILS");

companyBapi1.SetValue("PROGRAM", checkedListBox1.SelectedItem.ToString());

companyBapi1.Invoke(prd);

IRfcTable address1 = companyBapi1\"PROGDET\".GetTable();

for (int index = 0; index < address1.RowCount; ++index)

{

listView1.Items.Add(address1index\"STRING\".GetString());

}

}

}

}

Former Member
0 Kudos

Hello to everybody.

Check this link:

http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/

and this:

http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/

I tested the client application and it works perfectly.

Regards!

0 Kudos

Hi, I need just the connectivity to ECC 6 from vs210 using nco 3.0.

Kindly share the solution using c#

Thanks in advance.

regards

Sadiq

roland_giger
Explorer
0 Kudos

hi

you can find a example from me by

http://www.sdn.sap.com/irj/scn/weblogs?blog=/cs/user/view/cs_msg/78366

please give me feedback, when it is successfully.

regards

Roland

vincent_vaurette
Discoverer
0 Kudos

Hi

any news on this ? i'm checking for a simple example

which references to add to the .net project, how to create the connexion to SAP server, how to launch a simple RFC query

thanks & regards

Vince

Former Member
0 Kudos

Please...