Developing Advanced Entity in SAP OData

Create Deep Entity In Sap Odata

In this post, you will learn about handling Deep Structures in OData. We need to handle data with a hierarchy with deep structures while reading the data for the front-end applications and also while creating the data in SAP. This post deals with reading the data.

Creating Deep Entity in SAP OData

To create the SEGW project ZG00_JP_SO, follow the steps mentioned in previous posts of this series. The details of these steps will not be reiterated in this particular post.

To discover a range of articles about OData, you can visit the SAP section dedicated to OData development.

Entity Types (SOStatus can be disregarded for this article). Restate this information in your own words without elaborating on the subject, only providing original text. Write in Indian English.

The reference structures for all entities are listed below. At the same time, create entity sets that have the same properties.

Next, establish connections between the different entities to represent the structure of the data model. Additionally, create sets of associations simultaneously.

Navigation Properties and Associations are established with the creation of the following properties. The names of these properties hold significant importance in this particular scenario.

Next, create the project and complete the registration of the service. Two significant classes that are automatically generated include:

1. Data Provider Class: ZCL_G00_JP_SO_DPC_EXT

2. Model Provider Class: ZCL_G00_JP_SO_MPC_EXT

Creating Deep Structure in SAP OData

An alternative approach to constructing the framework is by generating it within the MPC_EXT class, specifically in ZCL_G00_JP_SO_MPC_EXT.

You might be interested:  Create S User Id Sap Marketplace

Navigate to the tab and enter the class details, including type TY_SO_ALL with Public visibility. Next, click on the highlighted green arrow below to access the editor.

tt_items_products is a standard table type that contains entries of the ty_item_product structure. This table has an empty key, meaning it does not have any specific fields designated as keys for identifying its entries.

You can declare a type called “ty_so_all” based on the DDIC (Data Dictionary) in SAP.

Understanding association and navigation in SAP OData

In SAP OData, association and navigation are important concepts that help establish connections between different entities or pieces of information. These concepts allow us to easily move from one entity to another within the system.

Navigation, on the other hand, allows us to navigate or move from one entity to another based on their associations. Using our previous example, if we want to see all the orders placed by a specific customer, we can use navigation to go from the “Customer” entity to the associated “Order” entities.

Create Deep Entity in SAP OData – $expand

The expansion feature allows for the use of multiple and multi-level concepts within a single request.


METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entity can be rewritten as the procedure to obtain an expanded entity in SAP OData.

Declare a variable named “ls_so_all” of type “zcl_g00_jp_so_mpc_ext=>ty_so_all”.

toitem = VALUE #( FOR ls_item IN lt_item WHERE ( vbeln = ls_header-vbeln ).

Rewritten: Assign the value of “toitem” as a result of iterating through each entry in “lt_item”, checking if the “vbeln” field matches the one from “ls_header”.

mtart = VALUE #( lt_material-mtart OPTIONAL ) ) ) ) )..

ENDMETHOD. METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.. can be rewritten as ENDMETHOD. METHOD to get the expanded entity set in the runtime of the SAP OData application service.

Declare a variable named “lt_so_all” of type standard table, which is based on the structure “ty_so_all” from the class “zcl_g00_jp_so_mpc_ext”.

toitem is assigned a value using the VALUE operator, with a loop over each ls_item in lt_item where vbeln matches ls_header-vbeln.

You might be interested:  Inventory Management Procedure in SAP MM

mtart = VALUE #( lt_material-mtart OPTIONAL ) ) ) ) ) ).

What is the purpose of deep entity read in OData?


1. The navigation property name is crucial for handling deep entities.

3. Neglecting to use the navigation property name will lead to obtaining empty records.

Test using Gateway Client

The reply displays various entries, where the Association ToCustomer is shown with information while the Association ToItem is postponed.

In this scenario, when the navigation property is NPL1 for the first level and NPL2 for the second level, it should be indicated as NPL1/NPL2.

Please be aware that the URI contains names of Navigation Properties and we have made sure that these property names align with the component names in the Deep Structure.

The output of the previous operation displays all the expanded data. Please focus on the actual information, as some additional details have been shortened.

“id” : “/sap/opu/odata/SAP/ZG00_JP_SO_SRV/CustomerSet(‘2000’)”,

“uri” : “/sap/opu/odata/SAP/ZG00_JP_SO_SRV/CustomerSet(‘2000’)”,

In the following post, we will further explore the concept of deep structures in SAP OData by focusing on how to create data using a deep entity.

To discover a wide range of articles on OData, make sure to check out the OData Development section in SAP.

Creating an OData service for BAPI in SAP

– Select PO Items and click Next. Then select keys and click Finish.

– Map Query Operation to BAPI.

– Choose Target System as Local, which is the same as before when creating the Entity Type.

Creating a deep insert in OData: How is it done?

To begin, open Solution Explorer and locate the ODataClientDeepInsert project. Right-click on it and select “OData Connected Service” from the “Other Services” menu. This will launch the OData Connected Service wizard. Proceed by clicking “Next” to advance to the Schema Types Selection wizard page. Once there, click “Next” again to proceed to the Function/Action Imports Selection wizard page.

Creating a deep structure in SE11: How is it done?

To create a deep entity in SAP OData, follow these steps:

You might be interested:  Understanding the Distinction: ERP vs. SAP

1. Open SE11 and navigate to Data Type.

2. Enter the desired name for the structure you want to create and click on Create.

3. Select Structure and press Enter.

4. Provide a short description for the structure.

Creating OData Associations: A Step-by-Step Guide

To create a deep entity in SAP OData, follow these steps:

1. Open the OData service and choose the specific entity type, external entity type, or complex type that you want to associate with.

2. In the Palette view of the OData editor, navigate to Associations.

3. Select either Single or Bidirectional association based on your requirements.

4. Drag and drop the selected association onto the Tree tab.

By following these steps, you can successfully create a deep entity in SAP OData.

In simple terms, creating a deep entity in SAP OData involves associating one data structure with another within an OData service. This allows for more complex relationships between different types of data objects.

Creating such associations enables efficient navigation and retrieval of related information when working with large datasets or interconnected entities within an application built using SAP technologies.

– Open desired OData service

– Choose relevant data structures/entities

– Establish associations using drag-and-drop

– Enable efficient navigation and retrieval of related information

Distinguishing association and navigation in SAP OData

In SAP OData, the following concepts are important to understand:

1. Association Sets: Instances of associations are organized in association sets. These sets group together related associations.

2. Navigation Properties: Entity Types have special properties called navigation properties. These properties are bound to a specific association and allow entities to refer to other associated entities.

3. Entity Container: All instance containers, including entity sets and association sets, are grouped within an entity container. This container serves as a collection for these instances.

Understanding these concepts is crucial when working with SAP OData as they help establish relationships between entities and enable efficient data retrieval and manipulation.