Highlighted
Respected Contributor.
Respected Contributor.
1144 views

Logging to SAP using LeanFT (C#)

Jump to solution

Hi,

Have the folllowing code in VB which works great with UFT.: 

SapGuiUtil.AutoLogonByIP "ipaddress", client, userName, pwd, language

Attempting to ocnvert to LeanFT using C#, editor is Visual studio. Below is the code i'm using:

IPAddress ipaddress = IPAddress.Parse("xxx.xxx.xxx.xx");

 try   {

       IGuiSession guiSession1 = GuiSessionFactory.Launch(ipaddress, client, userName, pwd);

            }

            catch (Exception ex)        {                 }

 Also tried using:GuiSessionFactory.Launch(serverDescription, client, userName, pwd, language);

 

In both cases it errors with "General error occurred". 

Anyone able to successfuly use Leanft C# library to login to SAP ?

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Respected Contributor.
Respected Contributor.

Just found the solution.. .. under Engine and Object Identification settings;  the SAP GUI addin was not enabled. I assumed this was used only for object identification and not needed for the Login part. My bad on not looking at this earlier. The GuiSessionFactory.Launch() works well. 

 

Thanks!!

View solution in original post

0 Likes
4 Replies
Highlighted
Respected Contributor.
Respected Contributor.

Hello,

Hope that you are okay,

I was reviewing this topic, and what we can offer you for this request can be found on the following links, due to it has an example of how to launch the GUI, i believe that you are doing it on a correct way but please check them:

https://admhelp.microfocus.com/leanft/en/14.03/HelpCenter/Content/CodeSamples_.NET/CodeEx.NETSAPGUI.htm 

https://admhelp.microfocus.com/leanft/en/14.03/HelpCenter/Content/HowTo/TipsTricks_SAPGUI.htm

Also please check the values of the parameters with the ones from the SAP GUI, based on previous expreience of this , the error is usually more related to incorrect inputs on them, this might be a reason of the error.

Also try without using the try catch, only the line that launches the SAP GUI

Hope that this helps in some way!

Best Regards,

Francisco

 

Highlighted
Respected Contributor.
Respected Contributor.

Hi Francisco,

Thanks for the response. Validated all the inputs, seems fine. The error " General error occured" is not helpful in debugging. Without the Exception handling the program just crashes as it can't return any object on the GuiSessionFactory.Launch call.

The input seems fine to me as i can make the calls work on VB scriipt in UFT. 

Anything else i should look at ?

 

 

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Just found the solution.. .. under Engine and Object Identification settings;  the SAP GUI addin was not enabled. I assumed this was used only for object identification and not needed for the Login part. My bad on not looking at this earlier. The GuiSessionFactory.Launch() works well. 

 

Thanks!!

View solution in original post

0 Likes
Highlighted
Frequent Visitor.

Hi,

 

i am trying  to automate SAP with LEanFT,

I am facing issue in selecting the node in Treeview,

its able t o select only the fist two node and other node are not able to select

more over, even the first two nodes also i need to provide the index to select, i am not able to select the value by name

TreeView tableTreeControlTreeView = session.describe(Window.class, new WindowDescription.Builder()

.name("wnd[0]")

.program("/POSDW/SAPLMONITOR_CTRL")

 

.screenNumber(1000l)

.transaction("/POSDW/MON0")

.type(ComponentType.MAIN_WINDOW).build())

.describe(TreeView.class, new TreeViewDescription.Builder()

 

.index(2)

.name("shell")

.type(ComponentType.CTRL_TREE).build());

 

 

tableTreeControlTreeView.activateNode("#2");

tableTreeControlTreeView.activateNode("#1");

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.