cancel
Showing results for 
Search instead for 
Did you mean: 

sap.net connector 3.0 example

Former Member
0 Kudos

Hey All,

I have gotten the NCo.net 3.0.....In the past I built a proof-of-concept to work on the old connector, but the new connector looks totally different. Is there any people out there with a simple connection and simple data retrieve from SAP server?

0 Kudos

Hello all,


I try to get this example to work, but it is not willing.

I get a Null Exception everytime I try call up

RfcConfigParameters

I tried to use a console file or something.

sapnco and sapnco_utils is installed and connected

Framework 4.0 (without Client is selected)

No more Ideas.

Maybe someone can help?

Best Regards

Mario

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Threading
Imports System.Reflection
Imports SAP.Middleware.Connector


Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim rfc As New RfcConfigParameters
        rfc.Add(RfcConfigParameters.Name, "Test")
        rfc.Add(RfcConfigParameters.AppServerHost, "123.456.789.123")
        rfc.Add(RfcConfigParameters.Client, "010")
        rfc.Add(RfcConfigParameters.User, "***")
        rfc.Add(RfcConfigParameters.Password, "***")
        rfc.Add(RfcConfigParameters.SystemNumber, "00")
        rfc.Add(RfcConfigParameters.Language, "DE")
        rfc.Add(RfcConfigParameters.PoolSize, "5")
        rfc.Add(RfcConfigParameters.PeakConnectionsLimit, "10")
        rfc.Add(RfcConfigParameters.ConnectionIdleTimeout, "600")

System.NullReferenceException
HResult=0x80004003
Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Source=sapnco
StackTrace:
at SAP.Middleware.Connector.RfcConfigParameters.LoadConfiguration()

Former Member
0 Kudos

I saw your posted comment. Please raise a new question and follow our rules of engagement: https://community.sap.com/resources/rules-of-engagement. I suggest using the "I have a similar question" option under the question to get started. Feel free to take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html. With these tips you'll be able to prepare questions that draw responses from our members.

Best,

Your SAP Community moderator

Accepted Solutions (0)

Answers (4)

Answers (4)

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

}

}

}

}

Former Member
0 Kudos

Hi,

I found for each connection, 2 session will be created in SAP. This should be expected or something wrong with my code?

Former Member
0 Kudos

Hi!!

How to get the column names alone from the table?

Former Member
0 Kudos

How do you pass in a parameter to the BAPI? I am getting an error on the createnewfunction when I try to call it before I set the parameters.

I am not invoking it yet, just trying to use create new function.

former_member197445
Contributor
0 Kudos

First, create a class that implements IDestinationConfiguration. VB.NET code shown below.

Imports SAP.Middleware.Connector

Public Class ECCDestinationConfig
    Implements IDestinationConfiguration

    Public Event ConfigurationChanged(ByVal destinationName As String, ByVal args As RfcConfigurationEventArgs) Implements IDestinationConfiguration.ConfigurationChanged

    Public Function GetParameters(ByVal destinationName As String) As RfcConfigParameters Implements IDestinationConfiguration.GetParameters

        Dim parms As New RfcConfigParameters

        Select Case destinationName

            Case "ECDCLNT140"

                parms.Add(RfcConfigParameters.AppServerHost, "10.1.1.1")
                parms.Add(RfcConfigParameters.SystemNumber, "00")
                parms.Add(RfcConfigParameters.SystemID, "ECD")
                parms.Add(RfcConfigParameters.User, "username")
                parms.Add(RfcConfigParameters.Password, "secret")
                parms.Add(RfcConfigParameters.Client, "140")
                parms.Add(RfcConfigParameters.Language, "EN")
                parms.Add(RfcConfigParameters.PoolSize, "5")
                parms.Add(RfcConfigParameters.MaxPoolSize, "10")
                parms.Add(RfcConfigParameters.IdleTimeout, "600")

            Case Else

        End Select

        Return parms

    End Function

    Public Function ChangeEventsSupported() As Boolean Implements IDestinationConfiguration.ChangeEventsSupported
        Return False
    End Function

End Class

Then, create a web application, console application, web service, whatever, that uses the NCo 3.0 object model. Very simple stuff to call an RFC enabled Function Module. See sample Console application below:

Imports SAP.Middleware.Connector

Module Driver

    Private _ecc As RfcDestination

    Sub Main()

        RfcDestinationManager.RegisterDestinationConfiguration(New ECCDestinationConfig)

        Try

            _ecc = RfcDestinationManager.GetDestination("ECDCLNT140")

            GetCompanyName()


        Catch ex As Exception
            System.Console.WriteLine(ex.Message)
            System.Console.ReadLine()
        End Try


    End Sub

    Private Sub GetCompanyName()
        System.Console.WriteLine(String.Format("Successfully connected to System {0} Client {1}.", _ecc.SystemID, _ecc.Client))
        System.Console.WriteLine("Enter a company ID:")

        Dim companyID As String = System.Console.ReadLine()

        While Not String.IsNullOrEmpty(companyID.Trim)

            Dim companyAPI As IRfcFunction = _ecc.Repository.CreateFunction("BAPI_COMPANY_GETDETAIL")
            companyAPI.SetValue("COMPANYID", companyID)

            companyAPI.Invoke(_ecc)

            Dim companyName As String = companyAPI.GetStructure("COMPANY_DETAIL").GetString("NAME1")

            If String.IsNullOrEmpty(companyName.Trim) Then
                companyName = "Not found"
            End If

            System.Console.WriteLine(companyName)

            companyID = System.Console.ReadLine()

        End While
    End Sub

End Module

Pretty sweet how you don't have to define the input or output structures. It's all done behind the scenes. Love it!

Former Member
0 Kudos

Anybody know how to resolve this error? I'm running Windows 7 64, Net Framework 4.0 and the latest net connector, intel 64 bit

Error 9 'RfcConfigParameters' is not declared. It may be inaccessible due to its protection level.

Warning 1 The referenced assembly "sapnco" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. ConsoleApplication1

Edited by: Brian on Mar 2, 2011 3:12 PM

Former Member
0 Kudos

Solution found

The client profile attempts to restrict the set of referenced assemblies to those that are only interesting to a client application. For example it won't make System.Web available by default because it is not typically valuable to client apps.

For Visual Basic projects, click the Compile tab and then click Advanced Compile Options. The Target Framework list is in the Advanced Compiler Settings dialog box. Select the Full Net Framework.

Former Member
0 Kudos

@Case Ahr

Hello, i am trying to get this to work (your code examples), but i simply can not.

I am usin VB2010.

Among other errors i get this:

Type 'RfcDestination' is not defined.

If i typeSAP.Middleware.Connector and then ., then i dont get the selection 'RfcDestination' in the dropdown. It's the same with IRfcFunction, VB does not know this as well.

How do i make RfcDestination, IRfcFunction etc. know to my program??

I have copy pasted your program into a console application.

Can anyone help??

Former Member
0 Kudos

Ohh, now i see the error i get:

The referenced assembly "sapnco" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.

How do i fix this?

Cheers

former_member197445
Contributor
0 Kudos

Kenneth,

Check under Project Properties --> Compile --> Advanced Compile Options. Is your target framework .NET Framework 4 Client profile? If so, change this to simply .NET 4 Framework (without the "Client Profile"). System.Web should now be available to import.

CASE

Former Member
0 Kudos

I had the same Problem, with that options it was solved.

But i have another question, maybe somebody can help me.

I want to connect to our sap server...

I have the username and the password, but everytime i get the error that the username or the password is incorrect.

The other error is, that the repository is NULL...

To solve these errors I need the librfc.dll file, is it right?

Or is there another solution?

Thanks Guys!

