sap SAP
SAP GUI for Windows through SAP GUI Scripting: sign in, run transactions, fill fields, press buttons, read tables and the status bar. Components are addressed by their id (wnd[0]/usr/ctxtVBAK-AUART), as Capture or SAP’s script recorder gives them.
Parameters of every variant
| Parameter | Value | Default | Description |
|---|
--session | text | SAP | Session name: given at logon/attach, used by the commands after it Names a sap session opened earlier. |
Actions (--action)
--action:logon
Opens a connection of SAP Logon (started when it is not running) and signs in; the session gets the --session name.
| Parameter | Value | Default | Description |
|---|
--connection required | text | | The connection as SAP Logon lists it, e.g. "PRD - Production" |
--client required | text | | The SAP client (Mandant), e.g. 100 |
--credential required | $variable$ | | A credential variable (set --type:credential) with the SAP user and password |
--language | text | | Logon language, e.g. EN or TR; the user’s default when empty |
--multiplelogon | one of continue, endothers, fail | continue | When the user is already signed in elsewhere: continue (keep the other sessions), endothers or fail |
--timeout | number | 60 | Seconds to wait for SAP Logon to start |
--action:attach
Uses a session that is already open (signed in by hand or by single sign-on).
| Parameter | Value | Default | Description |
|---|
--connection | text | | The connection’s description (wildcards: PRD*); the first open connection when empty |
--sessionindex | number | 1 | Which window of the connection, 1 for the first |
--action:starttransaction
Starts a transaction, e.g. VA01 (/n is added by SAP).
| Parameter | Value | Default | Description |
|---|
--transaction required | text | | Transaction code, e.g. VA01 |
--action:settext
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--value required | text | | The text to enter |
--action:gettext
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--output required | variable name | | Variable that receives the result |
--action:press
Presses a button, a toolbar button or a menu entry.
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--action:select
Selects a radio button, a tab or a menu entry.
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--action:setcheckbox
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--value required | true / false | | true to tick, false to clear |
--action:setcombo
Chooses an entry of a dropdown by its key or its text.
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--value required | text | | Key or text of the entry |
--action:sendkey
Presses a function key in a window: Enter, F1–F12, Shift+F1–F12, Ctrl+F1–F12, or Back, Exit, Cancel, Save, Execute.
| Parameter | Value | Default | Description |
|---|
--key required | text | | Enter, F8, Shift+F3, Back, Save, Execute… or a virtual key number |
--window | text | wnd[0] | The window: wnd[0] is the main window, wnd[1] a pop-up |
--action:setfocus
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--action:doubleclick
Double-clicks a component, or a cell of an ALV grid with --row and --column.
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--row | number | | Grid row, 0 for the first |
--column | text | | Grid column name, e.g. VBELN |
--action:selectrows
Selects rows of an ALV grid or a table control.
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--rows required | text | | Row numbers, 0 for the first: "0,2,5" or a list variable |
--action:exists
true when the component is on the screen.
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--output required | variable name | | Variable that receives the result |
--action:getproperty
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--property required | text | | A scripting property, e.g. Text, Tooltip, Changeable, Type, Name |
--output required | variable name | | Variable that receives the result |
--action:gettable
Reads an ALV grid or a table control into a datatable (all rows, scrolling as needed).
| Parameter | Value | Default | Description |
|---|
--id required | text | | The component id, e.g. wnd[0]/usr/ctxtVBAK-AUART (Capture: click it in SAP) |
--maxrows | number | 10000 | Read at most this many rows |
--output required | variable name | | Variable that receives the result |
--action:getstatusbar
The message at the bottom of the window as a record: Type (S success, W warning, E error, A abort, I info) and Text.
| Parameter | Value | Default | Description |
|---|
--failonerror | true / false | false | Fail when the message is an error (E) or abort (A) |
--output | variable name | | Variable that receives the result |
--action:windowtitle
| Parameter | Value | Default | Description |
|---|
--window | text | wnd[0] | The window: wnd[0] is the main window, wnd[1] a pop-up |
--output required | variable name | | Variable that receives the result |
--action:logoff
Signs off and closes the connection (a session from attach is only forgotten).
No further parameters.
Examples
sap --action:logon --connection:"PRD - Production" --client:100 --credential:$sapUser$ --language:EN
sap --action:starttransaction --transaction:VA01
sap --action:settext --id:wnd[0]/usr/ctxtVBAK-AUART --value:OR
sap --action:sendkey --key:Enter
sap --action:gettable --id:wnd[0]/usr/cntlGRID1/shellcont/shell --output:rows
sap --action:getstatusbar --failonerror:true --output:status
sap --action:logoff