Skip to content

SAP — Press button

Type: sap-press-button  ·  Package: SAP Activities v1.0.5

Presses a button on an SAP screen, as a person would with the mouse. It works for any button on the screen or in a dialog: Execute, Save, Yes, No, Continue. It also checks the status bar after pressing, so if SAP answers with an error, the flow finds out.

  1. It waits for SAP to finish processing and looks up the button by its selector, waiting for it to appear up to timeout.
  2. It presses it and waits for SAP to finish responding.
  3. It reads the status bar: if there is a message of type E (error) or A (abort), the activity fails with SAP’s text. Other messages (S, W, I) are written to the log and the flow goes on.
ParameterTypeDefaultDescription
selectorselector—Button to press. Ex: "wnd[1]/usr/btnBUTTON_1".
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
timeoutnumber—Seconds to wait for the button 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
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.

Confirm a question dialog with the “Yes” button:

SAP Element Exists selector = "wnd[1]/usr/btnBUTTON_1" → output: question
If condition = question
└─ then:
SAP Press Button selector = "wnd[1]/usr/btnBUTTON_1"