Former Member
0 Kudos

Hi Case,

I am following your snip code and looks like I made the connection to SAP server. But my problem is the companyAPI.GetStructure("COMPANY_DETAIL").GetString("NAME1") is returning empty string. But When I call BAPI through SAP directly, I can see the compnay name (NAME1) has value, Do you know why this happens. I am using VS 2008 and framework is 3.5. I Appreciate your help! Thank you!

former_member197445
Contributor
0 Kudos

Assuming your code is identical to the posting above, you can try and debug and see what's going on.  Replace this line:

Dim companyName As String = companyAPI.GetStructure("COMPANY_DETAIL").GetString("NAME1") 

with these lines

Dim compDetail As IRfcStructure = companyAPI.GetStructure("COMPANY_DETAIL")

' debug "compDetail" object and see what it contains!

Dim companyName As String = compDetail.GetString("NAME1")

If this doesn't help, please post your code, and we can all take a look and offer advice.

Former Member
0 Kudos

Thank you very much, Case for the quick reply.

I changed the code and the IRFCStructure (compDetail) is returning NON-NULL value. It is still same that the NAME1 returning empty string. Is there anything I should check on SAP side? I only checked the BAPI and it is running as expected. Here is the code. Thank you very much for your help!

Imports SAP.Middleware.Connector
Module Module1
    Private _ecc As RfcDestination

    Sub Main()

        RfcDestinationManager.RegisterDestinationConfiguration(New SAPSystemConnect)

        Try

            _ecc = RfcDestinationManager.GetDestination("SAPServer")

            GetCompanyName()

        Catch ex As RfcCommunicationException
            System.Console.WriteLine(ex.Message)
            System.Console.ReadLine()
        Catch ex As RfcLogonException
            System.Console.WriteLine(ex.Message)
            System.Console.ReadLine()
        Catch ex As RfcAbapRuntimeException
            System.Console.WriteLine(ex.Message)
            System.Console.ReadLine()
        Catch ex As RfcAbapBaseException
            System.Console.WriteLine(ex.Message)
            System.Console.ReadLine()

        Catch ex As Exception
            System.Console.WriteLine(ex.Message)
            System.Console.ReadLine()
        End Try


    End Sub

    Private Sub GetCompanyName()
        System.Console.WriteLine(String.Format("Successfully connected to System {0} Client {1}.", _ecc.SystemID, _ecc.Client))
        System.Console.WriteLine("Enter a company ID:")

        Dim companyID As String = System.Console.ReadLine()
        'Dim companyID As String = "1"

        While Not String.IsNullOrEmpty(companyID.Trim)

            Dim companyAPI As IRfcFunction = _ecc.Repository.CreateFunction("BAPI_COMPANY_GETDETAIL")
            companyAPI.SetValue("COMPANYID", companyID)


            companyAPI.Invoke(_ecc)
            Dim compDetail As IRfcStructure = companyAPI.GetStructure("COMPANY_DETAIL")

            Dim companyName As String = compDetail.GetString("NAME1")

            If String.IsNullOrEmpty(companyName.Trim) Then
                companyName = "Not found"
            End If

            System.Console.WriteLine("Company name:" & companyName)

            companyID = System.Console.ReadLine()

        End While
    End Sub

End Module

