Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RFC & BAPI with Visual Studio 2010 (C/ C++)

Former Member
0 Likes
1,869

Hello,

I would to develop, into MS Visual Studio 2010 (c/ c+), a application that allows establishing a RFC connection to SAP (ECC6) and call a Z program, or call a BAPI from my c/c+ application.

Can you recommend a good documentation, possibly with examples?

If anyone has any sample code, maybe a project in MS VS (c/c++), would be great.

Sincerely,

Serena

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,436

Hi,

Hope the following code will help you.

For establishing connection:

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, "erpanderp");

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;

}

Getting tables from BAPI:

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(address1[index]["PROGRAM"].GetString());

panel2.Visible = true;

}

}

else

{

MessageBox.Show("No Programs Found");

}

}

Hello,

I would to develop, into MS Visual Studio 2010 (c/ c+), a application that allows establishing a RFC connection to SAP (ECC6) and call a Z program, or call a BAPI from my c/c+ application.

Can you recommend a good documentation, possibly with examples?

If anyone has any sample code, maybe a project in MS VS (c/c++), would be great.

Sincerely,

Serena

7 REPLIES 7
Read only

Former Member
0 Likes
1,436

Hi

This may help it is with C# i guess as i was not able to view the video

www.youtube.com/watch?v=8tVUVpbapCY

Browse this link you may get more information

http://help.sap.com/saphelp_nw04/helpdata/EN/51/d5470940fd564b888f4beb9523fa6c/frameset.htm

Thanks & Regards

Jayanth.Y

Read only

0 Likes
1,436

Thanks, Jayanth.Y!

I read this documentation, but development must be in C or C++. C # not know and I have little time available for development.

Serenaaa

Read only

0 Likes
1,436

Hi serenaaa ;

Which method do you use for connect to SAP from VS .net?

Connector 1

Connector 2

Connector 3

WebService

DLL/OCX

Best regards.

Read only

0 Likes
1,436

Thank you all.

I downloaded and installed the SAP.NetConnector 3.0, but honestly, I can not figure out how to create a project in MS Visual Studio 2010 c/c++? How to integrate these two environments? Where to start?

I would love to have an example of VC project. I am familiar with c/c++.

Serena

Read only

0 Likes
1,436

Hi;

1. There are some sample downloaded documents from SAP.

You can examine samples of C##. And you can convert to C++.

2. You can examine blog ( ) You may ask question to Blog owner.

I didn't find any sample within C++.

Best regards.

Read only

Former Member
0 Likes
1,437

Hi,

Hope the following code will help you.

For establishing connection:

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, "erpanderp");

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;

}

Getting tables from BAPI:

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(address1[index]["PROGRAM"].GetString());

panel2.Visible = true;

}

}

else

{

MessageBox.Show("No Programs Found");

}

}

Read only

0 Likes
1,436

Yout code is wrong, please see image below: