Skip to content

SAP — Export list

Type: sap-export-list  ·  Package: SAP Activities v1.0.5  ·  Output: string

Saves the list SAP is showing to a file, in a single step: it does what a person does with List → Save → Local file, but without dialogs to handle. It is the best way to get lots of data out of a classic report: with the “Text with Tabs” format you get a tab-separated file, ready to read with the CSV or Excel activities.

  1. It types %pc in the command field and presses Enter, which is SAP’s shortcut to save the list to a local file. If the export dialog doesn’t appear, it fails: the current screen is not a classic list (if it is an ALV, use SAP — Export ALV grid). It also fails if a modal window in front hides the command field.
  2. It picks the format (format) in the format dialog.
  3. It fills in the folder, the file name and, if given, the encoding in the “Save File” dialog. If the folder doesn’t end with \, it adds one.
  4. It confirms with Replace (if overwrite is on, the default) or with Generate (otherwise; SAP refuses if the file already exists).
  5. It checks the result: if SAP answers with an error, the activity fails; if there is no error but the file isn’t at the given path, it fails too. If all goes well, it returns the file’s full path.

While SAP writes the file, the activity watches for the SAP GUI security dialog that asks for permission to write to disk. If it appears inside the SAP window, it accepts it (Allow) and notes it in the log. It recognizes the dialog by its shape, not by its texts, so it works with SAP GUI in any language.

ParameterTypeDefaultDescription
pathstring—Target folder, which must exist. Ex: "C:\output\". The trailing backslash is added if missing.
fileNamestring—File name, with extension. Ex: "list.txt".
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
formatstring"Text with Tabs"Export format: Unconverted, Text with Tabs, Spreadsheet, Rich Text or HTML. “Text with Tabs” is the one a flow can process afterwards. The Clipboard format is not offered because it produces no file; an older playbook that has it fails before opening the dialog, with a message explaining why.
encodingstring—SAP codepage (for example "4110" for UTF-8). Empty uses the system default.
overwritebooltrueOverwrite if the file already exists. With false, SAP refuses if the file exists and the activity fails. Also accepts an expression that returns true or false.

Returns a string with the path of the generated file (folder + name), once it has checked that it exists.

MessageCause and fix
%pc did not open the export dialog. The current screen is not a classic list: if it is an ALV use sap-grid-export.The screen is not a classic list. For an ALV use SAP — Export ALV grid.
There is no command field. Is a modal window open in front?A dialog covers the main window. Close it with SAP — Close modal.
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.

Look up table T000 in SE16 and save it as tab-separated text:

SAP Run Transaction code = "SE16"
SAP Set Text selector = "wnd[0]/usr/ctxtDATABROWSE-TABLENAME" value = "T000"
SAP Send Key key = Enter
SAP Press Toolbar Button selector = "wnd[0]/tbar[1]/btn[8]"
SAP Export List path = "C:\output\" fileName = "t000.txt" format = Text with Tabs → output: file
Log message = "Exported: " + file