imports SAP.Middleware.Connector
Public Class SAPSystemConnect : Implements IDestinationConfiguration
  
    Public Event ConfigurationChanged(ByVal destinationName As String, ByVal args As RfcConfigurationEventArgs) Implements IDestinationConfiguration.ConfigurationChanged

    Public Function GetParameters(ByVal destinationName As String) As RfcConfigParameters Implements IDestinationConfiguration.GetParameters

        Dim parms As New RfcConfigParameters

        Select Case destinationName

            Case "SAPServer"

                parms.Add(RfcConfigParameters.AppServerHost, "10.1.1.1")
                parms.Add(RfcConfigParameters.SystemNumber, "00")
                parms.Add(RfcConfigParameters.SystemID, "EE1")
                parms.Add(RfcConfigParameters.User, "User")
                parms.Add(RfcConfigParameters.Password, "Pass")
                parms.Add(RfcConfigParameters.Client, "100")
                parms.Add(RfcConfigParameters.Language, "EN")
                parms.Add(RfcConfigParameters.PoolSize, "5")
                parms.Add(RfcConfigParameters.PeakConnectionsLimit, "10")
                parms.Add(RfcConfigParameters.IdleTimeout, "600")

            Case Else

        End Select

        Return parms

    End Function

    Public Function ChangeEventsSupported() As Boolean Implements IDestinationConfiguration.ChangeEventsSupported
        Return False
    End Function

End Class

former_member197445
Contributor
0 Kudos

Look for a return message here:

Dim returnMsg As String = companyAPI.GetStructure("RETURN").GetString("MESSAGE")

Also make sure if your company ID is numeric, such as "0001," that you are including all leading zeroes.

Former Member
0 Kudos

Thank you a milliion, Case. That did the trick. In SAP , when I put companyID as 1 that works but as you said, we need add all the leading Zeros into code. Since this is old thread, how do I reward you some points?

former_member197445
Contributor
0 Kudos

Your "like" gets me two.  That will do. 

Former Member
0 Kudos

Hello,

I have an isse when I execute this code for a second time, I test your code in a window form and does work very well but I need a web services with this, and when I start for a first time and I senda value, the BAPI return another value. But if I try to send another value the system shows an error message:

RfcDestinationManager.RegisterDestinationConfiguration(New ECCDestinationConfig) <- destination configuration already initialized

Could you please help me with this?http://a.pictureupload.us/975719456514b2812882b2.png

Former Member
0 Kudos

Hi Case

I use your example and it works well but if I try to connect a second time then I get the error:

So how do I log off after the first time that I have log on (I have to download several HR info type tables after another)

Thanks

Ton

former_member197445
Contributor
0 Kudos

Do not call RegisterDestinationCOnfiguration more than once.  I suggest you put that line of code in your Form_Load event, not the button_click event.

Former Member
0 Kudos

Hi Case

Thanks for the very quick reply!

I suppose that I still can use:

CreateObject("SAP.Functions") ?

Thanks

ton

former_member197445
Contributor
0 Kudos

No, that is incorrect.  _ecc.Repository.CreateFunction("BAPI_COMPANY_GETDETAIL") would be an example for creating an invokable function.

Former Member
0 Kudos

Ok thanks a lot and a like for you!

KR

Ton

Former Member
0 Kudos

Hi Case,

The last one for today

When logging on via SAP GUI -. No problem

When logging on with same details

parms.Add(RfcConfigParameters.AppServerHost, "150.175.248.24")

                parms.Add(RfcConfigParameters.SystemNumber, "20")

                parms.Add(RfcConfigParameters.SystemID, "PD1")

                parms.Add(RfcConfigParameters.User, "xxxxxxxx")

                parms.Add(RfcConfigParameters.Password, "xxxxxxxx")

                parms.Add(RfcConfigParameters.Client, "606")

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

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

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

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

I get the error

Any idea?

Thanks

ton

hynek_petrak
Active Participant
0 Kudos

ask your basis support whether gateway process is runnimg

former_member197445
Contributor
0 Kudos

Agreed.  Ask BASIS.  Also check the IP.  It's definitely something specific to your SAP server, not the .NET Connector.  Your parameters look fine otherwise. 

hynek_petrak
Active Participant
0 Kudos

it's the gateway port.

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Hynek,

not really. In case only the port was wrong, the message would be "connection refused". In this case, network connectivity is not possible to that IP from the host, on which NCo is running. It simply cannot reach the host with that IP.

