Monday, May 20, 2019

Connect to ERP system with .Net Application

Hi everyone !!!!!

here is the example to connect the SAP ERP syetm to .Net Application.

for connection to SAP ERP to .NET Application through RFC (Remote Function), we need some dll files that can be easily available in internet or microsoft

SAPLogonCtrl.dll
SAPFunctionsOCX.dll

Step 1 : Download these 2 files

Step 2 : Open visual studio --> Start New Project (using C# or VB)

Step 3: In the solution explorer 'Right Click', add reference to these dll into you website

Step 4 : After add reference, need to write the code for connect to ERP SAP

Step 5 : Write below code to connect to ERP using namespace


using SAPLogonCtrl;
using SAPFunctionsOCX;


protected Boolean SAPConnection()
    {  

        SAPLogonCtrl.SAPLogonControlClass Login = new SAPLogonCtrl.SAPLogonControlClass();
        SAPLogonCtrl.Connection SapConn;

        Login.ApplicationServer = "ERP Server Name or IP";
        Login.SystemNumber = SystemNumber;
        Login.Client = "ClientNumber";
        Login.Language = "SAP Language";
        Login.User = "SAP User ID";
        Login.Password = "SAP Password";
        SapConn = (SAPLogonCtrl.Connection)Login.NewConnection();
        if (SapConn.Logon(0, true))
        {
            Response.Write("Connected to SAP");
            return true;
        }
        else
        {
            Response.Write("Not able to connect SAP");
            return false;
        }
    }

No comments:

Post a Comment