Skip to content

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.

The activity handles the two screens SAP usually shows when downloading:

  1. Format. If the dialog asking for the format (unconverted, text with tabs, spreadsheet…) is in front, it selects the one in format and moves on. If SAP does not ask for the format, this step is skipped and format has no effect.
  2. Save file. It types the folder (path), the name (fileName) and, if given, the code page (encoding). Then it presses Replace if overwrite = true (the default) or Generate if overwrite = false.

Important details:

  • If path does 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 (type A), 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.

ParameterTypeDefaultDescription
pathstring—Target folder, which must exist. E.g. "C:\salidas\". The trailing backslash is added if missing.
fileNamestring—File name with extension. E.g. "facturas.txt".
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
formatstring"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.
encodingstring—SAP code page (for example "4110" for UTF-8), typed into the ctxtDY_FILE_ENCODING field. Empty uses the system default.
overwritebooltrueOverwrite 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.
windowstring"wnd[1]"Dialog window.

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.

MessageCause 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.

Download, as text with tabs, the result of a report shown in an ALV grid:

SAP — Run transaction code = "ZREPORTE01"
SAP — Send key key = F8
SAP — 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: file
Log message = "Downloaded to " + file