Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to connect SAP with out using SAP LOGON.
HERE my code Is
C#
GuiApplication guiApp = (GuiApplication)System.Activator.CreateInstance(Type.GetTypeFromProgID("SapGui.ScriptingCtrl.1"));
GuiConnection guiConn = guiApp.OpenConnectionByConnectionString("/H/XXXXX/S/3200", true, true);

GuiSession guiSession = (GuiSession)guiConn.Sessions.Item(0);
GuiFrameWindow guiWindow = guiSession.ActiveWindow;
((GuiTextField)guiWindow.FindByName("RSYST-MANDT", "GuiTextField")).Text = "XXX";
((GuiTextField)guiWindow.FindByName("RSYST-BNAME", "GuiTextField")).Text = "XXX";
((GuiTextField)guiWindow.FindByName("RSYST-BCODE", "GuiPasswordField")).Text = "XXXX";
((GuiTextField)guiWindow.FindByName("RSYST-LANGU", "GuiTextField")).Text = "XX";
guiWindow.SendVKey(0);
Console.ReadLine();

this Code Compile successfully. but following errors

The enumerator of the collection cannot find en element with the specified index.

Kindly Resolve this?
Posted
Updated 26-Oct-15 21:09pm
v5
Comments
ZurdoDev 26-Oct-15 10:12am    
And which line of code causes the error?

And do you understand the error? You're trying to reference a collection item that does not exist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900