Operating the Search Help Generator

Objective

After completing this lesson, you will be able to operate the search help generator

Search Help Operation Mapping

Development flow: Search help generator

Since AS ABAP 7.40 SP07, you can map a DDIC search help to generate source code for read and query operations. CUD methods are not supported because a search help does not change any data. In the first release, the search help needed to be imported first to create an entity type and set before it could be mapped. But already with SP09, both steps were combined in one wizard.

Development steps: Search help generator

The implementation process starts with importing the search help interface. Beside creating an entity type and set, this also generates the mapping for the read and query operations. After generating the runtime artifacts, the read operations can already be tested.

CUD methods are out-of-scope when mapping a search help. These can either be mapped to suitable function modules or implemented directly.

Screenshot flow about importing a search help in SEGW

To import a search help, right-click Data Model and choose ImportSearch Help. This opens the first step of the Import from Search Help Wizard.

Screenshot flow about the Import from Search Help wizard in SEGW

The Import from Search Help Wizard consists of the following steps:

  1. In the first screen, you enter a name for the entity type.
  2. Using the value help, you select the search help to be imported.
  3. When the option Create Default Entity Set is selected, the wizard creates an entity set called <Name of entity type>Set, for example, CountrySet.
  4. Select the Query and Read checkboxes to generate code mapping for these operations.
  5. In the next screen, you select the fields of the RESULT_LIST[], which should become properties of the entity type.
  6. Finally you choose the key field(s). Every entity type in OData must have at least one key field. It is also possible to rename the properties and labels.

    Caution

    It is crucial to select the key field(s). If you miss this step, the code mapping will be incomplete.
Screenshots of search help wizard result in SEGW

The wizard has performed the mapping for the read and query operations. Expand Service Implementation<EnititySet>GetEntity (Read) or GetEntitySet (Query) and double-click Mapping to inspect the result.

For the query method, the range tables have been mapped so that $filter and navigation is supported. For the read method, an input parameter has been mapped for the property that has been marked as a key field. You may generate the runtime artifacts and start testing.

Screenshot of GET request providing technical keys in /WIFND/MAINT_SERVICE

The whole reason why a search help can be used for code mapping is quite simple: In the UI of an application, the task of a search help is to support the user in identifying, finding, or entering technical key values, for example in a dropdown. This is true for classical screens as well as SAPUI5. The only difference is that an SAPUI5 app gets its data via OData requests.

In our example, every business partner has the field Country consisting of a technical key. To get the actual name of the country, we must navigate or expand to countries. Although we may know many abbreviations for countries by heart, some may be difficult to remember like "AX".

So, importing a search help in an SAP Gateway project allows to reuse DDIC elements created years ago in a totally different environment still serving their purpose.

Create an SAP Gateway Service with the Search Help Generator

Business Example

You are a developer or solution architect in your company. You need to import and map a data dictionary search help to read and query operations of an SAP Gateway service.

Template:
GW100_S_BORRFC (SAP Gateway Project)
Solution:
GW100_S_SEARCHHELP (SAP Gateway Project)

Note

This exercise requires an SAP Learning system. Login information are provided by your system setup guide.

Note

You may continue with your solution of the previous exercise or copy the template to ZGW100_##_SEARCHHELP. Whenever the values or object names in this exercise include ##, replace ## with the number of your user.

Prerequisites

The query operation for business partner was implemented in exercise Add an Additional Entity to a Data Model.

Task 1: Define the Entity Country based on a Value Help

Steps

  1. In the SAP Gateway Service Builder on your SAP S/4HANA (S4H) system, import the parameters of the search help F4_INTCA as entity Country. Map parameter LAND1, renaming it to Key, and parameter LANDX, renaming it to Name. Set the Key field as key.

    1. In the SAP Easy Access of your S4H, search for SAP Gateway Service Builder or start transaction SEGW.

    2. In the SAP Gateway Service Builder, in the Data Model context menu, choose ImportSearch Help.

    3. In the Import from Search Help popup, enter the following values:

      FieldValue
      Entity Type NameCountry
      Name (Import Search Help)F4_INTCA
    4. Choose Next.

    5. Expand the RESULT_LIST[] tree node.

    6. Select the checkbox for parameters LAND1 and LANDX.

    7. Choose Next.

    8. Select the Is Key checkbox for the Key field.

    9. Change both Complex/Entity Type"F4intca" to Country.

    10. Change the Name"Land1" to Key.

    11. Change the Name"Landx" to Name.

    12. Choose Finish.

    13. Choose Save.

Task 2: Model a Navigation between Country and Business Partner

Steps

  1. Model navigation Country_BusinessPartners between the Country and BusinessPartner entities, connecting one Key to many Country. Create the navigation properties BusinessPartners and CountryName in the according entity types.

    1. In the SAP Gateway Service Builder of your S4H, expand the Data Model node.

    2. In the context menu of Associations, choose Create.

    3. In the Create Association popup, in the Association Name field, enter Country_BusinessPartners.

    4. Select the Create checkbox related to the Navigation Property for the Dependent Entity.

    5. For the Principal Entity, enter the following values:

      FieldValue
      Entity Type NameCountry
      Cardinality1
      Navigation PropertyBusinessPartners
    6. For the Dependent Entity, enter the following values:

      FieldValue
      Entity Type NameBusinessPartner
      Cardinality1..n
      Navigation PropertyCountryName
    7. Choose Next.

    8. In the Dependent Property field, enter Country by using the value help.

    9. Choose Next.

    10. Choose Finish.

    11. Choose Save.

Task 3: Check the Mappings of the Query and Read Operations for Country

Steps

  1. Check the mapping of the read and query operations of entity set CountrySet to the search help F4_INTCA and generate the runtime objects.

    Hint

    If the mapping is incomplete, check if you set the Key field in the Country entity type as key and complete the mapping.
    1. In the SAP Gateway Service Builder of your S4H, expand the Service ImplementationCountrySet node.

    2. Double-click the node GetEntity (Read)Mapping.

    3. The following mappings exist:

      Entity Set propertyMappingData Source Parameter
      KeyLAND1
      KeyRESULT_LIST\LAND1
      NameRESULT_LIST\LANDX
    4. Double-click node GetEntitySet (Query)Mapping.

    5. The following mappings exist:

      Entity Set propertyMappingData Source Parameter
      KeyLAND1
      KeyRESULT_LIST\LAND1
      NameLANDX
      NameRESULT_LIST\LANDX
    6. Choose Generate Runtime Objects.

Task 4: Test the Query and Read Operations of Country

Steps

  1. In the SAP Gateway Client of your S4H, test the paging operation for countries in your service. Query the first two countries.

    1. In the SAP Gateway Service Builder of your S4H, double-click Service Maintenance.

    2. Choose SAP Gateway Client.

    3. In the SAP Gateway Client, select HTTPS as Protocol.

    4. Choose Entity Set.

    5. In the Entity Sets popup, double-click CountrySet.

    6. Choose Add URI Option.

    7. In the Add URI Option popup, double-click $top=2.

      Example

      /sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/CountrySet?$top=2
    8. Choose Execute.

      Result

      The HTTP Response displays the first two countries.
  2. Test the expand operation for business partner and country in your service. Query all business partners including their country name.

    1. Choose Entity Set.

    2. In the Entity Sets popup, double-click BusinessPartnerSet.

    3. In the Request URI field, add ?$expand=CountryName to the URI.

      Example

      /sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/BusinessPartnerSet?$expand=CountryName
    4. Choose Execute.

      Result

      The HTTP Response displays all business partners including their country name.

Task 5: Document the Query Options Generated via Search Help Generator in the Metadata

Steps

  1. Set entity set CountrySet to be Pageable and set the Key and Name properties of entity type Country to be Filterable.

    1. In the SAP Gateway Service Builder of your S4H, expand Data Model.

    2. Double-click Entity Sets.

    3. For of the CountrySet, set the Pageable checkbox.

    4. Expand Entity TypesCountry.

    5. Double-click Properties.

    6. For the properties Key and Name, set the Filterable checkbox.

    7. Choose Generate Runtime Objects.