@Ton: Is the GUI perhaps using a SAPRouter in order to connect to that system? This would explain why it is not reachable with the current set of parameters ...

Best regards,

Markus

hynek_petrak
Active Participant
0 Kudos

Hi Marcus, you are right. Perhaps if Tos posts his SAPGUI settings screenshot would make it more clear.

Former Member
0 Kudos

Hi All

Thanks a lot for helping me out with this.

Here are the settings

Thanks

Ton

hynek_petrak
Active Participant
0 Kudos

Hi Ton, is it the same destination, like you use over here?

If yes let's move to that thread for the resolution. Marcus was perfectly right for usage of the SAPRouter, besides you are using load balanced system, where you shall use rather RfcConfigParameters.MessageServerHost and LogonGroup, instead of AppServerHost and SystemNumber.

Former Member
0 Kudos

Hello, i have a problem.

Because i must two table import to my rfc function.

But  didnt worked this method.

My code part is below.

AppServerHost = servername;

SystemNumber = "96";

User = "USER"

Password = "password";

Client = "210";

Language = "TR";

PoolSize = "1";

MaxPoolSize = "1";

IdleTimeout = "0";

            

CreateFunction = "ZTMTR_WAS_02";

                            try

                            {

                                RfcDestinationManager.RegisterDestinationConfiguration(new   MyBackendConfig());

                            }

                            catch

                            {

                            }

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

                            RfcRepository repo = prd.Repository;

                            IRfcFunction companyBapi = repo.CreateFunction(CreateFunction.ToString());

                            IRfcTable import2 = companyBapi.GetTable("ZBASLIK");

                            for (int i = 0; i < dtbaslik.Rows.Count; i++)

                            {

                                import2.Append();

                               

                                import2.SetValue("PERNR", dtbaslik.Rows[i]["pernr"].ToString());

                                import2.SetValue("SCHEMT", dtbaslik.Rows[i]["SCHEMT"].ToString());

                                import2.SetValue("BEGDA", dtbaslik.Rows[i]["begda"].ToString());

                                import2.SetValue("ENDDA", dtbaslik.Rows[i]["endda"].ToString());

                                import2.SetValue("KUNDE", dtbaslik.Rows[i]["kunde"].ToString());

                                import2.SetValue("ZORT1", dtbaslik.Rows[i]["zort1"].ToString());

                                import2.SetValue("ZLAND", dtbaslik.Rows[i]["zland"].ToString());

                                import2.SetValue("REINR", dtbaslik.Rows[i][7].ToString());

                                import2.SetValue("PERIO", dtbaslik.Rows[i][8].ToString());

                                import2.SetValue("PDVRS", dtbaslik.Rows[i][9].ToString());

                            }

                            IRfcTable import = companyBapi.GetTable("ZBELEG");

                         

                            for (int i = 0; i < dtbeleg.Rows.Count; i++)

                            {

                                import.Append();

                             

                                import.SetValue("BELNR", dtbeleg.Rows[i]["BELNR"].ToString());

                                import.SetValue("SPKZL", dtbeleg.Rows[i]["SPKZL"].ToString());

                                import.SetValue("BEART", dtbeleg.Rows[i]["BEART"].ToString());

                                import.SetValue("MWSKZ", dtbeleg.Rows[i]["MWSKZ"].ToString());

                                import.SetValue("BETRG", dtbeleg.Rows[i]["BETRG"].ToString());

                                import.SetValue("BLDAT", dtbeleg.Rows[i]["BLDAT"].ToString());

                                import.SetValue("BTEXT", dtbeleg.Rows[i]["BTEXT"].ToString());

                                import.SetValue("WAERS", dtbeleg.Rows[i]["WAERS"].ToString());

                                import.SetValue("KURSB", dtbeleg.Rows[i]["KURSB"].ToString());

                                import.SetValue("FFACT", dtbeleg.Rows[i]["FFACT"].ToString());

                                import.SetValue("TFACT", dtbeleg.Rows[i]["TFACT"].ToString());

                                import.SetValue("ANZFR", dtbeleg.Rows[i]["ANZFR"].ToString());

                                import.SetValue("LNDFR", dtbeleg.Rows[i]["LNDFR"].ToString());

                                import.SetValue("BERFR", dtbeleg.Rows[i]["BERFR"].ToString());

                                import.SetValue("RGION", dtbeleg.Rows[i]["RGION"].ToString());

                                import.SetValue("TXJCD", dtbeleg.Rows[i]["TXJCD"].ToString());

                                import.SetValue("PAYOT", dtbeleg.Rows[i]["PAYOT"].ToString());

                                import.SetValue("PAYCURR", dtbeleg.Rows[i]["PAYCURR"].ToString());

                             import.SetValue("ABOVE_LIMIT", dtbeleg.Rows[i]["ABOVE_LIMIT"].ToString());

                                import.SetValue("PROTECT", dtbeleg.Rows[i]["PROTECT"].ToString());

                                import.SetValue("pernr", dtbeleg.Rows[i]["pernr"].ToString());

                           

                            }

                            companyBapi.SetValue("FUNCTION", "3");

                            companyBapi.Invoke(prd);  // i didnt get any error.But rfc didnt worked.

                            IRfcTable test = companyBapi.GetTable("LOGTAB");

