|
| Many
SAP ERP transactions display data in tabular form (table
control). In some cases a user might wish to get these data into an
Excel spreadsheet for further display, printing and processing. We present a simple technique using an InputScript to build an Excel spreadsheet from the table. The user selects some (or all) rows in the table and then presses a button that invokes our InputScript. The script scrolls through the whole table, collects all selected lines and generates an xxl-file. It then uses the "Start" command to start Excel for this file. Required components: InputAssistant.
|
![]() Transaction MIR6. The user selects the rows that she would like to have in the spreadsheet She then clicks on the "Download" button. The system collects all selected rows and starts Excel:
For the implementation you need the following 2 scripts: // GuiXT
Script SAPMM08N.D0201.txt // InputScript
SaveToExcel.txt OpenFile "&U[Filename]" -output// Column headings Set V[C1] "DocNo" Set V[C2] "Invoicing party" Set V[C3] "Name of invoicing party" Set V[C4] "Gross amount" AppendFile "&U[Filename]" C1 C2 C3 C4
// Variables Set V[absrow] 1 // Absolute row number Set V[relrow] 1 // Relative row number
Screen SAPMM08N.0201 GetTableAttribute T[Table] FirstVisibleRow=FVisRow LastVisibleRow=LVisRow LastRow=LastRow // First row on screen?if V[FVisRow=1] goto new_row endif // scroll to first line Enter "/ScrollToLine=1" Table="T[Table]" label new_screen Screen SAPMM08N.0201GetTableAttribute T[Table] FirstVisibleRow=FVisRow LastVisibleRow=LVisRow LastRow=LastRow Set V[relrow] 1 label new_row// end of table? if V[absrow>&V[LastRow]] goto end_of_table endif // end of screen? if V[absrow>&V[LVisRow]] Enter "/ScrollToLine=&V[absrow]" Table="T[Table]" goto new_screen endif Set V[selected] "&cell[Table,0,&V[relrow]]" // Selected? if V[selected=X] Set V[C1] "&cell[Table,Doc. no.,&V[relrow]]" Set V[C2] "&cell[Table,Invoicing party,&V[relrow]]" Set V[C3] "&cell[Table,Name of invoicing party,&V[relrow]]" Set V[C4] "&cell[Table,Gross amount,&V[relrow]]" AppendFile "&U[Filename]" C1 C2 C3 C4 endif Set V[absrow] &V[absrow] + 1Set V[relrow] &V[relrow] + 1 goto new_row label end_of_table CloseFile "&U[filename]" // Display fileStart "&U[filename]" // Back to line 1 Enter "/ScrollToLine=1" Table="T[Table]"
|