Purpose Submit a report via RFC (Call statement) and process the list output, or read the resulting ALV grid data ABAP reports are used in the implementation of numerous business functions in the SAP system. They either produce a standard list output (free format) or they display tabular data in a grid control via the the ABAP list viewer ALV. In some cases the reports can be started via a transaction code, for example, IW39 (selection of PM orders, ABAP report RIAUFK20) or IW59 (selection of service notifications, ABAP report RIQMEL20) . |
Solution Use the function module /guixt/submitreport. Example 1 At the right hand side of the above picture you see the "System->Status" popup which shows the underlying program RIAUFK20, here in an S/4HANA system. Alternatively you may use transaction SE93 to display the transaction type and the underlying ABAP program:
There are two ways to pass the selection parameters to
/guixt/submitreport: In this example we assume that there is a selection variant "OPENORDERS" defined in IW39 which we want to use:
The selection variant OPENORDERS also defines the layout of the resulting grid control:
The "Displayed columns" are precisely the columns that are returned by /guixt/submitreport.
InputScript // copy grid data into CSV file // display the file (Excel)
Result
Example 2
The material texts are read from the database (table MAKT) and the sales figures via the sales information system:
The underlying transaction is MCTC and the ABAP report is RMCV0200:
GuiXT Script // list of selectable years Set V[year1] &V[year0] - 1 Set V[year2] &V[year0] - 2 Set text[list_of_years] "&V[year0];&V[year1];&V[year2]"// default: current year Set V[selected_year] "&V[year0]" endif // year selection DropDownList (1,20) "list_of_years" width=10 refer="V[selected_year]" -noSort // button to read statistics data // table to enter material numbers and display the sales figures name="matorders" fixedColumns=5 Column "Material" size=16 name="matnr" searchHelp="MAT1" Column "Text" -readOnly size=40 name="maktx" Column "Incoming orders" -readOnly size=16 name="orders" Column "Sales volume" size=16 name="sales" -readOnly Column "Billing Qty" size=16 name="quantity" -readOnly
InputScript // First we check the entered material numbers
and read the material texts Set V[k] 0// table for report selection parameters CreateTable V[myparams] include=V[rsparams] // process all table rows if V[k<&V[matorders.rowcount]] Set V[k] &V[k] + 1// read table row Nr. k ReadRow V[matinfo] table=V[matorders] index=&V[k] // material number specified? if V[matinfo.matnr] // read material text and also return matnr in internal format // we use the cache so that each material is read only once if // the user presses the "Read" button again Call text[r] Call /guixt/dbselect cache="transaction" _ in.table="MAKT" _ in.fields="MAKTX,*MATNR" _ in.condition="SPRAS = '&V[_language]' and MATNR = @MATNR" _ in.domname1="MATNR" _ in.domvalue1="&V[matinfo.matnr]" _ table.values="r" // material text and matnr in internal format CopyText fromText="r" toString="maktx" line=1 CopyText fromText="r" toString="intmatnr" line=2 // set material
text if not V[maktx] // clear existing text UpdateRow V[matinfo] table=V[matorders] index=&V[k]
// set cursor to
wrong material number Set V[relposrow] &V[k] - &V[matorders.stat.firstvisiblerow] Set V[relposrow] &V[relposrow] + 1 SetCursor cell[matorders,matnr,&V[relposrow]] endif // display error message Message "E: Material &V[matinfo.matnr] not found" -statusline // teminate processing return endif // append material number Set V[rsparams.selname] "SL_MATNR" Set V[rsparams.kind] "S" Set V[rsparams.sign] "I" Set V[rsparams.option] "EQ" Set V[rsparams.low] "&V[intmatnr]" AppendRow V[rsparams] table=V[myparams] else Clear V[matinfo] endif // update the row, i.e. set the material text UpdateRow V[matinfo] table=V[matorders] index=&V[k] goto next_row endif // set sales organization selection Set V[rsparams.kind] "S" Set V[rsparams.sign] "I" Set V[rsparams.option] "EQ" Set V[rsparams.low] "1010" AppendRow V[rsparams] table=V[myparams] // set period selection Set V[rsparams.kind] "S" Set V[rsparams.sign] "I" Set V[rsparams.option] "BT" Set V[rsparams.low] "&V[selected_year]01" Set V[rsparams.high] "&V[selected_year]12" AppendRow V[rsparams] table=V[myparams] // Start report RMCV0200 for the entered material numbers // csvdata has only
one component ("feld") // submit reportCall "/guixt/submitreport" _ export.progname="progname" _ export.params="myparams" _ import.csvdata="csvdata" // we transform the CSV format into GuiXT structured table CreateTable V[mysales] include=V[mysalesinfo] CopyText fromTable=V[csvdata] toText="temp" CopyText fromText="temp" toTable=V[mysales] delimiter=";" // finally we merge the sales values into our table label merge_salesif V[k<&V[matorders.rowcount]]Set V[k] &V[k] + 1 // read table
row if V[matinfo.matnr] // table lookup in the sales figure table ReadRow V[mysalesinfo] table=V[mysales] key="&V[matinfo.matnr]" if q[ok] Set V[matinfo.orders] "&V[mysalesinfo.orders]" Set V[matinfo.sales] "&V[mysalesinfo.sales]" Set V[matinfo.quantity] "&V[mysalesinfo.quantity]" else Clear V[matinfo.orders] Clear V[matinfo.sales] Clear V[matinfo.quantity] endif // update table row (sales figures) UpdateRow V[matinfo] table=V[matorders] index=&V[k] endif // next rowgoto merge_sales endif return
|
Components InputAssistant |