Logging to SAP using types available under the SAP Plugin

Download and share automation modules and examples.
nivasd16
Posts: 14
Joined: Fri Jan 22, 2016 11:17 pm

Logging to SAP using types available under the SAP Plugin

Post by nivasd16 » Wed Sep 28, 2016 3:32 am

Hi Team
I tried to used the classes available under the Ranorex.Plugin.SAPtypes for koggin into SAP. I tried to use the OpenConnection:GuiConnection also OpenConnectionByConnectionString:Guiconnection, but the SAP Logon is not launching..

Once the script is reached to the sections Openconnection. Please let me know if any solution for this

Below is the code snippet i tried .
using System;
using System.Collections.Generic;
using System.Collections;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Repository;
using Ranorex.Plugin.SapTypes;
using SampleTest.Repository;

namespace SampleTest.Framework
{
/// <summary>
/// Description of Class1.
/// </summary>
public static class SAPActive
{

public static GuiApplication SapGuiApp { get; set; }
public static GuiConnection SapConnection { get; set; }
public static GuiSession SapSession { get; set; }
public static void openSap(string env)
{
//SAPActive.SapGuiApp = new GuiApplication();
string connectString = null;
connectString="ET1 [public]";

SAPActive.SapConnection=SAPActive.SapGuiApp.OpenConnection(connectString,true,true);
;
SAPActive.SapSession= (GuiSession)SAPActive.SapConnection.Sessions.Item(0);
//Repo.SAPEasyAccess.Okcd.PressKeys("S_PH0_48000510");
//Repo.SAPEasyAccess.Btn01.Click();
//Repo.SAPEasyAccess.SAPTable.Find(
}

public static void login_SAP(string myclient,string mylogin, string mypass, string mylang)
{
SAPActive.openSap("ET1");
GuiTextField client=(GuiTextField)SAPActive.SapSession.ActiveWindow.FindByName("RSYST-MANDT", "GuiTextField");
//GuiTextField Client=(GuiTextField)SapActive.SapSession.ActiveWindow.FindByName("RSYST-MANDT", "GuiTextField");
GuiTextField login = (GuiTextField)SAPActive.SapSession.ActiveWindow.FindByName("RSYST-BNAME", "GuiTextField");
GuiTextField pass = (GuiTextField)SAPActive.SapSession.ActiveWindow.FindByName("RSYST-BCODE", "GuiPasswordField");
GuiTextField language = (GuiTextField)SAPActive.SapSession.ActiveWindow.FindByName("RSYST-LANGU", "GuiTextField");

client.SetFocus();
client.Text = myclient;
login.SetFocus();
login.Text = mylogin;
pass.SetFocus();
pass.Text = mypass;
language.SetFocus();
language.Text = mylang;

//Press the green checkmark button which is about the same as the enter key
GuiButton btn = (GuiButton)SapSession.FindById("/app/con[0]/ses[0]/wnd[0]/tbar[0]/btn[0]");
btn.SetFocus();
btn.Press();

}
}
}

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Logging to SAP using types available under the SAP Plugin

Post by odklizec » Wed Sep 28, 2016 8:59 am

Hi,

I'm afraid, I can't help you with your problem. But I would like to ask you not to post the same problem multiple times. It does not help with faster response and makes the forum cluttered with doubled posts. Thanks! ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration