SAP APIs

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

Launch SAP GUI

Launches SAP GUI logon pad.

Parameters
None
Return Value

Modes Supported :
Raw Script
_launchSAPGUI();

Sahi Pro Classic API :_launchSAPGUI


Close SAP GUI

Closes SAP GUI logon pad launched earlier using _launchSAPGUI.

Parameters
None
Return Value

Modes Supported :
Raw Script
_closeSAPGUI();

Sahi Pro Classic API :_closeSAPGUI


Open a SAP GUI connection

Opens the specified SAP GUI connection.

Parameters
$connectionNamestring Name of the connection to open
Return Value

Modes Supported :
Raw Script
_openSAPConnection("Connection1");

Sahi Pro Classic API :_openSAPConnection


Close SAP GUI connection

Closes the currently open SAP GUI connection.

Parameters
None
Return Value

Modes Supported :
Raw Script
_closeSAPConnection();

Sahi Pro Classic API :_closeSAPConnection


Create a SAP GUI session

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

Parameters
None
Return Value

Modes Supported :
Raw Script
_createNewSAPSession();

Sahi Pro Classic API :_createNewSAPSession


Maximize a SAP GUI window

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

Parameters
$titlestring optional Title of the window to maximize
Return Value

Modes Supported :
Raw Script
_maximizeWindow();
_maximizeWindow("Create Order");
_maximizeWindow("/Purchase Order No./");
_maximizeWindow("/Purchase Order No. [0-9]{5}/");

Sahi Pro Classic API :_maximizeWindow


Minimize a SAP GUI window

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

Parameters
$titlestring optional Title of the window to minimize
Return Value

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

Sahi Pro Classic API :_minimizeWindow


Restore a SAP GUI window

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

Parameters
$titlestring optional Title of the window to restore
Return Value

Modes Supported :
Raw Script
_restoreWindow();
_restoreWindow("Create Order");
_restoreWindow("/Purchase Order No./");
_restoreWindow("/Purchase Order No. [0-9]{5}/");

Sahi Pro Classic API :_restoreWindow


Resize a SAP GUI window

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

Parameters
$titlestring Title of the window to resize
$widthinteger New width for the window
$heightinteger New height for the window
Return Value

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

Sahi Pro Classic API :_resizeWindow


Read status from SAP GUI

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.

Parameters
None
Return Value
mpStatus information object

Modes Supported :
Raw Script
// 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);

Sahi Pro Classic API :_getStatusInformation


Select rows in a SAP GUI table

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

Parameters
$elementHTML DOM element Table element
$rowsstring Comma separated list of row numbers to be selected
Return Value

Modes Supported :
Raw Script
_selectRows(_gridView("wnd[0]/usr/cntlBCALVC_TOOLBAR_D100_C1/shellcont/shell"), "2,3");

Sahi Pro Classic API :_selectRows


Select columns in a SAP GUI table

Selects the specified columns in the specified table element.

Parameters
$elementHTML DOM element Table element
$columnsstring Comma separated list of column titles to be selected
Return Value

Modes Supported :
Raw Script
_selectColumns(_gridView("wnd[0]/usr/cntlBCALVC_TOOLBAR_D100_C1/shellcont/shell"), "Price,Order Quantity");

Sahi Pro Classic API :_selectColumns


Submit a HTML form in SAP GUI

Submits an HTML form for an _htmlViewer element.

Parameters
$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.
Return Value

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

Sahi Pro Classic API :_htmlFormSubmit