Sahi Documentation

SAP APIs

abstract SAP GUI automation is supported since Sahi Pro SAP Add-on.

_launchSAPGUI

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_launchSAPGUI()

Arguments
None

Returns
null

Details

Launches SAP GUI logon pad.
_launchSAPGUI();
infoCall this API only if SAP logon pad is not open.


_closeSAPGUI

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_closeSAPGUI()

Arguments
None

Returns
null

Details

Closes SAP GUI logon pad launched earlier using _launchSAPGUI.
_closeSAPGUI();
infoBefore closing logon pad, ensure that all connections are closed and no new connection will be opened.


_openSAPConnection

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_openSAPConnection($connectionName)

Arguments
$connectionNamestring Name of the connection to open

Returns
null

Details

Opens the specified SAP GUI connection.

_openSAPConnection("Connection1");


_closeSAPConnection

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_closeSAPConnection()

Arguments
None

Returns
null

Details

Closes the currently open SAP GUI connection.

_closeSAPConnection();


_createNewSAPSession

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_createNewSAPSession()

Arguments
None

Returns
null

Details

Opens a new SAP GUI session from the existing SAP GUI session.
_createNewSAPSession();
infoPlayback would happen on the new session. Later if this newly created session is closed, playback would happen on the previous session.
infoThis action resembles clicking the toolbar button 'Creates New Session' from an already logged in SAP GUI session window.


_maximizeWindow

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_maximizeWindow([$title])

Arguments
$titlestring optional Title of the window to maximize

Returns
null

Details

Maximizes an existing SAP GUI window having the specified title. If title is not specified, it maximizes the current window.

_maximizeWindow();
_maximizeWindow("Create Order");
_maximizeWindow("/Purchase Order No./");
_maximizeWindow("/Purchase Order No. [0-9]{5}/");


_minimizeWindow

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_minimizeWindow([$title])

Arguments
$titlestring optional Title of the window to minimize

Returns
null

Details

Minimizes an existing SAP GUI window having the specified title. If title is not specified, it minimizes the current window.

_minimizeWindow();
_minimizeWindow("Create Inquiry");
_minimizeWindow("/Purchase Order No./");
_minimizeWindow("/Purchase Order No. [0-9]{5}/");


_restoreWindow

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_restoreWindow([$title])

Arguments
$titlestring optional Title of the window to restore

Returns
null

Details

Restores an existing SAP GUI window having the specified title from its minimized state. If title is not specified, it restores the current window.

_restoreWindow();
_restoreWindow("Create Order");
_restoreWindow("/Purchase Order No./");
_restoreWindow("/Purchase Order No. [0-9]{5}/");


_resizeWindow

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_resizeWindow($title, $width, $height)

Arguments
$titlestring Title of the window to resize
$widthinteger New width for the window
$heightinteger New height for the window

Returns
null

Details

Resizes an existing SAP GUI window having the specified title with the specified dimensions.

_resizeWindow("Create Order", 800, 400);
_resizeWindow("/Purchase Order No./", 380, 250);
_resizeWindow("/Purchase Order No. [0-9]{5}/", 640, 300);


_getStatusInformation

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_getStatusInformation()

Arguments
None

Returns
mpStatus information object

Details

Gets the status information from the status bar of the current SAP GUI window. It returns the status message, message type, message id, message number. It also returns up to eight parameters of the status message.

// Read status information
var $statusInfo = _getStatusInformation();
var $statusMessage = $statusInfo.Message; // e.g Inquiry 10000267 has been saved
var $statusMessageType = $statusInfo.MessageType; // e.g Success, Information, Warning, Error, Abort
var $statusMessageId = $statusInfo.MessageId;
var $statusMessageNumber = $statusInfo.MessageNumber;
var $statusMessageParameter0 = $statusInfo.MessageParameter0;
var $statusMessageParameter1 = $statusInfo.MessageParameter1;
var $statusMessageParameter2 = $statusInfo.MessageParameter2;
var $statusMessageParameter3 = $statusInfo.MessageParameter3;
var $statusMessageParameter4 = $statusInfo.MessageParameter4;
var $statusMessageParameter5 = $statusInfo.MessageParameter5;
var $statusMessageParameter6 = $statusInfo.MessageParameter6;
var $statusMessageParameter7 = $statusInfo.MessageParameter7;

// Verify status message
var $pattern = "/^Inquiry (.*) has been saved$/";
_assertEqual($pattern, $statusMessage);

// Extract inquiry number from status message
var $inquiryNumber = _extract($statusMessage, $pattern, true);


_selectRows

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_selectRows($element, $rows)

Arguments
$elementHTML DOM element Table element
$rowsstring Comma separated list of row numbers to be selected

Returns
null

Details

Selects the specified row(s) in the specified table element.

_selectRows(_gridView("wnd[0]/usr/cntlBCALVC_TOOLBAR_D100_C1/shellcont/shell"), "2,3");


_selectColumns

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_selectColumns($element, $columns)

Arguments
$elementHTML DOM element Table element
$columnsstring Comma separated list of column titles to be selected

Returns
null

Details

Selects the specified columns in the specified table element.

_selectColumns(_gridView("wnd[0]/usr/cntlBCALVC_TOOLBAR_D100_C1/shellcont/shell"), "Price,Order Quantity");


_htmlFormSubmit

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
NANANANANA9.0.0NA

Available for modes: SAP

_htmlFormSubmit($element, $frameName, $postData, $url)

Arguments
$elementHTML DOM element HtmlViewer element
$frameNamestring Name of the parent frame of the HTML form to be submitted
$postDatastring Post data to be submitted
$urlstring Url to be submitted to the SAP server.

Returns
null

Details

Submits an HTML form for an _htmlViewer element.

_htmlFormSubmit(_htmlViewer("wnd[0]/usr/cntlHTML/shellcont/shell"), "Frame1", "FirstName=John&LastName=Smith", "sapevent:SUBMIT_FORM_AS_POST_METHOD");