cancel
Showing results for 
Search instead for 
Did you mean: 

$count error

Pavan_Golesar
Active Participant

Hello gurus,

I am facing a issue with the use of $count operation.

I also had a peak at the syntax in this.

URI:

/sap/opu/odata/SAP/ZPRO_ODA_SRV/SOListSet?$filter=SalesOrg eq '2000' and DistChan eq '03' and Division eq '00' and SalesOff eq '2001'/$count

Error snapshot:

Thanks,

Pavan G

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Pavan,

Check URL as below :

OData Query Options - SAP NetWeaver Gateway - SAP Library

$count ->

This will return only the count and data fetched is not displayed as part of GW response.

This dos not require any additional implementation in DPC level. GW frame work will it self will return the count.

$inlinecount ->

To get the Data and also the Count of the data fetched as part of GW Response you need to add some code in DPC level and sent that as count value.

add count to response -> example

DESCRIBE TABLE et_entityset LINES es_response_context-inlinecount.

This way response will have data and also the number of items fetched.

......?$filter=Delimiter eq '' and QueryTable eq '' and Text eq ''&$inlinecount=allpages


Pavan_Golesar
Active Participant
0 Kudos

Hello Ashwin,

This is nice document.

I also read the with $filter, the $count considers the relevant result sets returned but  I don't have any idea how does $count works with $filter.. Whch is my case.

Thanks,

Pavan G

AshwinDutt
Active Contributor
0 Kudos

As far as i know with filters you need to use $inlinecount

Pavan_Golesar
Active Participant
0 Kudos

yes Ashwin, after that I tried below URI's still could not identify the count of records which satisfy the $filter conditions

/sap/opu/odata/SAP/ZPRO_ODA_SRV/SOListSet?$filter=SalesOrg eq '2000' and DistChan eq '03' and Division eq '00' and SalesOff eq '2001'&?$inlinecount=allpages


/sap/opu/odata/SAP/ZPRO_ODA_SRV/SOListSet?$filter=SalesOrg eq '2000' and DistChan eq '03' and Division eq '00' and SalesOff eq '2001'&?$inlinecount


/sap/opu/odata/SAP/ZPRO_ODA_SRV/SOListSet?$inlinecount=allpages&?$filter=SalesOrg eq '2000' and DistChan eq '03' and Division eq '00' and SalesOff eq '2001'


Still not got count,

but Http response is 'accepted' but their is no sign of count shown anywhere.


Regards,

Pavan G

AshwinDutt
Active Contributor
0 Kudos

Hello Pavan,

It will work.

Check again

URL -> Sample for understanding and which is working for me as well.

/sap/opu/odata/sap/ZGW_TEST_SERVICE_SRV/GetDataSet?$filter=ImAging eq 180 and ImLcAmnt eq 20&$expand=GenItems&$inlinecount=allpages

Add code in DPC ->

DESCRIBE TABLE lt_gen_items LINES es_response_context-inlinecount.

Where lt_gen_items is your final internal table which is holding all the data to be shown as part of GW response.

OutPut ->

Count of 1257 records are fetched and data is displayed as well.

Regards,

Ashwin

Answers (2)

Answers (2)

former_member206574
Active Participant
0 Kudos

Hi Pavan,

Use the below URL for count.

/sap/opu/odata/SAP/ZPRO_ODA_SRV/SOListSet/$count?$filter=SalesOrg eq '2000' and DistChan eq '03' and Division eq '00' and SalesOff eq '2001'


Regards,

Venu

sreehari_vpillai
Active Contributor
0 Kudos

1. Whats there in /IWFND/ERROR_LOG ?

2. Without $count , are you getting result sets returned ?

3. Any dump in Business suite or Gateway ?

Sree

Pavan_Golesar
Active Participant
0 Kudos

Hello Sreehari,

Service runs fine, and relevant data result set are returned.