SAP — Save file dialog
SAP — Save file dialog
Section titled “SAP — Save file dialog”Type: sap-save-file-dialog · Package: SAP Activities v1.0.5 · Output: string
Fills in SAP’s save dialog and confirms it. It is the last step of almost any download from SAP: after the action that opens the dialog (exporting an ALV grid, a transaction’s own download button, the menu entry that saves the list to a local file), this activity picks the format, types the folder and the name, and generates the file. It returns the full path of the file.
How it works
Section titled “How it works”The activity handles the two screens SAP usually shows when downloading:
- Format. If the dialog asking for the format (unconverted, text with tabs, spreadsheet…) is in front, it selects the one in
formatand moves on. If SAP does not ask for the format, this step is skipped andformathas no effect. - Save file. It types the folder (
path), the name (fileName) and, if given, the code page (encoding). Then it presses Replace ifoverwrite = true(the default) or Generate ifoverwrite = false.
Important details:
- If
pathdoes not end in\, the activity adds the trailing backslash (SAP joins folder and name as they are). - If it does not find the save dialog in window
window(wnd[1]by default), it fails with a message reminding you that this activity goes after the one that opens the dialog. - If SAP answers with an error (type
E) or an abort (typeA), the activity fails with that message. - When done, it checks that the file actually exists at the path; the dialog closing does not guarantee that it was written.
- Since the download writes to disk, SAP GUI may show its security dialog asking for permission. While the download lasts, the activity watches for that dialog inside the SAP window and accepts it, leaving a warning in the log. It recognizes the dialog by its shape, not by its texts, so it works with SAP GUI in any language.
Unlike other SAP activities, this one does not wait for the dialog to appear: it must be open when the activity starts.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Target folder, which must exist. E.g. "C:\salidas\". The trailing backslash is added if missing. |
fileName | string | — | File name with extension. E.g. "facturas.txt". |
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. |
format | string | "Text with Tabs" | Format, when SAP asks for it first: Unconverted · Text with Tabs · Spreadsheet · Rich Text · HTML. Text with Tabs is the one a playbook can easily process afterwards. The Clipboard format is not offered because it produces no file; an older playbook that has it fails with a message explaining why. |
encoding | string | — | SAP code page (for example "4110" for UTF-8), typed into the ctxtDY_FILE_ENCODING field. Empty uses the system default. |
overwrite | bool | true | Overwrite the file if it already exists (Replace button, btn[11]). With false it uses Generate (btn[0]): if the file exists, SAP refuses (“already exists”) and the activity fails. Also accepts an expression that returns true or false. |
window | string | "wnd[1]" | Dialog window. |
Output
Section titled “Output”Returns a string with the path of the generated file: folder + name, as you gave them (with the trailing backslash added if it was missing). It only returns it after checking that the file exists.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
The Clipboard format is not supported: SAP copies the list to the clipboard and never opens the save dialog, so there is no file to write. … | An older playbook has format = Clipboard. Choose another format. |
Unknown format '…'. Valid: Unconverted, Text with Tabs, Spreadsheet, Rich Text, HTML. | format is not in the list (compared case-insensitively). |
There is no save dialog at wnd[1]. This activity goes AFTER the one that opens it (sap-export-list, sap-grid-export, or the transaction's own button). | The folder field (ctxtDY_PATH) is not in the dialog window. The activity does not wait for it to appear. |
The dialog has no btn[11] button. (or btn[0]) | The dialog in front is not SAP’s standard “Save File”. Drive it by hand with SAP — Press button. |
SAP refused the download [E …]: … | SAP answered with an error, for example a folder that doesn’t exist or, with overwrite = false, a file that already exists. |
SAP left no error but the file was not written. … | The dialog closed but the file is not at the path. If the message adds If the machine asks for write permission and nobody answers, the download never happens, check SAP GUI’s security dialog (Options → Security). |
Plus the errors common to all activities.
Example
Section titled “Example”Download, as text with tabs, the result of a report shown in an ALV grid:
SAP — Run transaction code = "ZREPORTE01"SAP — Send key key = F8SAP — Export ALV grid selector = "wnd[0]/usr/cntlGRID1/shellcont/shell" menuItem = "&PC"SAP — Save file dialog path = "C:\salidas\" fileName = "reporte.txt" format = Text with Tabs → output: fileLog message = "Downloaded to " + fileRelated activities
Section titled “Related activities”- SAP — Export ALV grid — open an ALV grid’s download; complete it with this activity.
- SAP — Export list — download a classic list end to end (it already includes this dialog).
- SAP — Select menu — reach the dialog through the menu bar.
- SAP — Screenshot — save an image of the screen.