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.
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:
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)
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)
- 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.
Thank You
Thank you Sreehari.
Good Work....Keep It Up . 🙂
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¤t_toc=/en/11/e168533271a548e10000000a423f68/plain.htm&node_id=39
Procedure
Run transaction
( ) and create a new PFCG role or edit an existing role.On the
tab, open the menu of the pushbutton for adding objects (+ pushbutton) and choose the object type .From the
menu, choose and enter the following data:: R3TR
: IWSV
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
.Repeat steps 2 to 4 for all services of the catalogs that you want to authorize with the role.
On the
tab, choose the pushbutton next to to generate the authorization profile for the role.Choose
.Choose
and then .Run transaction
( ) 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:
Open transaction
( ).On the
tab, choose next to the profile name.Choose
.On the
screen, choose the 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.
I found the cause of my issue, it was an incorrect system alias assignment, it wasn't neccesary to change anything in the model classes.
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.
It worked for me.
Thanks Steve.
THIS IS COMPLETELY WRONG.
those methods are called internally by define, so no need to be public.
Yes I do agree with Jun.
You should create methods in MPC_EXT.
You should never change or code in MPC classes.