PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

SAP package guide

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Packages

Prerequisites

Use Windows with SAP GUI already open. The package does not start it or use a browser. Turn on SAP GUI Scripting in the client and on the server, for this account. A missing scripting setup or registration, missing connection or server error fails the step.

Start with Connect. Later steps use its Session name within this Run. Use another name for another connection. Disconnect removes the local name; it does not sign out, close the connection or close SAP GUI.

Get each Field path from the SAP scripting tools for your actual screen. It is a scripting ID, not a title, CSS selector or position on screen. Replace these sample IDs with IDs from a test screen; the package does not create them.

ControlSample IDSample content
Text fieldwnd[0]/usr/txtSAMPLESample
Checkboxwnd[0]/usr/chkSAMPLENot checked
Radio optionwnd[0]/usr/radSAMPLENot selected
Buttonwnd[0]/tbar[0]/btn[0]A button safe to click
Combownd[0]/usr/cmbSAMPLEAlpha, key A1; two entries
Treewnd[0]/usr/cntlTREE/shellcont/shellA node named Alpha
Tablewnd[0]/usr/cntlGRID/shellcont/shellColumns Code and Text; rows A1/Alpha and B2/Beta
Containerwnd[0]/usr/cntlSAMPLEChildren First and Second, with text Alpha and Beta

Table rows, columns, item numbers and cell positions start at 1. Menu paths use SAP's own numbers, usually from 0. Menu, tree and item text must match exactly, with case. A control must support the action, or the step fails. The effect depends on the active SAP screen. Use test data for clicks, keys and edits. Create samples before a CSV export. Relative paths start in the Run working folder.

Shared fields

Each example, except Connect and Disconnect, starts with Connect Default and the test screen above.

Session and control

All actions use Session name. All except Connect, Disconnect and Send virtual key also use Field path.

IDFieldType; default; requirementValue
sessionNameSession nameStringdefault DefaultOptional.Connect gives the connection this local name. Later steps use it. It is not an account or server.
fieldPathField pathStringdefault emptyRequired.The exact scripting ID of the control. Spaces at the ends are removed. The control must exist and support this action.

Actions

This package has no conditions.

Check/uncheck checkbox (sapCheckboxActions)

Check, uncheck or reverse a checkbox.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
actionActionCheckboxOperationdefault CheckOptional.Check checks it, Uncheck clears it and Toggle reverses it.

Outputs

None.

Example

Set Field path=wnd[0]/usr/chkSAMPLE, Action=Check.

Expected result

The checkbox is checked. A missing control or one that cannot be checked fails.

Back to actions

Click (sapClick)

Clicks a button. On a grid, clicks the current cell.

Inputs

Also uses the session and control fields.

Outputs

None.

Example

Set Field path=wnd[0]/tbar[0]/btn[0] on the disposable screen.

Expected result

The button or current grid cell is clicked. The screen sets the effect. An unsupported control or a SAP error fails.

Back to actions

Click menu (sapClickMenu)

Select a nested SAP menu by exact names or SAP menu indexes.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
selectMenuPathSelectMenuSelectiondefault NAMEOptional.NAME selects a menu by exact visible text segments. INDEX builds a scripting path from indexPath and selects that menu directly. Choices: NAME⁠, INDEX⁠.
namePathnamePathStringdefault emptyOptional.For Select=NAME, enter a path such as System > Status or System/Status⁠. Segments are trimmed and compared exactly, with case sensitivity. INDEX ignores this input.
indexPathindexPathStringdefault emptyOptional.For Select=INDEX, enter SAP menu indexes such as 0/2⁠. The action extracts digit groups and appends menu[0]/menu[2] to Field path. These are SAP indexes, not the 1-based table indexes.

Outputs

None.

Example

With a test menu path System > Status, set Field path=wnd[0]/mbar, Select=NAME, namePath=System > Status. Alternatively use Select=INDEX and the actual indexPath, for example 0/2.

Expected result

The last matching menu is selected. The number example gives wnd[0]/mbar/menu[0]/menu[2]. Missing names, no number or a missing menu fails.

Back to actions

Connect (sapConnect)

Use or open a SAP GUI session and give it a local name.

Inputs

IDFieldType; default; requirementValue
sessionNameSession nameStringdefault DefaultOptional.A name for this connection in this Run.
connectionTypeSelect connection typeConnectionTypedefault AutomaticOptional.Automatic uses the first session of the first connection, already signed in. SAP_SSO opens the named SAP Logon connection with working SSO. SAP_GUI opens it and fills Client, User name, Password and Language.
sapSSOServerNameNameStringdefault emptyOptional.For SAP_SSO, enter the exact configured SAP Logon connection name, for example SAP Training⁠. Required in that mode. Ignored by Automatic and SAP_GUI.
sapServerNameNameStringdefault emptyOptional.For SAP_GUI, enter the exact configured SAP Logon connection name, for example SAP Training⁠. Required in that mode. It is not a hostname.
clientIDClientStringdefault emptyOptional.For SAP_GUI, enter one to three digits, for example 100⁠. Other connection modes ignore it.
secureUserUser nameCredentialdefault emptyOptional.For SAP_GUI, bind a Credential with a nonempty username for the test account. Its password part is ignored in this field.
secureCredentialPasswordCredentialdefault emptyOptional.For SAP_GUI, bind a Credential with the nonempty account password. Its username part is ignored in this field.
languageLanguageStringdefault emptyOptional.For SAP_GUI enter exactly two letters, for example EN⁠. Other modes ignore it.

Outputs

None.

Example

Sign into a test connection in SAP GUI. Set Session name=Default, Select connection type=Automatic. For a new login, use SAP_GUI, Name=SAP Training, Client=100, Language=EN and Credential variables for the test account.

Expected result

The first session is available as Default. SAP_GUI fills the login screen and presses Enter; later dialogs can still need handling. A non-Windows system or missing SAP scripting fails.

Back to actions

Disconnect (sapDisconnect)

Release the session and remove its local name. It does not sign out, close the connection or close SAP GUI.

Inputs

IDFieldType; default; requirementValue
sessionNameSession nameStringdefault DefaultOptional.The name given in Connect.

Outputs

None.

Example

After the sample actions set Session name=Default.

Expected result

The local name is removed; SAP stays open and signed in. Later steps with Default fail until Connect runs again. An unknown name fails Disconnect.

Back to actions

Double click (sapDoubleClick)

Double-clicks a control. On a grid, double-clicks the current cell.

Inputs

Also uses the session and control fields.

Outputs

None.

Example

Select a disposable sample row first. Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell.

Expected result

The selected control or current grid cell receives a double click. This action does not choose a row itself. An unsupported control fails.

Back to actions

Expand (sapExpand)

Expand one node in a SAP tree.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
selectSelectItemSelectiondefault TEXTOptional.Shared.
itemByTextitemByTextStringdefault emptyOptional.Shared.
itemByIndexitemByIndexNumberdefault 1Optional.Shared.

Outputs

None.

Example

Prepare a node with text Alpha. Set Field path=wnd[0]/usr/cntlTREE/shellcont/shell, Select=TEXT, itemByText=Alpha.

Expected result

The first exact Alpha node opens. INDEX=1 uses the first key in the tree key list. Missing text or a bad number fails.

Back to actions

Export table (sapExportTable)

Read all table cells into a Table and optionally write CSV.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
exportAsExport AsExportAsdefault CSVOptional.CSV writes a CSV file and returns the Table. Datatable returns the Table without a file. The output table is populated in both modes. Choices: CSV⁠, Datatable⁠.
filePathFile PathStringdefault emptyRequired.Always required. For CSV, a local path such as samples/sap-grid.csv⁠, in an existing folder. Datatable does not write it; give any path, such as samples/unused.csv⁠.
encodingTypeEncodingEncodingTypedefault ANSIOptional.For CSV use ANSI for Windows-1252, UNICODE for UTF-16, or UTF8 for UTF-8 without a byte-order mark. Datatable ignores this field. Choices: ANSI⁠, UNICODE⁠, UTF8⁠.
withHeaderExport data with headerBooleandefault falseOptional.For CSV, true writes column names before rows. False writes rows only. Headers use SAP column titles when available, then column keys or generated names.
overwriteOptionOverwrite the fileBooleandefault trueOptional.For CSV, true replaces the whole file; false appends rows to the existing file, not skips or fails. With Header=true each appended export adds another header.

Outputs

IDTypeResult
tableTableTable. Bind to a Table variable such as sapData⁠. All cell values are Strings; column names come from titles, keys or generated names. Returned for CSV and Datatable.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell, Export As=CSV, File Path=samples/sap-grid.csv, Encoding=UTF8, Export data with header=true, Overwrite the file=true. Bind table to sapData. For no file, choose Export As=Datatable.

Expected result

sapData has String columns Code and Text and two rows A1/Alpha and B2/Beta. The CSV has header Code,Text and those rows. Overwrite=false appends, including another header when enabled. A missing parent folder fails CSV writing.

Back to actions

Get cell count (sapGetCell)

Return the number of cells: rows times columns.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultNumberRows times columns. Bind to Number cellCount⁠.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell; bind result to Number variable cellCount.

Expected result

cellCount=4. An empty table gives 0. A count too large for a whole number or an unsupported control fails.

Back to actions

Get children names (sapGetChildrenNames)

Read the names of the direct child controls, not their children.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultListStrings from direct children only, in control order. Uses Name, or Id if there is no Name. Bind to a List variable.

Example

Set Field path=wnd[0]/usr/cntlSAMPLE for the prepared two-child container. Bind result to List variable childNames.

Expected result

childNames contains First and Second in their control order. It does not include grandchildren. A container with no children returns an empty List.

Back to actions

Get children text (sapGetChildrenText)

Read the text of each direct child, in control order.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultListStrings from direct children only, in control order. Uses text, then value, then empty if neither exists. Bind to a List variable.

Example

Set Field path=wnd[0]/usr/cntlSAMPLE for the prepared two-child container. Bind result to List variable childTexts.

Expected result

childTexts holds Alpha and Beta. No children gives an empty List.

Back to actions

Get column count (sapGetColumn)

Return the number of columns.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultNumberThe number of columns. Bind to Number columnCount⁠.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell; bind result to Number columnCount.

Expected result

columnCount=2. A table with no columns gives 0; a control that cannot count columns fails.

Back to actions

Get item count (sapGetItemCount)

Count combo entries, tree keys or direct children.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultNumberThe number of combo entries, or tree keys, or direct children, in that order. Bind to a Number variable.

Example

Use a sample combo with two entries. Set Field path=wnd[0]/usr/cmbSAMPLE; bind result to Number itemCount.

Expected result

itemCount=2. An empty collection gives 0; an unsupported control can fail.

Back to actions

Get row count (sapGetRow)

Return the number of rows.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultNumberThe number of rows. Bind to Number rowCount⁠.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell; bind result to Number rowCount.

Expected result

rowCount=2. A table with no rows gives 0; a control that cannot count rows fails.

Back to actions

Get selected item (sapGetSelectedItem)

Read the selection. It can be a key, not the visible text.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultStringThe combo key, selected-rows text, selected-node text or tab number (from 1), using the first that the control supports. No selected tab gives empty. Bind to a String variable.

Example

Prepare a combo whose visible Alpha entry has key A1 and select it. Use Field path=wnd[0]/usr/cmbSAMPLE; bind result to String selectedItem.

Expected result

selectedItem=A1. Other control errors can fail.

Back to actions

Get status (sapGetStatus)

Read whether a checkbox or other control is selected.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultBooleantrue means selected, false means not selected. Bind to a Boolean variable. This is an action, not a condition.

Example

Check the sample checkbox, then set Field path=wnd[0]/usr/chkSAMPLE; bind result to Boolean isSelected.

Expected result

isSelected=true; after Uncheck it is false. A control with no selection state or an unreadable state fails.

Back to actions

Get table cell index (sapGetTableCellIndexByText)

Find exact whole-cell text and return its first position or every position.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
searchTextSearch textStringdefault emptyRequired.Enter the entire cell text to match, for example Alpha⁠. This is an exact match, not a substring or regular expression. Empty is rejected.
caseSensitiveSearchCase sensitive searchBooleandefault falseOptional.true needs exact case. false ignores case for the whole cell.
allOccurrencesAll occurrencesBooleandefault falseOptional.False returns the first matching row,column String, or empty String. True returns a List of all such Strings, or an empty List, in row-first scan order.

Outputs

IDTypeResult
resultAnyAny carrying a String row,column when All occurrences=false, or a List of those Strings when true. Positions start at 1. Bind to an Any variable, or a matching String/List variable for the chosen mode.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell, Search text=alpha, Case sensitive search=false, All occurrences=false; bind result to Any cellPosition.

Expected result

cellPosition is String 1,2. With All occurrences=true it is a List containing 1,2. No match gives empty String or empty List for that mode. Search text empty fails.

Back to actions

Get table cell text (sapGetTableCellTextByIndex)

Read the text at a 1-based table row and column.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
rowRowNumberdefault 1Optional.Shared.
columnColumnNumberdefault 1Optional.Shared.

Outputs

IDTypeResult
resultStringString containing the selected cell text. Bind to a String variable. Invalid indexes fail rather than return an empty placeholder.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell, Row=2, Column=2; bind result to String cellText.

Expected result

cellText=Beta. Row=0 or Column=0 fails validation; a position beyond the table fails in the control.

Back to actions

Get text (sapGetText)

Read the text of a control.

Inputs

Also uses the session and control fields.

Outputs

IDTypeResult
resultStringUses text, then value if text is not supported, then empty if neither is supported. Bind to a String variable. Other control errors fail.

Example

Put Sample in the test text field. Set Field path=wnd[0]/usr/txtSAMPLE; bind result to String fieldText.

Expected result

fieldText=Sample. A missing control fails.

Back to actions

Left click (sapLeftClick)

Same as Click. It does not move the mouse.

Inputs

Also uses the session and control fields.

Outputs

None.

Example

Set Field path=wnd[0]/tbar[0]/btn[0] on the disposable screen.

Expected result

The button or current grid cell is clicked. SAP sets the screen change; an unsupported control fails.

Back to actions

Right click (sapRightClick)

Open the control's right-click menu.

Inputs

Also uses the session and control fields.

Outputs

None.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell for a grid that has a right-click menu.

Expected result

The right-click menu opens. No item is selected. A control without this menu fails.

Back to actions

Select item (sapSelectItem)

Select a combo entry, tree node or tab by exact text or 1-based index.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
selectSelectItemSelectiondefault TEXTOptional.Shared.
itemByTextitemByTextStringdefault emptyOptional.Shared.
itemByIndexitemByIndexNumberdefault 1Optional.Shared.

Outputs

None.

Example

Use the test combo whose Alpha entry has key A1. Set Field path=wnd[0]/usr/cmbSAMPLE, Select=TEXT, itemByText=Alpha.

Expected result

The combo key becomes A1. INDEX with itemByIndex=1 selects its first entry. It also selects tree nodes and tabs. A missing item or invalid index fails.

Back to actions

Select radio option (sapSelectRadioOption)

Select a radio option.

Inputs

Also uses the session and control fields.

Outputs

None.

Example

Set Field path=wnd[0]/usr/radSAMPLE.

Expected result

The option is selected. SAP controls changes to other options. A missing control or one that cannot be selected fails.

Back to actions

Send virtual key (sapSendVirtualkey)

Send one SAP virtual key to the main session window wnd[0].

Inputs

Also uses the session and control fields (Session name only).

