Adding Queries

This option allows you to create a query.

Context

To respond to requests from applications, you need to add the query entity to a business object. For example, the application used to display overdue invoices uses the query entity to return all overdue details from the CUSTOMER_INVOICE business object.

You can add a query to any node of a business object. A query returns the node entity instances of a business object. Only an application or another query entity can use an existing query. You cannot use a query entity to modify node instance data.

The Business Object Processing Framework (BOPF) allows a query to return any of the following:

  • Only the keys of node instances

    or

  • Entire data of a node instance
Prerequisite

You have already created a business object.

Procedure

  1. In the Project Explorer view, choose a business object.
  2. In the context menu, choose Open.

    The Overview page appears.

  3. Choose the Nodes page.
  4. Select a node.
  5. Press Ctrl + click to open the node Overview page.
  6. Choose the Queries page.
  7. Choose New.
  8. In the New Query wizard, enter the following details:
    1. Name: Enter a query name
    2. Description: This is an optional field. Enter a short description of the purpose of the query.
    3. Query Category: Based on your requirements you can choose any category. The table below provides descriptions of the various categories:
      Query Category Description
      Select All Query This is a predefined query that retrieves the result set from all attributes of a node. The framework:
      • creates this query while creating a node and implements the query
      • provides business logic for the query
      You can have only one Select All Query for a node. If a node already has the Select All Query, this option will appear disabled.
      Select By Elements Query This is a predefined query that retrieves the result set from predefined attributes of a node. In this query category, the Filter Structure is same as the Combined Structure of the node. The framework:
      • creates this query while creating a node and implements the query
      • provides business logic for the query
      You can have only one Select By Elements Query for a node. If a node already has the Select By Elements Query, this option will appear disabled.
      Custom Query This is not a predefined query. You have to implement the entire query logic. You can create multiple custom queries. A custom query contains the following fields:
      • Implementation Class: This class contains the custom query implementation. You can either choose an existing class or create a new one.
      • Filter structure: This is an optional field. It is used to declare the structure of the filter criteria used in a query. You can either choose an existing structure or create a new one.
      • Result Type: This is an optional field. It is used to accommodate the result type returned by the query. You can either choose an existing result type or create a new one. You must declare and activate the new result type.
  9. Choose Finish.

    The query appears in the query table. You can also provide an existing table type as the Result Table Type. The existing table type must have line type as the result type. To choose an existing value, choose (Browse) in the Result Table Type column.

  10. To check for correctness of business object, choose (Check ABAP Development Object) from the toolbar.
  11. To activate the business object, choose Edit > Activate ABAP Development Object.

    TIP

    You can also use (Activate ABAP Development Object) in the toolbar.