Skip to Content
author's profile photo Former Member
Former Member

sap login programmatically

I didn't use SAP Login form.

Instead of SAP Login form, I made codes to connect to SAP like below sources.

When I run it, it connects to SAP and get some data from SAP successfully.

But, the page makes an error and didn't show the binded data at datagrid.

Can you help me?

The error message is belows.

PS : When I didn't connect with SAP, and bind the datagrid to internal table, it works fine.


private void Button1_Click(object sender, System.EventArgs e)


// Declare parameters here

SAPProxy1 proxy = new SAPProxy1();

this.components = new System.ComponentModel.Container();

System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();

this.destination1 = new SAP.Connector.Destination(this.components);


// destination1


this.destination1.AppServerHost = ((string)(configurationAppSettings.GetValue("destination1.AppServerHost", typeof(string))));

this.destination1.SystemNumber = ((short)0);

this.destination1.Username = "RFCB2B";

this.destination1.Password = "SVCUSA";

this.destination1.Client = ((short)(160));

this.destination1.Language = "en";



SAP.Connector.SAPLoginProvider.OpenSAPConnection(this, destination1.ConnectionString, false);

proxy.Connection = SAP.Connector.SAPLoginProvider.GetSAPConnection(this);

// Call methods here

string strEsvc_Rfc_Ok = null;

ZWEBIF2 zBuffer = new ZWEBIF2();

zBuffer.Buffer = this.TextBox1.Text;

Input_Data = new ZWEBIF2Table();


proxy.Z_Web_Rfc_D3("WB_MODEL_SEARCH", "C310", "0001656428", "E", out strEsvc_Rfc_Ok, ref In_31, ref In_33,

ref In_39, ref In_81, ref In_82, ref In_83, ref Input_1000, ref Input_Data, ref Output_1000, ref zwebiF2Table1);



// Now update Data Bindings. On WinForms this will be automatic, on WebForms call the following line



catch(Exception ex)




// If SAPLoginProvider.GetSAPConnection(this) cannot get a connection, we might get an error. // Normally this can be ignored as it will automatically will force a relogon.




Server Error in '/WebApplication3' Application.


The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested Url: /WebApplication3/default.aspx


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Feb 04, 2005 at 08:25 AM

    If you don't want to use a Login page, you shouldn't user SAPLoginProvider.OpenSAPConnection / SAPLoginProvider.GetSAPConnection. This classes to internally some redirect to other pages which causes 404 error.

    Instead us Connection.GetConnection() (for NCo 2.0) or just "new SAPConnection().

    In NCo 2.0 you can easily reach this by just dragging a Destination from Toolbox or the corresponsing Application Server icon from Server Explorer to your form. The Destination is already configured to take most settings from the Web.config file (see the cyan icons on the properties), so you don't need to write "configurationAppSettings.GetValue" by hand.

    In NCo 2.0 you can also drag the SAPProxy1 instance from the toolbox and wire the connection between it and the destination in designer.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.