cancel
Showing results for 
Search instead for 
Did you mean: 

Count Field in Odata service

former_member190313
Active Participant
0 Kudos

Hello All,

I have one entityset -  ResourceSet. I am sending Resources List in this set. Along with this I need to send the total count of resources in the list , in a separate field. I need to pas this number to UI5 App.

I have created a BAPI , which gives the output as Resources Table and one export parameter RCOUNT ( which has the resources Count)

When I map this to query operation how ever how to map this global field ?

Regards,

Sheetal

Accepted Solutions (1)

Accepted Solutions (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

you just need to add /$count to your entityset which will give count of entries. no need of additional coding.

Regards,

Chandra

former_member190313
Active Participant
0 Kudos

Hi Chandra,

I tried doing that.

Firstly the same field gets repeated for every table entry . i.e. For every Resource I will get this field. Secondly though my BAPI output is correct , The field in odata service is blank when I run this odata service.

Please suggest.

Regads,

Sheetal

ChandraMahajan
Active Contributor
0 Kudos

Sorry I did not understood.

if you are querying like /sap/opu/odata/sap/ZGW_SRV/ResourceSet then it will give you output of resource table. now if you try with  /sap/opu/odata/sap/ZGW_SRV/ResourceSet/$count  then it will provide you number of resources.

You need not to do separate coding for returning counts.

additionally, if you want count to be displayed in output, you can have that field defined in entity and set the value. I will refer my blog and accordingly you can go for code based implementation of entityset ie. query operation.

Regards,

Chandra

former_member190313
Active Participant
0 Kudos

Thanks Chandra !

Answers (1)

Answers (1)

former_member195242
Active Participant
0 Kudos

Hi Sheetal,

In your .....DPC_EXT class GET_ENTITYSET method for the specified entity, please fill the ES_RESPONSE_CONTEXT-inlinecount to get this global value in your entitylist and this will only come once not with every entity.  Then try adding $inlinecount to your entityset GET request as follows:

http://services.odata.org/OData/OData.svc/Products?$inlinecount=allpages

Best regards,

Aakash