Skip to content

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.

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

ParameterTypeDefaultDescription
selectorselector—The tree. Captured selector or SAP id, for example wnd[0]/usr/cntlTREE/shellcont/shell.
nodeKeystring—Node key, obtained with SAP — Read tree.
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
doubleClickbooltrueDouble-click to trigger the node’s action; selecting alone usually does nothing. Also accepts an expression that returns true or false.
timeoutnumber—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.

This activity does not return a value.

MessageCause and fix
SAP GUI error when selecting the nodeThe 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.

Open the “Monthly reports” node of a navigation tree:

SAP — Read tree selector = "wnd[0]/usr/cntlTREE/shellcont/shell" → output: nodes
For 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"]