Skip to Content

Entityset of an OData not appearing in Metadata

Hello Everyone,

While creating a service in SAP OData, I came across an interesting issue which I thought to be worthy of sharing with you all. The issue is after creating a project in the Gateway Service Builder (TCode: SEGW), I tried to  generate the service for the same  in Gateway Client and I got a success message. But the problem was the metadata was incomplete i.e., without the entity sets.

I tried with all the Authorizations, profiles etc. but later I found that there was a minor problem in the Extended Model Provider Class. Please find below the detailed diagnosis of the issue.

Entity set of an OData not appearing in Metadata

After creating a project in the TCode: SEGW, while creating the OData service in the Gateway Client, in some cases it is possible that the entity sets which are created in the Service Builder won’t appear in the Metadata.

/wp-content/uploads/2016/06/img_1_976212.png

Reason:

The method which provides the metadata is not inherited from the parent ZCL_XXXXXXX_MPC to its extension class ZCL_XXXXXXX_MPC_EXT.

Because the method GET_EMPLOYEE (in this example) is created as a Private Method in the parent class, whereas it should be Protected or Public.

In ZCL_XXXXXXX_MPC:

/wp-content/uploads/2016/06/img_2_976213.png

In ZCL_XXXXXXX_MPC_EXT:

As you can see the method GET_EMPLOYEE is not inherited. Hence, in the metadata the entity sets were not shown although the service was executed without any errors. (Status: OK, Status Code: 200)

/wp-content/uploads/2016/06/img_3_976239.png

Solution:

This can be resolved in two possible ways:

  • Change the visibility of the concerned method as Public or Protected in the parent class so that the extended class can inherit. (this is more preferable)

/wp-content/uploads/2016/06/img_4_976240.png

  • Copy and paste the same method in the extended class as well.

NOTE: Generally, the methods will not be in Private visibility, but in some cases due to configuration problems this case may arise.

/wp-content/uploads/2016/06/img_5_976247.png

As you can see, the method is now available in the extended model provider class. Now, Save, Check and Activate the class and create Run time Artifacts for the project and see the result in the Gateway Client.

/wp-content/uploads/2016/06/img_6_976249.png

The issue is resolved now.

Disclaimer: This is not the only solution for the given issue; I followed the above steps to resolve this. But, there might be other reasons like Authorization issues or Insufficient Role Assignment etc. in those cases some other troubleshooting processes needs to be followed.

Post your suggestions if you found this document helpful.

Thank You

Kiran VK

Vinay Varanasi

8 Comments
You must be Logged on to comment or reply to a post.
  • Hi, In my case.

    The user not have a authorization in this code

     

    Documentation:

    Backend

    http://help-legacy.sap.com/fiori_bs2013/helpdata/en/6f/0e415370107d77e10000000a441470/content.htm?frameset=/en/cd/284353d5da6957e10000000a44538d/frameset.htm&current_toc=/en/11/e168533271a548e10000000a423f68/plain.htm&node_id=39

    Procedure

    1. Run transaction Role Maintenance (PFCG) and create a new PFCG role or edit an existing role.

    2. On the Menu tab, open the menu of the pushbutton for adding objects (+ pushbutton) and choose the object type Authorization Default.

    3. From the Authorization Default menu, choose TADIR Service and enter the following data:

      • Program ID: R3TR

      • Object Type: IWSV

    4. In the table, enter the name of the OData service.

      For more information about the OData service for your app, see the app-specific documentation in the section SAP Fiori Apps.

    5. Repeat steps 2 to 4 for all services of the catalogs that you want to authorize with the role.

    6. On the Authorization tab, choose the pushbutton next to Profile Name to generate the authorization profile for the role.

    7. Choose Change Authorization Data.

    8. Choose Save and then Generate.

    9. Run transaction User Maintenance (SU01) and assign the role to the user.

    If the user does not yet have the business authorizations required to use the app, perform the following steps:

    1. Open transaction User Maintenance (SU01).

    2. On the Authorization tab, choose Generate Profile next to the profile name.

    3. Choose Maintain Authorization Data.

    4. On the Authorization Details screen, choose the Generate symbol.

  • I have a similar situation… In the development system everything works OK, but after transport to QA system I have this same issue. I checked ┬ámy┬áZCL_XXXXXXX_MPC and┬áZCL_XXXXXXX_MPC_EXT┬áin both systems and in both cases the methods are also private (in case of MPC class) and not inherit to the MPC_EXT class. So I don’t understand why in DEV works as it is and why in QA won’t. I will try your solution in QA since I need this to work, but either way, is unclear for me how this will make any difference since in DEV worked with private methods and without the inheritance.

    Thank you and regards!

    Cristian R.

     

  • Try this:

    SEGW > Service Maintenance > Maintain >  Load Metadata

    You should not change MPC and DPC class, otherwise next time it will be neu generated.