Purpose Export selected data from an table control to an excel file Many SAP ERP transactions display data in tabular form (table control). In some cases, users may want to download this data to Excel in order to display it in a different format, print it or process it further. Here we present a simple method how to create an Excel spreadsheet from the SAP ERP table using an InputScript. The user selects some or all lines of the table and then calls the InputScript by clicking on the corresponding pushbutton. The script scrolls through the entire table, collects all selected rows and generates an xls file. The Start statement is then used to call Excel with this file. |
Solution Transaction MIR6:
Result: GuiXT Script SAPMM08N.D0201.txt: Pushbutton (toolbar) "Download selected data" process="SaveToExcel.txt" InutScript "savetoexcel.txt:
Parameter
Filename
"C:\temp\Invoices.xls"
// Column headings AppendFile "&U[Filename]" C1 C2 C3 C4
//
Variables
Screen
SAPMM08N.0201
GetTableAttribute
T[Table]
FirstVisibleRow=FVisRow _
//
First
row
on
screen?
//
scroll
to
first
line
label
new_screen
Screen
SAPMM08N.0201
GetTableAttribute
T[Table]
FirstVisibleRow=FVisRow
_
Set
V[relrow]
1
label
new_row
//
end
of
table?
//
end
of
screen?
Set
V[selected]
"&cell[Table,0,&V[relrow]]"
//
Selected?
if
V[selected=X]
Set
V[absrow]
&V[absrow]
+
1
label
end_of_table
CloseFile
"&U[filename]"
//
Display
file
//
Back
to
line
1
|
Components |