on 07-07-2010 1:15 PM
I need to integrate GUI scripting into some existing c# code. I am making use of the SAPFEWSELib.dll as an Interop component within Visual Studio 2008.
I am having some success:
private void Form1_Load(object sender, EventArgs e)
{
GuiApplication Application;
GuiConnection Connection;
GuiSession Session;
Application = (GuiApplication)System.Activator.CreateInstance(Type.GetTypeFromProgID("SapGui.ScriptingCtrl.1"));
Connection = Application.OpenConnection("Bazinga", false, true);
Session = (GuiSession)Connection.Sessions.Item(0);
Session.TestToolMode = 1;
((GuiTextField)Session.ActiveWindow.FindByName("RSYST-MANDT", "GuiTextField")).Text = "050";
((GuiTextField)Session.ActiveWindow.FindByName("RSYST-BNAME", "GuiTextField")).Text = "dshelman";
((GuiTextField)Session.ActiveWindow.FindByName("RSYST-BCODE", "GuiPasswordField")).Text = "N0tAPwd";
((GuiTextField)Session.ActiveWindow.FindByName("RSYST-LANGU", "GuiTextField")).Text = "EN";
Session.SendCommand("");
Console.WriteLine("Logged in");
}
The problem occurs when I issue the SendCommand(""). I see the little barber pole/script indicator on the login screen and it appears to have logged in. Then the application quits. It never gets to the subsequent WriteLine statement of "Logged In".
I suspect I need to make use of events here, but am not familiar with how to code the GUI Scripting API events in C#.
Can someone provide me with some sample code to assist me in transitioning from the login to the actual use of a session with a transaction. I feel that once there, my VBA scripting knowlege will help me.
Thanks,
Don Shelman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Don,
I'm trying to get "Interop.SAPFEWSELib.dll" running in C# as well.
But I can not figure out how to import the DLL properly.
[DllImport("Interop.SAPFEWSELib.dll")]
seems not to work. Even if i try to use a Kexword out of the SAPFEWSELib for example a constructor to create an instance of an object which might be included in the DLL i get an compiler Error.
[DllImport("Interop.SAPFEWSELib.dll")]
public static extern IntPtr GuiApplication();
public GuiApplication Engine;
The error displayed:
GuiApplication is a 'method' but is used like a type.
How can I import a constructor from the DLL?!
Have you already solved your issue with this DLL?
Help would be highly appreciated Thanks a lot.
Andi
Edited by: aegidos on Jul 13, 2011 8:01 AM
User | Count |
---|---|
76 | |
10 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.