SAP — Screenshot
SAP — Screenshot
Section titled “SAP — Screenshot”Type: sap-screenshot · Package: SAP Activities v1.0.5 · Output: string
Saves an image of the SAP window to a file. It serves as evidence of what the robot had in front of it: the result of a transaction, an error message, the state of a document before saving it. It returns the full path of the generated file.
How it works
Section titled “How it works”Creates the target folder if it does not exist, waits for SAP to finish whatever it is processing and asks SAP GUI to capture the window given in window (the main one, wnd[0], by default) into the file filePath.
When done, it checks that the file actually exists; if SAP did not write it, the activity fails.
Since the capture writes to disk, SAP GUI may show its security dialog asking for permission to write the file. While the capture lasts, the activity watches for that dialog inside the SAP window and accepts it, leaving a warning in the log. It does not touch windows of other applications.
The window must exist at capture time; otherwise the activity fails right away (it does not wait for it to appear).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
filePath | string | — | Target .png file. E.g. "C:\evidencias\paso1.png". Use an absolute path: a relative one is resolved against the robot’s working folder. |
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. |
window | string | "wnd[0]" | Window to capture. Use wnd[1] to capture a pop-up dialog. |
Output
Section titled “Output”Returns a string with the full (absolute) path of the image file.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Window '…' does not exist. | The window is not open at that moment. The activity does not wait for it to appear. |
SAP did not write the screenshot file. | SAP GUI did not create the file: check write permissions on the folder and that nobody denied SAP GUI’s security dialog. |
'filePath' is required. | filePath is missing. |
Plus the errors common to all activities.
Example
Section titled “Example”Keep evidence if a report run fails:
Try / Catch errorVariable = error ├─ try: │ SAP — Run transaction code = "SE16" │ SAP — Set text selector = "wnd[0]/usr/ctxtDATABROWSE-TABLENAME" value = "T000" │ SAP — Send key key = Enter └─ catch: SAP — Screenshot filePath = "C:\evidencias\se16_" + now().ToString("yyyyMMdd_HHmmss") + ".png" → output: capture Log level = error message = "The query failed. Evidence: " + captureRelated activities
Section titled “Related activities”- SAP — Read status bar — also log SAP’s message.
- SAP — Maximize — enlarge the window before capturing it.
- SAP — Save file dialog — save data (not images) to a file.