SAP — Select tree node
SAP — Select tree node
Section titled “SAP — Select tree node”Type: sap-tree-select · Package: SAP Activities v1.0.5
Selects a node of an SAP tree and, by default, double-clicks it to trigger its action: open a transaction from the SAP Easy Access menu, display a document, enter a folder.
How it works
Section titled “How it works”Waits for SAP to finish whatever it is processing, finds the tree by its selector and selects the node whose key is nodeKey. If doubleClick is on (the default), it also double-clicks it.
Double-click is on by default because in almost every SAP tree, selecting a node does nothing by itself: the action lives in the double-click. Turn it off if you only want to leave the node selected, for example before pressing a button that acts on the chosen node.
Then it waits for SAP to respond and reads the status bar: an error (type E) or an abort (type A) makes the activity fail; any other message is logged.
The node is given by its key, not by its text; take it from the output of SAP — Read tree. If the tree is not on the screen yet, the activity waits for it up to the configured limit (timeout or the scope’s elementTimeout, 30 seconds by default).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The tree. Captured selector or SAP id, for example wnd[0]/usr/cntlTREE/shellcont/shell. |
nodeKey | string | — | Node key, obtained with SAP — Read tree. |
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. |
doubleClick | bool | true | Double-click to trigger the node’s action; selecting alone usually does nothing. Also accepts an expression that returns true or false. |
timeout | number | — | Seconds to wait for the tree to appear. Overrides the scope’s elementTimeout. Empty uses the scope value (30 by default); 0 fails on the first try. Decimals allowed. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
| SAP GUI error when selecting the node | The key doesn’t exist in the tree (or its branch is collapsed). Take it from SAP — Read tree and expand the branch first with SAP — Expand tree node. |
Component '…' does not exist in the SAP session. Waited … s for it to appear. The current screen is … dynpro … (transaction …). … | The element did not appear in time. The message says which screen the session is on: it is almost always a different one than expected (a dialog in front, a step that didn’t happen). If the screen is slow, raise timeout. |
SAP replied [E …]: … | After the action, SAP showed an error (E) or an abort (A) in the status bar. The text is SAP’s. |
Plus the errors common to all activities.
Example
Section titled “Example”Open the “Monthly reports” node of a navigation tree:
SAP — Read tree selector = "wnd[0]/usr/cntlTREE/shellcont/shell" → output: nodesFor Each items = nodes itemVariable = node └─ activities: If condition = node["text"] == "Monthly reports" └─ then: SAP — Select tree node selector = "wnd[0]/usr/cntlTREE/shellcont/shell" nodeKey = node["key"]Related activities
Section titled “Related activities”- SAP — Read tree — get the node keys.
- SAP — Expand tree node — expand a branch to reach an inner node.
- SAP — Wait for element — wait for the screen the node opens to load.