IDFieldType; default; requirementValue
virtualKeyToSendSelectVirtualKeydefault EnterOptional.Choose the named SAP virtual key sent to wnd[0]⁠. Enter is code 0, F11_CtrlS code 11 and F12_Esc code 12. Modifier names select those combinations; Shift_Ctrl0 is the retained value with SAP code 22. The screen decides each key effect. Choices: Enter⁠, F1⁠, F2⁠, F3⁠, F4⁠, F5⁠, F6⁠, F7⁠, F8⁠, F9⁠, F10⁠, F11_CtrlS⁠, F12_Esc⁠, Shift_F1⁠, Shift_F2⁠, Shift_F3⁠, Shift_F4⁠, Shift_F5⁠, Shift_F6⁠, Shift_F7⁠, Shift_F8⁠, Shift_F9⁠, Shift_Ctrl0⁠, Shift_F11⁠, Shift_F12⁠, Ctrl_F1⁠, Ctrl_F2⁠, Ctrl_F3⁠, Ctrl_F4⁠, Ctrl_F5⁠, Ctrl_F6⁠, Ctrl_F7⁠, Ctrl_F8⁠, Ctrl_F9⁠, Ctrl_F10⁠, Ctrl_F11⁠, Ctrl_F12⁠, Ctrl_Shift_F1⁠, Ctrl_Shift_F2⁠, Ctrl_Shift_F3⁠, Ctrl_Shift_F4⁠, Ctrl_Shift_F5⁠, Ctrl_Shift_F6⁠, Ctrl_Shift_F7⁠, Ctrl_Shift_F8⁠, Ctrl_Shift_F9⁠, Ctrl_Shift_F10⁠, Ctrl_Shift_F11⁠, Ctrl_Shift_F12⁠, Ctrl_E⁠, Ctrl_F⁠, Ctrl_Slash⁠, Ctrl_Backslash⁠, Ctrl_N⁠, Ctrl_O⁠, Ctrl_X⁠, Ctrl_C⁠, Ctrl_V⁠, Ctrl_Z⁠, Ctrl_PageUp⁠, PageUp⁠, PageDown⁠, Ctrl_PageDown⁠, Ctrl_G⁠, Ctrl_R⁠, Ctrl_P⁠.

Outputs

None.

Example

Use the disposable training screen. Set Select=Enter.

Expected result

The main window receives Enter. SAP can submit or check the screen. No field is selected by this action. A missing window or a SAP error fails.

Back to actions

Set table cell text (sapSetTableCellText)

Replace one editable table-cell text by an index or the first exact current value.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
setTextBySelectItemSelectiondefault TEXTOptional.TEXT finds the first cell whose whole text exactly equals Find Text, with case sensitivity. INDEX uses the 1-based Row and Column. Choices: TEXT⁠, INDEX⁠.
findTextFind TextStringdefault emptyOptional.Required at runtime with Select=TEXT. Enter the current whole cell value, for example Alpha⁠. Empty or no matching cell fails. INDEX ignores it.
rowRowNumberdefault 1Optional.Shared.
columnColumnNumberdefault 1Optional.Shared.
setTextSet TextStringdefault emptyRequired.Enter the replacement cell text, for example Changed⁠. It must be nonempty, so this action cannot clear a table cell to an empty string.

Outputs

None.

Example

Set Field path=wnd[0]/usr/cntlGRID/shellcont/shell, Select=INDEX, Row=2, Column=2, Set Text=Changed. Alternatively use Select=TEXT and Find Text=Beta.

Expected result

The second row Text cell becomes Changed. TEXT uses exact case-sensitive matching and changes only the first hit. Empty Set Text, no matching Find Text, bad indexes or read-only cells fail.

Back to actions

Set text (sapSetText)

Replace or add to the text of a control.

Inputs

Also uses the session and control fields.

IDFieldType; default; requirementValue
fieldValueField valueStringdefault emptyOptional.Enter the text to write, for example Sample⁠. Empty clears the field when Append text=false.
isAppendTextEnabledAppend textBooleandefault falseOptional.False replaces the current field text. True reads the current text and appends Field value with no separator.

Outputs

None.

Example

With the sample field containing Sample, set Field path=wnd[0]/usr/txtSAMPLE, Field value= note, Append text=true.

Expected result

The field becomes Sample note. Append=false writes only Field value; an empty value clears it. A noneditable or absent control fails.

Back to actions