Skip to content

SAP — Close modal

Type: sap-close-modal  ·  Package: SAP Activities v1.0.5  ·  Output: boolean

Closes an SAP modal window: a dialog that opens on top of the main screen and blocks it, such as the system messages shown at logon. If none is open, it does nothing and doesn’t fail, so you can place it “just in case” wherever a dialog sometimes appears and sometimes doesn’t.

It waits for SAP to finish whatever it is processing and looks for the window given in window (by default wnd[1], the first modal). If it exists, it closes it, as with the window’s X: it doesn’t press any of its buttons or accept its content. If it doesn’t exist, it notes that in the log and goes on.

It returns true if it closed a window and false if there was none, in case you want to know whether the dialog appeared.

None.

ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
windowstring"wnd[1]"Window to close. Use wnd[2] when one dialog sits on top of another.

Returns a boolean: true if there was a modal window and it closed it, false if there was none. The log shows Window … closed. or There was no window ….

No window is not an error: the activity returns false. It can only fail with the errors common to all activities, such as a missing session.

Close the system messages that may appear right after logon:

SAP Logon connection = "DEVELOP" client = "001"
user = credential("sap-dev")["user"] password = credential("sap-dev")
└─ body:
SAP Close Modal
SAP Run Transaction code = "SE16"

Record whether the dialog showed up at all:

SAP Close Modal → output: hadDialog
If condition = hadDialog
└─ then:
Log level = warning message = "SAP showed a dialog and it was closed"