Normally , test table should contains rows.But didnt return any rows.

Not error or warning .

Could you help me please?

hynek_petrak
Active Participant
0 Kudos

Sure there is a help, but please post your question as a separate topic. It is not related to the subject of this thread. It would be difficult to maintain the answers here.

Former Member
0 Kudos

Ok , thank you.

Former Member
0 Kudos

Check out this blogpost [A Spotlight on the New .NET Connector 3.0|SDNWeblogs_Interoperabilitynet%2528SAPNetworkWeblogs%253AInteroperability.NET%2529]

It hightlights the differences and improvements wrt NCo 2.0 (in particular the relieve of explicit connection handling, which previous NCo versions required each application developer to do self); and also has some example code for how to set up a configuration, simple client and simple server.

Best regards, William.

Former Member
0 Kudos

HI,

    I creat rfc with SAP .NET CONNECTION 3.0.

   The rfc read data from lips,return incorrect values.

   i_vbeln = 180009902

   clent 880

   error:

{STRUCTURE LIPS{VBELN:CHAR10, MANDT:CHAR3,


{TABLE  [STRUCTURE LIPS { FIELD VBELN=8800180009 FIELD MANDT=880


right:

{STRUCTURE LIPS{MANDT:CHAR3, VBELN:CHAR10,



why?

hynek_petrak
Active Participant
0 Kudos

which function and how do you call it?

Former Member
0 Kudos

i creat a rfc. its tables associated type is lips and import associate type lips-vbeln.

Microsoft .NET Framework4.0 and  SAP .NET connector 3.0

.NET Framework4.0 call rfc to return tables.


please look

SAP .Net Connector 3.0 RfC return incorrect values - Stack Overflow

hynek_petrak
Active Participant
0 Kudos

How did you define your destination? do you use a special "RepositoryDestination" ?

Former Member
0 Kudos

Sorry,i don't understand what you mean.

When I put SAP .NET connector upgrading from 2.0 to 3.0,there is the problem.

this is .Net code.

IRfcFunction fuction = null;

           fuction = destination.Repository.CreateFunction("Z_RFC_OPMS_INBOUND_DELIVERY");

            fuction.SetValue("I_VBELN", EBELN);

            fuction.Invoke(destination);

            Console.WriteLine(fuction);

            IRfcStructure headtable = fuction.GetStructure("E_LIKP");

            IRfcTable itemtable = fuction.GetTable("T_LIPS");

            IRfcTable logtable = fuction.GetTable("T_RETURN");