Redefining a Data Service

Objective

After completing this lesson, you will be able to redefine a data service

Redefinition Scenarios

Development flow: Data source redefinition

You can redefine existing data services by using the Redefine Service Wizard. The SAP Gateway Service Builder enables you to make certain restricted changes in the generated services. For example, these services might not have proper labels or might not need all the artifacts. In these cases, the SAP Gateway Service Builder allows you to make cosmetic changes without influencing the underlying implementation of the service.

Note

Redefinition should not be confused with including an existing SAP Gateway service into a new SAP Gateway service. The later can be compared to a mashup and is no longer recommended.

When generating a service by using redefinition, the data model definition and service implementation are performed in a single step. This is possible because the data sources offer methods that are already very similar to the methods of an OData service.

Two use case can be distinguished:

  1. Redefine a data source service.
  2. Redefine (or extend) an SAP Gateway service

When redefining a data source, an SAP Gateway service is completely generated based on existing data objects.

Redefinition Support

Screenshot of SEGW and table of redefinition scenarios

For the following frameworks, redefinition scenarios are supported:

Easy Query
Easy Query allows external access to queries created in SAP Business Warehouse (BW).
Multidimensional Expression (MDX)
MDX is a language used in SAP BW and developed by Microsoft for queries using multi-dimensional data. An MDX expression returns a multi-dimensional result set (dataset) that consists of axis data and cell data.
Operational Data Provisioning (ODP)

ODP is an infrastructure for data extraction and replication from SAP (ABAP) applications to a SAP BW/4HANA Data Warehouse.

Business Objects Processing Framework (BOPF)

BOPF is an ABAP object-oriented framework that provides a set of generic services and functionality to speed up, standardize, and modularize development.

Caution

BOPF is also used as business layer in the ABAP Programming Model for SAP Fiori, also known as CDS-based BOPF. In this variant, it cannot be used as data source in a redefinition.
Open Data (OData)
OData services from external systems can be redefined as and thereby transformed in SAP Gateway services.
SAP Gateway (GW)
Redefining an SAP Gateway service allows to extend an (SAP-)delivered one in customer namespace.
Generic Interaction Layer (GenIL)

GenIL is based on the SAP Customer Relationship Management (CRM) Business Object Layer (BOL) and can be used for data access through the GenIL connectivity framework.

Note

The data model is deprecated since ABAP Platform 7.54. The mandatory add-on IW_GIL can no longer be used since SAP S/4HANA 1909.
Service Provider Infrastructure (SPI)

SPI is an application and User Interface (UI) technology independent layer for business data exposure. As application data model, it is used in the SAP Business Suite mainly in the areas Product Lifecycle Management (PLM) and Enterprise Application Management (EAM). As a UI data model, it is used as internal framework for Web Dynpro as part of the Floorplan Manager (FPM).

Note

The usage as application data model is deprecated since AS ABAP 7.51. The mandatory add-on IW_SPI can no longer be used since SAP S/4HANA 1610.
Screenshots of redefine service wizards in SEGW

The Redefine Service Wizard looks and works differently for each data model because every data model defines other (runtime) artifacts. Here are some examples:

  • BW easy query and MDX are combined in the wizard for BW Query Service and distinguished using the Access Type.
  • The OData access for ODP can combine multiple ODPs in one SAP Gateway service.
  • A BOPF configuration may include an FPM BOPF Integration (FBI) view.
  • The redefinition of an SAP Gateway service asks for a certain version of the original service.

In general, you should be familiar with the data service you want to redefine. Working with the wizard is quite simple as long as the terms and behavior of the origin are understood.

Redefinition Process

Development steps: Data service redefinition

The implementation process starts with redefining a data service. The model and data provider classes are generated depending on the kind of data service chosen. In particular, the generated operations heavily depend on what the data service is providing. After generating the runtime artifacts, the implementation can be tested.

For some data sources, the next step is called beautification. The reason is that OData service are meant to be human readable. But this may not apply to the redefined data source. In fact, the names of fields in the data source may be generated in a very technical manor using character and number chains. Therefore, you literally beautify the data model to make it readable.

Screenshots of starting Redefine Service wizard in SEGW

As an example, we redefine an SAP Gateway service. You should be familiar with this data source by now. Right-click Data Model and choose RedefineOData Service (SAP GW). Enter the name and the version of the technical service you want to redefine. If the SAP Gateway service resides in another system, you can fetch the metadata via an RFC destination.

Note

The version of a service is set when generating the runtime artifacts of an SAP Gateway project for the first time. This may come in handy, if you want to implement new features in your service but also keep the old implementation for compatibility reasons. You create a new project, redefine the original version, and reuse the same name for the technical service but in another version.
Screenshots of Redefine Service wizard result in SEGW

In the second step of the wizard, you select the entity types, properties, and associations you want to be part of your new data model. It is totally fine to only choose parts of the original service if it meets your requirements. Beside the selected elements, a model reference referencing the original model is generated in the new data model.

Screenhots about beautifying a data model in SEGW

Depending on the kind of redefined data model, several adaptions are possible. For all data models, it is possible to change the name of entity types, properties, labels, and entity sets. Double-click the element in the data model tree, select the line you want to change, and choose Redefine. Choose Undone to reverse the changes at any time.

Enhance an SAP Gateway Service by Using Redefinition

Business Example

You are a developer or solution architect in your company. You need to create a new SAP Gateway service project, redefine an existing SAP Gateway service, add a new property to an entity, and beautify the element names.

Template
GW100_S_SEARCHHELP
Solution
GW100_S_REDEFINE

Note

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

Note

You may redefine your solution of the exercise about search help or use the template. Whenever the values or object names in this exercise include ##, replace ## with the number of your user.

Task 1: Redefine an SAP Gateway Service Selecting one Entity

Steps

  1. In the SAP Gateway Service Builder of your SAP S/4HANA (S4H) system, create a new project named ZGW100_##_REDEFINE in your ZGW100_##_BES package.

    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, choose Create Project.

    3. In the Create Project popup, enter the following values:

      FieldValue
      ProjectZGW100_##_REDEFINE
      Descriptionyour choice
      PackageZGW100_##_BES
    4. Choose Continue.

    5. Choose Save.

    6. In the Prompt for transportable workbench request popup, in the Request field, select the transport request provided to you.

    7. Choose Continue.

  2. Redefine the service GW100_S_SEARCHHELP_SRV selecting only the entity Product.

    Note

    You may also redefine your solution of the exercise about search help.
    1. In the context menu of Data Model, choose RedefineOData Service (SAP GW).

    2. In the Redefine Service popup, in the Technical Service Name field, enter GW100_S_SEARCHHELP_SRV by using the value help.

    3. Choose Next.

    4. Select the Product checkbox.

    5. Choose Finish.

    6. Choose Save.

Task 2: Change the Data Model of a Redefined Service

Steps

  1. In the SAP Gateway Service Builder of your S4H, add the TaxTarifCode property to the Product entity.

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

    2. Right-click Product and choose ImportProperties.

    3. In the Import Properties popup, select the checkbox for TaxTarifCode and choose Next.

    4. Choose Finish.

    5. Choose Save.

  2. Rename entity set ProductSet to ArticleSet and entity type Product to Article. Rename its ProductId field to ArticleId and label Product ID to Article ID.

    1. Double-click Entity Types.

    2. Select the name Product.

    3. Choose Redefine Attributes.

    4. In the Name field, enter Article and choose Enter.

    5. Double-click the Properties node of entity type Article.

    6. Select the name ProductId.

    7. Choose Redefine Attributes.

    8. In the Name field, enter ArticleId and choose Enter.

    9. Select the label Product ID.

    10. Choose Redefine Attributes.

    11. In the Label field, enter Article ID and choose Enter.

    12. Double-click the Entity Sets node.

    13. Select the name ProductSet.

    14. Choose Redefine Attributes.

    15. In the Name field, enter ArticleSet and choose Enter.

    16. Choose Save.

Task 3: Register and Test a new Redefined Service

Steps

  1. In the SAP Gateway Service Builder of your S4H, generate the runtime objects in your ZGW100_##_BES package creating the new service ZGW100_##_REDEFINE_SRV.

    Caution

    Do NOT overwrite the base service.
    1. In the SAP Gateway Service Builder of your S4H, choose Generate Runtime Objects.

    2. In the Model and Service Definition popup, to accept the proposed names, choose Continue.

      Caution

      Do NOT select the Overwrite Base/Extended Service checkbox.
    3. In the Create Object Directory popup, in the Package field, enter ZGW100_##_BES.

    4. Choose Save.

    5. In the Prompt for transportable workbench request popup, in the Request field, select the transport request provided to you.

    6. Choose Continue.

  2. Register and activate the service in your S4H using your ZGW100_##_FES package.

    1. Double-click the Service Maintenance node.

    2. Right-click the LOCAL_GW system.

    3. Choose Register.

    4. In the Select System Alias (Hub to Backend) popup, in the System Alias field, enter LOCAL.

    5. Choose Continue.

    6. In the Add Service popup, in the Package Assignment field, enter ZGW100_##_FES.

    7. Choose Continue.

    8. For every popup, choose the transport request provided to you.

    9. Choose Save.

  3. In the SAP Gateway Client of your S4H, test if the query operation for articles contains the TaxTarifCode. Query all articles.

    1. Choose SAP Gateway Client.

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

    3. Choose Entity Set.

    4. In the Entity Sets popup, double-click ArticleSet.

      Example

      /sap/opu/odata/SAP/ZGW100_##_REDEFINE_SRV/ArticleSet
    5. Choose Execute.

      Result

      The HTTP Response displays the TaxTarifCode for each article.

Log in to track your progress & complete quizzes