Queries and Reports 
The Query component of SAP Sourcing provides customizable access to data. In particular, queries drive the following:
Lists, such as All Suppliers
Object pickers, such as Search Contents by Supplier
Channels, such as the Activities channel
Reports, such as System Activity
The selection of objects to be exported
The Query component has been developed to allow implementers to customize and extend these areas of the product. This section describes query capabilities and explains how to create and manage queries using the Query Definition, Query Group, and Report options in Setup. Run-time personalization of query filtering and results display is also available in each list page.
In SAP Sourcing, working with queries assumes knowledge of SQL and a basic understanding of the SAP Sourcing data model. The data model reference is available in a separate document through the SAP Professional Services organization.
SAP Sourcing is delivered with a broad set of queries. These queries are not modifiable as part of the implementation. It is possible, however, to view the definition of these standard queries, use them as a model for custom queries, and incorporate the custom queries either as additions or replacements in the user's view of the system. For details on integrating queries, see Query Groups.
In a list page, a user can save filter and display personalization options in a named object, called a “saved search”. All saved searches on a list page can be seen in the dropdown list of queries. Beneath the list of query names in the drop-down list is a divider; beneath the divider are the user-entered saved search names. However, the list page does not have an action to delete any saved searches. To delete a saved search or to see the saved searches for all object types, a user can add the Saved Search channel on a portal page.
The Saved Search channel shows up to 10 saved searches for the user. A complete set of saved searches for the user is available via the More Details report link in the channel. Each row in the channel or the more detailed report contains the name of the object type and the user-entered saved search name. The saved search name is presented as a link. Choosing the link will navigate to the object type’s list page and execute the associated query with the options that are specified in the saved search. Each row also displays a trash can icon that can be pressed to delete the saved search.
At the lowest level, a typical query is a single SQL SELECT statement. SAP Sourcing adds powerful functionality that enhances the query development and results presentation, and provides the integration of the SQL statement with the application. Key query capabilities are as follows.
Formatting
For each result column identifying the type of data presented, the appropriate presentation format is automatically selected, for example, right justified for monetary amounts. Additionally, data can be formatted to display as a hyperlink to enable navigation to other system objects or to provide drill-down linking of queries.
Prompting
SAP Sourcing queries can include one or more user-supplied parameters. The Query component supports a simple, powerful wild-card model.
Paging, Sorting and Searching
SAP Sourcing queries support sorting and searching within the returned result set. Clickable sort arrows on the heading of each column allow the results to be resorted based on any single result column. Clicking again toggles the sort direction between ascending and descending. Additionally, it is possible to move forward and backward through pages of the result set, and to search for any entered value in any column of the results set.
Totaling
SQL queries can incorporate totaling, but generally this only shows summary results. The Query component adds the ability to generate column totals while still returning detailed results information, for example, showing each auction in a category, with the total dollar value included, rather than simply returning one line of total information.
Tokens
The Query component incorporates powerful token substitution that significantly simplifies the development and enhances the usability of common query features. For example, a typical query might show all RFPs associated with the current user. Without token substitution, the query would have to prompt for the user name at runtime. The token CURRENT_USER_ID can be used in the query definition to automatically filter the results based on the user executing the query. This eliminates the need to prompt the user at runtime, and simplifies the query definition by eliminating the need to join to the user account definition tables.
Charting
The Query component is integrated with a charting servlet that allows automatic generation of various chart types from the query results. The charts include hot-spots for hyperlinks included in the query results, and the option to automatically aggregate an Other category, keeping the number of data elements shown in the chart usable.
For performance reasons, query definitions and groups are cached. (See Cache Configuration for details.) Note that queries and groups should not be edited directly in a production database. They should be edited in a staging database and migrated as a unit to a production database.
A report is the presentation of the results of one or more queries. The queries in a report are listed in the report elements tab of the report document. All queries in the report are executed, so multiple tables and charts can appear on one page or be distributed as a PDF document. The order and relative position of the results of each query can be tailored.
Some reports appear in channels on the workbench. Reports can be launched from the Analysis page. Some reports are document-type-specific and can be launched from a drop-down list in the document toolbar. Reports can also be scheduled to be executed at a certain date and time or at regular intervals. The results of a scheduled report can be announced by an alert or be delivered as a PDF document via e-mail to multiple addresses, including those for people who do not have access to the SAP Sourcing system.
One step in implementing a report is to edit one or more objects that control where the report is executed in the system and where its results are displayed. Query parameter names and values can be stored in these objects, to be passed to the report's query (or queries) when the report is executed. The common locations to trigger a report are:
Analysis page
Workbench report channel
Document toolbar
The Analysis page can be configured to add the new report to one of the subcategories on the page. This is done using the Analysis Reports Setup option in Setup.
Using the Edit button on a Workbench page, a channel can be configured to run the report. The report is run automatically, with no user action needed to start it.
A report that is designed to show data related to a single document (such as an RFx) can be added to a list of reports available in the toolbar for documents of that type. This is done using the Document Report Configuration option in Setup. Each of these reports should have a query with the Number parameter CurrentDocument. The object ID of the current document being viewed will be passed as the value of this parameter to the query when the report is executed. Supplier RFx Response Status is an example of such a report.
If a report is to be available as a drill-down from another report, its location is specified differently. To create the drill-down, the parent query must include a column of the Internal Link type, with a value structured as in the following example:
'/analysis/report?queryGroupName=FCI-Analytics2=Value'
In the link, analysis/report identifies the report page, and parameter values follow the question mark. The queryGroupName is required and contains the name of the Query Group defining the report as its value. Any parameters being passed into the query as filter prompts follow the query group name as name/value pairs, separated by ampersands (&). Note also that the report page name can be generated using the <%REQUEST_PAGE_PATH%> token to display the linked report on the same page as the original report. This can be useful with reports used both as a Workbench channel and in the Reports module.
The subsequent documentation within this Queries and Reports section describes the customizing options in Setup.