Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member9607
Active Participant
0 Kudos
15,843

Introduction

This document is written to understand the cause of "Property of Data Object has no type assigned" error in ODATA service.

Scenario

While writing the ODATA service, normally we follow the below steps in Model class.

1. Create Entity Type

2. Bind structure to Entity Type

3. Create Entity Sets


Now, For example,  If You have defined 3 Properties in your entity type.

*&----------------------------------------------------------------------------------------------------------------------------------*

* DATA

*&----------------------------------------------------------------------------------------------------------------------------------*

   DATA : lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ,

                lo_property   type ref to /iwbep/if_mgw_odata_property.

*&----------------------------------------------------------------------------------------------------------------------------------*

* Entity

*&----------------------------------------------------------------------------------------------------------------------------------*

*Define Entity Booking

  lo_entity_type model->create_entity_type( 'Name' ).

*Define Property FirstName

  lo_property = lo_entity_type->create_property( iv_property_name = 'FirstName'

                                                                      iv_abap_fieldname = 'FIRSTNAME' ).

*Define Property MiddleName

   lo_property = lo_entity_type->create_property( iv_property_name = 'MiddleName'

                                                                       iv_abap_fieldname = 'MIDDLENAME' ).

*Define Property LastName

  lo_property = lo_entity_type->create_property( iv_property_name = 'LastName'

                                                                      iv_abap_fieldname = 'LASTNAME' ).

*&-----------------------------------------------------------------------------------------------------------------------------------*

* Bind EntityType to an ABAP dictionary structure ZNAME which has two columns

* FIRSTNAME and LASTNAME

*&----------------------------------------------------------------------------------------------------------------------------------*

*Bind Entity Type to structure

  lo_entity_type->bind_structure( 'ZNAME' ).

*&----------------------------------------------------------------------------------------------------------------------------------*

* Create Entity Set

*&----------------------------------------------------------------------------------------------------------------------------------*

lo_entity_type->create_entity_set( 'Names' ).

Problem

On above scenario if you activating your model class will not result any kind of error or warning. After that you will create a Runtime Data Provider Class and at the end you will register your service.

When you call this service in your browser, it will give you an error "Property 'MiddleName' of Data Object 'Name' has no type assigned"


This error occurs when execution goes to create the Entity Set. There is a internal check which maps properties of entity type to the structure which is bound to it.

Solution

If you come across errors like this, just go to your Model Class and cross check the entity properties with your structure. Update your structure with missing properties. If you are playing with standard SAP provided service then make sure that you apply all the respective notes.

Happy Learning


5 Comments
Labels in this area