Alefair.SAP.API 1.0.7

dotnet add package Alefair.SAP.API --version 1.0.7                
NuGet\Install-Package Alefair.SAP.API -Version 1.0.7                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Alefair.SAP.API" Version="1.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Alefair.SAP.API --version 1.0.7                
#r "nuget: Alefair.SAP.API, 1.0.7"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Alefair.SAP.API as a Cake Addin
#addin nuget:?package=Alefair.SAP.API&version=1.0.7

// Install Alefair.SAP.API as a Cake Tool
#tool nuget:?package=Alefair.SAP.API&version=1.0.7                

logo

Alefair.SAP.API

SAP API based by Interop.SAPFEWSELib.dll  and  Interop.SapROTWr.dll

Current version 1.0.7

nuget on https://www.nuget.org

class SAPAPI

Properties

(added 1.0.3)

(added 1.0.4)

Methods:

class SAPTABLE

Properties

(added 1.0.3)

Methods:

class EXTENSION

Methods:


SAPAPI

--class--

/// Init SAPAPI object, The sap should open if exist
///
SAPAPI gui = new SAPAPI(string path = @"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", int timeout = 2000, bool logging = false)

-> SAPAPI gui  { LogDateFormat="MM/dd/yyyy HH:mm:ss.fff", Logging=true, PID=84404 }

back |

LogDateFormat

--property--

/// DateTime format for logging
/// gui.LogDateFormat {get; set;}
Console.WriteLine(gui.LogDateFormat); -> "MM/dd/yyyy HH:mm:ss.fff"
gui.LogDateFormat = "dd.MM.yyyy HH:mm:ss.fff";

back |

Logging

--property--

/// Disable/Enable Logging for SAPAPI class
/// gui.Logging {get; set;}
Console.WriteLine(gui.Logging); -> false
gui.Logging = true;

back |

PID

--property--

/// Gets current process id of running Saplogon
/// gui.PID {get;}
Console.WriteLine(gui.PID); -> 84404

back |

Application

--property--

/// Gets current instance application of running Saplogon
/// gui.Application {get;}
object app = gui.Application); 

-> app <COMObject <unknown>>

back |

HWND

--property--

/// Gets current window handle
/// gui.HWND {get;}
Console.WriteLine(gui.HWND); -> 2178945

back |

ProcessName

--property--

/// Gets current process window title
/// gui.ProcessName {get;}
Console.WriteLine(gui.ProcessName); -> "SAP Logon 760"

back |

GetConnections

--Method--

/// Method get a Dictionary of open connections
/// Key is an Id of connection
/// Value is an instance of GuiConnection
///
Dictionary<string, object> connections = gui.GetConnections();

-> connections["/app/con[0]"] = <COMObject <unknown>>

back |

GetSessions

--Method--

/// Method get a Dictionary of open sessions
/// Key is an Id of session
/// Value is an instance of GuiSession
///
Dictionary<string, object> sessions = gui.GetSessions();

-> sessions["/app/con[0]/ses[0]"] = <COMObject <unknown>>

back |

Connect

--Method--

/// Method create new Connection of GuiConnection object with username, password and base name
///
object connection = gui.Connect(string Login, SecureString Pswd, string Basename);

-> connection <COMObject <unknown>>

back |

CloseConnection

--Method--

/// Method closes an open connection(-s)
/// by connection           - Conn:connection
/// by id                   - Id:"/app/con[0]"
/// by number of connection - Child:0
/// close all connections   - All:true
///
gui.CloseConnection(object Conn = null, string Id = "", int Child = -1, bool All = false);

///gui.CloseConnection(connection);
///gui.CloseConnection(Id:id_conn);
///gui.CloseConnection(Child:child_conn);
///gui.CloseConnection(All:true);

-> 

back |

CloseSession

--Method--

/// Method closes an open session(-s)
/// by connection, session           - Conn:connection, Sess:session
/// by id                            - Id:"/app/con[0]"
/// by connection, number of session - Conn:connection, Child:0
/// close all session                - All:true
///
gui.CloseSession(object Conn = null, object Sess = null, string Id = "", int Child = -1, bool All = false);

///gui.CloseSession(connection, session);
///gui.CloseSession(Id:id_sess);
///gui.CloseSession(connection, Child:child_sess);
///gui.CloseSession(connection, All:true);
///gui.CloseSession(All:true);

-> 

back |

CreateSession

--Method--

/// Method creates a new session from the connection
/// 
object session = gui.CreateSession(object Conn = null);

-> session <COMObject <unknown>>

back |

GetConnection

--Method--

/// Method gives the instance of the GuiConnection object by ID
/// 
object connection = gui.GetConnection(int connNumber = 0);

-> connection <COMObject <unknown>>

back |

GetSession

--Method--

/// Method gives the instance of the GuiSession object by ID and connection
/// 
object session = gui.GetSession(object Conn, int SessNumber = 0);

-> session <COMObject <unknown>>

back |

CheckSAP

--Method--

/// Method checks whether the Saplogon is running or not
/// 
gui.CheckSAP();

-> true

back |

GetListConnections

--Experimental Method--

/// Method gets list of connections on start page of Saplogon
/// 
/// By manual automationId of Table with connections - 1008, automationId of buttons with list - 59410
/// Support only SAP theme with buttons choice(see screenshot later)

List<string> basenames = GetListConnections(int id = 1008, int btn = 59410);

-> basenames<string> = {"Base Name 1", "Base Name 2"...}

Choice

back |

Kill

--Method--

/// Kill Saplogon
/// 
gui.Kill();

-> true

back |


SAPTABLE

--class--

/// Init SAPTABLE object, read GuiGridView table to DataTable
/// selector is an id of GuiGridView table, for example: "wnd[0]/usr/cntlGRID1/shellcont/shell"
/// autodouble is an option, parse value to double, for example: 0,123- -> double -0.123
///
SAPTABLE tbl = new SAPTABLE(object Session, string Selector, bool Autodouble = true);

back |

ColumnsCount

--property--

/// Gets columns count
/// tbl.ColumnsCount {get;}
Console.WriteLine(tbl.ColumnsCount); -> 52

back |

DefaultColumnName

--property--

/// Gets/Sets Default Column Name
/// tbl.DefaultColumnName {get; set;}
Console.WriteLine(tbl.DefaultColumnName); -> "Column"
tbl.DefaultColumnName = "Clmn";

-> {"Clmn_0", "Clmn_1"....}

back |

DefaultSuffixColumnName

--property--

/// Gets/Sets suffix default column name
/// tbl.DefaultSuffixColumnName {get; set;}
Console.WriteLine(tbl.DefaultSuffixColumnName); -> "_"
tbl.DefaultColumnName = "-";

-> {"Clmn-0", "Clmn-1"....}

back |

GuiTable

--property--

/// Gets instance GuiComponent of table 
/// tbl.GuiTable {get;}
GuiGridView table = tbl.GuiTable;

-> table <COMObject <unknown>>

back |

Id

--property--

/// Gets Id of table
/// tbl.Id {get;}
Console.WriteLine(tbl.Id); -> wnd[0]/usr/cntlGRID1/shellcont/shell

back |

RowsCount

--property--

/// Gets rows count
/// tbl.RowsCount {get;}
Console.WriteLine(tbl.RowsCount; -> 320

back |

ExtractTable

--Method--

/// Method gets a DataTable with columns type by default
///
/// [unavailable after 1.0.3] ColumnsType.type_default -> Column_1, Column_2...
/// [unavailable after 1.0.3] ColumnsType.type_1       -> column name as is
/// [unavailable after 1.0.3] ColumnsType.type_2       -> column name as name in report of sap
/// [unavailable after 1.0.3] ColumnsType.type_3       -> column name as name of tooltip
///
/// [unavailable after 1.0.3] DataTable table = tbl.ExtractTable(ColumnsType clmntype = ColumnsType.type_default);
///
/// ColumnNameType.FULLNAME
/// ColumnNameType.DISPLAYNAME
/// ColumnNameType.TOOLTIP
/// ColumnNameType.TECHNAMES
/// ColumnNameType.DEFAULT


DataTable table = tbl.ExtractTable(ColumnsType clmntype = ColumnsType.type_default);

-> DataTable(){"Column_1", "Column_2"...}

back |

ExtractFirstVisibleRows

--Method--

/// Method gets a List<int> of parameters .FirstVisibleRow
///
List<int> fvrc = tbl.ExtractFirstVisibleRows();

-> List<int> {0, 40, 81, 122}

back |

GetTechNamesColumns

--Method--

/// Method gets a DataTable of only tech columns names
/// Option clmntype gets a real column name
///
/// [unavailable after 1.0.3] ColumnsType.type_default -> Column_1, Column_2...
/// [unavailable after 1.0.3] ColumnsType.type_1       -> column name as is
/// [unavailable after 1.0.3] ColumnsType.type_2       -> column name as name in report of sap
/// [unavailable after 1.0.3] ColumnsType.type_3       -> column name as name of tooltip
/// [unavailable after 1.0.3] DataTable dtTech = tbl.GetTechNamesColumns(ColumnsType clmntype = ColumnsType.type_default);
///
/// ColumnNameType.FULLNAME
/// ColumnNameType.DISPLAYNAME
/// ColumnNameType.TOOLTIP
/// ColumnNameType.TECHNAMES
/// ColumnNameType.DEFAULT

DataTable dtTech = tbl.GetTechNamesColumns(ColumnNameType clmntype = ColumnNameType.DEFAULT);

-> DataTable() {"Column Number", "Name", "Value"}

back |

OnlyColumns

--Method--

/// Method gets a DataTable of only columns names
/// [unavailable after 1.0.3] ColumnsType.type_default -> Column_1, Column_2...
/// [unavailable after 1.0.3] ColumnsType.type_1       -> column name as is
/// [unavailable after 1.0.3] ColumnsType.type_2       -> column name as name in report of sap
/// [unavailable after 1.0.3] ColumnsType.type_3       -> column name as name of tooltip
/// [unavailable after 1.0.3] DataTable dtClone = tbl.OnlyColumns(ColumnsType clmntype = ColumnsType.type_default);
///
/// ColumnNameType.FULLNAME
/// ColumnNameType.DISPLAYNAME
/// ColumnNameType.TOOLTIP
/// ColumnNameType.TECHNAMES
/// ColumnNameType.DEFAULT

DataTable dtClone = tbl.OnlyColumns(ColumnNameType clmntype = ColumnNameType.DEFAULT);

-> DataTable(){"Column_1", "Column_2"...}

back |


EXTENSION

--class--

SelectorType

--Method--

/// Method gets a type name of GuiComponent
///
string selectortype = session.SelectorType("wnd[0]/usr/cntlGRID1/shellcont/shell");

-> selectortype = "GuiGridView"

back |

GetTitle

--Method--

/// Method gets a title window
string title = session.GetTitle();

-> title = "Transaction Name"

back |

GetStatus

--Method--

/// Method gets a text from Status Bar
string status = session.GetStatus();

-> status = "Current status"

back |

Click

--Method--

/// Generate Click Event for GuiComponent
/// Avaible: GuiButton, GuiCheckBox, GuiRadioButton, GuiShell

session.Click("wnd[0]/tbar[0]/btn[3]")

back |

Focus

--Method--

/// Generate Focus Event for GuiComponent
/// Avaible: GuiCTextField, GuiTextField, GuiLabel, GuiShell
/// For GuiShel Avaible: Select All, Select Column, Select Rows, Select Cell

session.Focus("wnd[0]/usr/ctxtS_VKORG-LOW")

session.Focus("wnd[0]/usr/cntlGRID1/shellcont/shell", TableSelectMethod.SelectCell, "2, SUM_OPEN")

back |

GetText

--Method--

/// Get text from GuiComponent
/// Avaible GuiShell get text from cell

sResult = session.GetText("wnd[0]/usr/ctxtS_VKORG-LOW")
-> "control text"

sResult = session.GetText("wnd[0]/usr/ctxtS_VKORG-LOW", "2, SUM_OPEN")
-> "cell value"

back |

SetText

--Method--

/// Set text of GuiComponent
/// Avaible GuiShell set text into cell

session.SetText("wnd[0]/usr/ctxtS_VKORG-LOW", "control text")

session.SetText("wnd[0]/usr/ctxtS_VKORG-LOW", "cell value", "2, SUM_OPEN")

back |

Handle

--Method--

/// Get Window Handle of session

session.Handle()
-> 52345

back |

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Alefair.SAP.API:

Package Downloads
Primo.Alefair.SAP

SAP Activities for Primo RPA platform based of Alefair.SAP.API powered by Alefair

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 2,925 9/20/2022
1.0.6 678 9/7/2022
1.0.5 655 9/2/2022
1.0.4 752 8/18/2022
1.0.3 886 8/14/2022
1.0.2 394 8/13/2022