Skip to content
Get Free Trial

SAP Functions

SAP GUI automation is supported since Sahi Pro SAP Engine.

Since
SAP Engine 9.0.0

Modes SAP

_launchSAPGUI()

Arguments

NameTypeDescription
None

Returns

null

Launches SAP GUI logon pad.

_launchSAPGUI();
Since
SAP Engine 9.0.0

Modes SAP

_closeSAPGUI()

Arguments

NameTypeDescription
None

Returns

null

Closes SAP GUI logon pad launched earlier using _launchSAPGUI.

_closeSAPGUI();
Since
SAP Engine 9.0.0

Modes SAP

_openSAPConnection($connectionName)

Arguments

NameTypeDescription
$connectionNamestringName of the connection to open

Returns

null

Opens the specified SAP GUI connection.

_openSAPConnection("Connection1");
Since
SAP Engine 9.0.0

Modes SAP

_closeSAPConnection()

Arguments

NameTypeDescription
None

Returns

null

Closes the currently open SAP GUI connection.

_closeSAPConnection();
Since
SAP Engine 9.0.0

Modes SAP

_createNewSAPSession()

Arguments

NameTypeDescription
None

Returns

null

Opens a new SAP GUI session from the existing SAP GUI session.

_createNewSAPSession();
Since
SAP Engine 9.0.0

Modes SAP

_maximizeWindow([$title])

Arguments

NameTypeDescription
$titlestringoptionalTitle of the window to maximize

Returns

null

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}/");
Since
SAP Engine 9.0.0

Modes SAP

_minimizeWindow([$title])

Arguments

NameTypeDescription
$titlestringoptionalTitle of the window to minimize

Returns

null

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}/");
Since
SAP Engine 9.0.0

Modes SAP

_restoreWindow([$title])

Arguments

NameTypeDescription
$titlestringoptionalTitle of the window to restore

Returns

null

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}/");
Since
SAP Engine 9.0.0

Modes SAP

_resizeWindow($title, $width, $height)

Arguments

NameTypeDescription
$titlestringTitle of the window to resize
$widthintegerNew width for the window
$heightintegerNew height for the window

Returns

null

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);
Since
SAP Engine 9.0.0

Modes SAP

_getStatusInformation()

Arguments

NameTypeDescription
None

Returns

mpStatus information object

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);
Since
SAP Engine 9.0.0

Modes SAP

_selectRows($element, $rows)

Arguments

NameTypeDescription
$elementHTML DOM elementTable element
$rowsstringComma separated list of row numbers to be selected

Returns

null

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

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

Modes SAP

_selectColumns($element, $columns)

Arguments

NameTypeDescription
$elementHTML DOM elementTable element
$columnsstringComma separated list of column titles to be selected

Returns

null

Selects the specified columns in the specified table element.

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

Modes SAP

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

Arguments

NameTypeDescription
$elementHTML DOM elementHtmlViewer element
$frameNamestringName of the parent frame of the HTML form to be submitted
$postDatastringPost data to be submitted
$urlstringUrl to be submitted to the SAP server.

Returns

null

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");