TB1200 93 Query Practice
TB1200 93 Query Practice
PUBLIC
PRACTICE: QUERIES PUBLIC
INTRODUCTION
These practice exercises are designed to give you hands-on use in creating basic SQL queries for SAP
HANA using the built-in query tools in SAP Business One.
PREREQUISITE:
1. Use the demo database for SAP Business One 9.3, version for SAP HANA
2. Credentials: User code: manager
Use either of the SAP Business One query tools: Query Generator or Query Wizard. Note: the solutions are
shown for the Query Generator only. All queries shown here use the HANA SQL syntax.
Important note: The reports included in this case study show data from the UK localization database. The
data you will see will obviously be different depending on your localization and the date you run the
queries.
2
PRACTICE: QUERIES PUBLIC
1. Create a query using the following fields from the OCRD Business Partners table: CardCode,
CardName, Address, City (Bill-to city), ZipCode, Balance, CntctPrsn.
2. Since the OCRD table also contains records for vendors and leads you need to filter customer
records using the CardType = ’C’ condition.
3. In the query results, sort the results alphabetically by customer name and add a total to the
account balances column.
4. Save the query in a new category called Sales and choose the Assign Group button to assign the
category to the Saved Queries – Group No.1 authorization group.
5. Run the saved query from the Tools menu.
Note: When using a HANA database, multi-case field names must be enclosed in double quote marks
in the query.
The query and the results should look something like this:
Note: When you hold your mouse over the Total field, the field name does not display in system
information. This is because this field holds the currency symbol as well as the amount. The
database field name is DocTotal.
Save this query with the name Invoice List in the Sales category.
This query will display a list of open sales quotations summarized by customer and grouped by sales
employee. The query will use two tables:
▪ Sales Quotation (OQUT)
▪ Sales Employee table (OSLP)
The inner join will be provided for you by the query tool.
Create the query
Select the OSLP table and then select the SlpName field.
Select the OQUT table and then select the CardCode and CardName fields.
Calculate the total value of the sales quotations using the SUM function and provide a column
heading in the report:
SUM(T0."DocTotal") as “Total Value”
Count the number of sales quotations for each customer using the COUNT function and provide a
heading:
COUNT(T0. "DocNum") as “No of Documents”
Filter the query so that only open quotations are used:
T0."DocStatus" = ‘O’
This report displays all the sales orders posted for today, organized by sales employee name. The
report uses the ORDR table and the OSLP table. The report is saved then can be later used with an
alert to provide a daily worklist for a user.
Preparation: Create 2-3 sales orders for customers, with today’s posting date. Select a discount %
in each order.
Select the sales employee name, document number, card code, document total and discount.
SUM the document total from each sales order, combined with the OVER clause to keep a running
total for each sales employee.
Only select sales orders for the current day:
INFORMATION: The report can be scheduled to run daily and sent to a user using the alert
mechanism. This will be covered in the case study for alerts.
Set up a count widget that counts the number of deliveries created each day.
Find the newly created widget in the Widget Gallery (choose Business Object Count in the
dropdown box) and add it to the cockpit.