Skip to content

SAP — Set checkbox

Type: sap-set-checkbox  ·  Package: SAP Activities v1.0.5

Checks or unchecks an SAP checkbox, such as “Test run”, “Show details” or any yes/no option on a selection screen.

Waits for SAP to finish whatever it is processing, finds the checkbox by its selector and leaves it in the state you set with checked: checked (true, the default) or unchecked (false).

The activity sets the state; it does not toggle it. If the checkbox was already as requested, it stays that way. So the result is always the same, no matter how the robot found the screen.

If the checkbox 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 checkbox. Captured selector or SAP id, for example wnd[0]/usr/chkP_TEST.
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
checkedbooltruetrue to check, false to uncheck. Also accepts an expression that returns true or false; empty counts as true.
timeoutnumber—Seconds to wait for the checkbox 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.
'checked' must be true or false; got '…'.The checked expression gave neither true nor false.

Plus the errors common to all activities.

Uncheck the test run option before executing a report:

SAP — Run transaction code = "ZREPORTE01"
SAP — Set text selector = "wnd[0]/usr/ctxtP_BUKRS" value = "1000"
SAP — Set checkbox selector = "wnd[0]/usr/chkP_TEST" checked = false
SAP — Send key key = F8