The different count modes in SAPUI5

In the UI5 framework, we do differ how we want to setup the count requests, when an OData service gets called. The mode how this count should be sent and retrieven, can be set in the manifest.json file.

  "models": {
      // ...
			"": {
				"type": "sap.ui.model.odata.v2.ODataModel",
				"settings": {
					"defaultOperationMode": "Server",
					"defaultBindingMode": "OneWay",
					"defaultCountMode": "InlineRepeat", // <-- Can be set here
					"useBatch": true
				},
				"dataSource": "...",
				"preload": true
			},
			// ...
  }

Therefore we can set the following options:

Count modeDescription
InlineCount is retrieved by adding $inlinecount=allpages to data requests as long as no count has been determined yet.
InlineRepeatCount is retrieved by adding $inlinecount=allpages to every data request.
RequestA separate $count request will be sent to the OData service.
NoneNo info about the count should be sent by the backend.
Source: https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.odata.CountMode%23properties

The differences are now be shown below within a batch request:

Inline & InlineRepeat

Request

--batch_c433-cbe5-be7d
Content-Type: application/http
Content-Transfer-Encoding: binary

GET AnySet?$skip=0&$top=100&$inlinecount=allpages HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: application/json
Accept-Language: de-CH
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0


--batch_c433-cbe5-be7d--

Response

--767F4D3B41568C8580C8851C34925D590
Content-Type: application/http
Content-Length: 4180
content-transfer-encoding: binary

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 3988
dataserviceversion: 2.0
sap-metadata-last-modified: Thu, 07 Dec 2023 13:09:46 GMT
cache-control: no-store, no-cache

{"d":{"__count":"10","results":[ /* ..... */ ]}}
--767F4D3B41568C8580C8851C34925D590--

Request

In this request, you can see that we have to requests. The first one is the $count request, the second the real data request, with the data that can be viewed.

Request

--batch_be18-a9fe-712c
Content-Type: application/http
Content-Transfer-Encoding: binary

GET AnySet/$count HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: text/plain, */*;q=0.5
Accept-Language: de-CH
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0


--batch_be18-a9fe-712c
Content-Type: application/http
Content-Transfer-Encoding: binary

GET AnySet?$skip=0&$top=100 HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: application/json
Accept-Language: de-CH
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0


--batch_be18-a9fe-712c--

Response

--3849B0FB00EBDAAD2D42EA014B3CD2140
Content-Type: application/http
Content-Length: 91
content-transfer-encoding: binary

HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 2
dataserviceversion: 2.0

10
--3849B0FB00EBDAAD2D42EA014B3CD2140
Content-Type: application/http
Content-Length: 4180
content-transfer-encoding: binary

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 3988
dataserviceversion: 2.0
sap-metadata-last-modified: Thu, 07 Dec 2023 13:09:46 GMT
cache-control: no-store, no-cache

{"d":{"__count":"10","results":[ /* ..... */ ]}}
--3849B0FB00EBDAAD2D42EA014B3CD2140--

None

With none, the same happens as the Inline mode in my case. Therefore the count is always calculated, just the delivery format changes depending on the setting.

Relative links


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ad blocker detected

We have detected that you are using extensions to block ads. Please support us by disabling your ad blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO