Skip to content

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.

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 (type A), the activity fails with that message.
  • Any other message is logged (warnings, type W, as warnings). This matters because SAP reports relevant things with type S (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).

ParameterTypeDefaultDescription
keystring—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.
KeyvkeyCommon use
Enter0Confirm, go to the next screen
F1 … F121–12F1 help · F3 back · F4 value help · F8 execute · F11 save · F12 cancel
Shift+F1 … Shift+F1213–24Shift+F3 exit
Ctrl+F1 … Ctrl+F1225–36Depends on the screen
Ctrl+Shift+F1 … Ctrl+Shift+F1237–48Depends on the screen
Ctrl+E · Ctrl+F · Ctrl+/ · Ctrl+\ · Ctrl+N · Ctrl+O70–75Ctrl+F find
Ctrl+X · Ctrl+C · Ctrl+V · Ctrl+Z76–79Depends on the screen
Ctrl+PageUp · PageUp · PageDown · Ctrl+PageDown80–83First page · previous page · next page · last page
Ctrl+G · Ctrl+R · Ctrl+P84–86Ctrl+G find next · Ctrl+P print
Ctrl+S11Same 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.

ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
windowstring"wnd[0]"Window that receives the key. Use wnd[1] for a modal window (a pop-up dialog).

This activity does not return a value. To know what SAP answered, read it afterwards with SAP — Read status bar.

MessageCause 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.

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 screen
SAP — Send key key = F8 // execute
SAP — Read status bar → output: status
Log message = "SAP answered: " + str(status["text"])

Find on the current screen with Ctrl+F:

SAP — Send key key = Ctrl+F

Send a vkey by its number, from a variable:

SAP — Send key key = sapKey // for example 8, which is F8

Confirm a pop-up dialog:

SAP — Send key key = Enter window = "wnd[1]"