Entityset of an OData not appearing in Metadata
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.
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.
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)
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)
- 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.
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.
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.