When you use a query in an approval procedure, the query must use the SELECT DISTINCT clause, so that the result is a TRUE statement if the conditions of the query are met. A TRUE statement will trigger an approval procedure; a FALSE statement will not.
An example is shown above, where two conditions must be met for an approval - the customer account balance is over 10,000 and the order total is higher than 2500. The query will select from the sales order table ORDR and the business partner master data OCRD.
When you write a query for an approval procedure, you will need to reference information in the active window. The active window is the one the originator is working in. This is in contrast to standard queries where you select information from the database.
To refer to a field in the active window, you must include a $ sign in front of the field.
In the query shown here, a $ sign is used with the CardCode and DocTotal fields in the active sales document.
The $ sign is not needed for fields that are stored in the database, such as the balance field from the master data record.
Note: You can only use this query for sales orders, since the table and field name are unique to a specific table, in this case the sales order table ORDR.