SAP — Send key
SAP — Send key
Section titled “SAP — Send key”Type: sap-send-key · Package: SAP Activities v1.0.5
Sends a function key to the SAP window: Enter to confirm, F8 to execute, F3 to go back, F11 to save… Almost everything in SAP is triggered with one of these keys, so it is one of the most used activities.
SAP does not receive keyboard keystrokes but function codes (vkeys): every key or combination SAP understands has a fixed number, and that number is what is sent to the window. That is why the key list is closed: only the combinations in SAP’s table exist.
How it works
Section titled “How it works”Waits for SAP to finish whatever it is processing, sends the key to the window given in window (the main one, wnd[0], by default) and waits again for SAP to respond.
Then it reads the status bar:
- If SAP shows an error message (type
E) or an abort (typeA), the activity fails with that message. - Any other message is logged (warnings, type
W, as warnings). This matters because SAP reports relevant things with typeS(success) messages, such as “No table entries found for specified key”: they do not stop the flow, but they end up in the log.
The key is sent to the window, not to a specific field: you do not need to select anything first. The window must exist, though; otherwise the activity fails right away (it does not wait for it to appear).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | — | Key to send (see Available keys). With Expression you can pass a key name built at run time or the SAP vkey number itself (0–99). If it arrives empty, Enter is sent. |
Available keys
Section titled “Available keys”| Key | vkey | Common use |
|---|---|---|
Enter | 0 | Confirm, go to the next screen |
F1 … F12 | 1–12 | F1 help · F3 back · F4 value help · F8 execute · F11 save · F12 cancel |
Shift+F1 … Shift+F12 | 13–24 | Shift+F3 exit |
Ctrl+F1 … Ctrl+F12 | 25–36 | Depends on the screen |
Ctrl+Shift+F1 … Ctrl+Shift+F12 | 37–48 | Depends on the screen |
Ctrl+E · Ctrl+F · Ctrl+/ · Ctrl+\ · Ctrl+N · Ctrl+O | 70–75 | Ctrl+F find |
Ctrl+X · Ctrl+C · Ctrl+V · Ctrl+Z | 76–79 | Depends on the screen |
Ctrl+PageUp · PageUp · PageDown · Ctrl+PageDown | 80–83 | First page · previous page · next page · last page |
Ctrl+G · Ctrl+R · Ctrl+P | 84–86 | Ctrl+G find next · Ctrl+P print |
Ctrl+S | 11 | Same as F11 (save) |
What each key does depends on the screen: SAP only runs the function if that screen has it assigned. The values F11-Save, F12-Cancel and F15-Exit from playbooks saved with earlier versions still work (they are F11, F12 and Shift+F3).
The name is matched ignoring case and spaces, so in an expression "ctrl + f5", "CTRL+F5" or "Shift+Ctrl+F1" all work. F13–F24 are also accepted as another name for Shift+F1–Shift+F12, as well as PgUp/PgDn. If the value is neither a known name nor a number between 0 and 99, the activity fails listing the valid keys.
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanSapSession | — | SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on. |
window | string | "wnd[0]" | Window that receives the key. Use wnd[1] for a modal window (a pop-up dialog). |
Output
Section titled “Output”This activity does not return a value. To know what SAP answered, read it afterwards with SAP — Read status bar.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Unknown key '…'. Valid: Enter, F1-F12, Shift+F1-F12, … | The value is neither a name from the table nor a number between 0 and 99. Pick a key from the list. |
Window '…' does not exist. | The window is not open (for example, wnd[1] when the dialog already closed). Check it first with SAP — Element exists. |
SAP replied [E …]: … | After the key, SAP showed an error or an abort in the status bar. |
Plus the errors common to all activities.
Example
Section titled “Example”Open table T000 in SE16 and run the query:
SAP — Run transaction code = "SE16"SAP — Set text selector = "wnd[0]/usr/ctxtDATABROWSE-TABLENAME" value = "T000"SAP — Send key key = Enter // go to the selection screenSAP — Send key key = F8 // executeSAP — Read status bar → output: statusLog message = "SAP answered: " + str(status["text"])Find on the current screen with Ctrl+F:
SAP — Send key key = Ctrl+FSend a vkey by its number, from a variable:
SAP — Send key key = sapKey // for example 8, which is F8Confirm a pop-up dialog:
SAP — Send key key = Enter window = "wnd[1]"Related activities
Section titled “Related activities”- SAP — Read status bar — read the message SAP left.
- SAP — Press button — press a specific button on the screen.
- SAP — Press toolbar button — press a toolbar button.
- SAP — Close modal — close a pop-up dialog.