<!-- https://abap2ui5.github.io/docs/cookbook/model/size_limit -->

# Size Limit

Every UI5 JSON model has a built-in upper limit on the number of items it will expose to a list binding. By default this limit is `100`. If you bind a `ComboBox`, `Table` or any other aggregation to a table that contains more than 100 entries, only the first 100 are rendered — the rest are silently dropped. This is a UI5 design decision, documented under [`sap.ui.model.Model#setSizeLimit`](https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.Model%23methods/setSizeLimit).

abap2UI5 exposes this setting through the built-in client event `SET_SIZE_LIMIT`, so you can raise (or reset) the limit per view directly from ABAP.

## Set the Limit
Trigger the event from your controller with `client->follow_up_action`. The first argument is the new limit, the second is the view key — use the constants `client->cs_view-main`, `-nested`, `-nested2`, `-popup`, or `-popover` to stay type-safe (their underlying values are `MAIN`, `NEST`, `NEST2`, `POPUP`, `POPOVER`):
```abap
client->follow_up_action(
    val   = z2ui5_if_client=>cs_event-set_size_limit
    t_arg = VALUE #(
        ( `1000` )
        ( client->cs_view-main ) ) ).
```
After this call, the model bound to the main view accepts up to 1000 entries per binding. The setting is remembered across roundtrips — once raised, it stays in effect until you reset it or leave the app.

## Reset the Limit
To restore the default of `100`, omit the limit argument and pass only the view key:
```abap
client->follow_up_action(
    val   = z2ui5_if_client=>cs_event-set_size_limit
    t_arg = VALUE #( ( client->cs_view-main ) ) ).
```

## Complete Example
The snippet below shows a `ComboBox` filled with 105 entries. Without raising the size limit, the dropdown would stop at item 100. A small form lets the user adjust the limit and the number of entries at runtime:
```abap
CLASS z2ui5_cl_sample_size_limit DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

    TYPES:
      BEGIN OF ty_s_combo,
        key  TYPE string,
        text TYPE string,
      END OF ty_s_combo.
    DATA t_combo         TYPE STANDARD TABLE OF ty_s_combo WITH EMPTY KEY.
    DATA mv_size_limit   TYPE i VALUE 100.
    DATA mv_combo_number TYPE i VALUE 105.

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS z2ui5_cl_sample_size_limit IMPLEMENTATION.
  METHOD z2ui5_if_app~main.

    CASE client->get( )-event.
      WHEN `UPDATE_LIMIT`.
        client->follow_up_action(
            val   = z2ui5_if_client=>cs_event-set_size_limit
            t_arg = VALUE #( ( CONV #( mv_size_limit ) ) ( client->cs_view-main ) ) ).
        client->message_toast_display( `Size limit updated` ).
        RETURN.

      WHEN `UPDATE_MODEL`.
        t_combo = VALUE #( ).
        DO mv_combo_number TIMES.
          INSERT VALUE #( key = sy-index text = sy-index ) INTO TABLE t_combo.
        ENDDO.
        RETURN.
    ENDCASE.

    DO mv_combo_number TIMES.
      INSERT VALUE #( key = sy-index text = sy-index ) INTO TABLE t_combo.
    ENDDO.

    DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
        )->ele( n = `View` ns = `mvc`
            )->a( n = `xmlns`      v = `sap.m`
            )->a( n = `xmlns:mvc`  v = `sap.ui.core.mvc`
            )->a( n = `xmlns:core` v = `sap.ui.core`
            )->a( n = `xmlns:form` v = `sap.ui.layout.form`

            )->ele( `Page`
                )->a( n = `title` v = `Size Limit Demo`

                )->ele( n = `SimpleForm` ns = `form`
                    )->a( n = `title`    v = `Settings`
                    )->a( n = `editable` b = abap_true

                    )->ele( n = `content` ns = `form`
                        )->tag( `Label`
                            )->a( n = `text` v = `setSizeLimit`
                        )->tag( `Input`
                            )->a( n = `value` v = client->_bind( mv_size_limit )
                        )->tag( `Button`
                            )->a( n = `text`  v = `update size limit`
                            )->a( n = `press` v = client->_event( `UPDATE_LIMIT` )
                        )->tag( `Label`
                            )->a( n = `text` v = `Number of Entries`
                        )->tag( `Input`
                            )->a( n = `value` v = client->_bind( mv_combo_number )
                        )->tag( `Button`
                            )->a( n = `text`  v = `update number of entries`
                            )->a( n = `press` v = client->_event( `UPDATE_MODEL` )
                        )->tag( `Label`
                            )->a( n = `text` v = `ComboBox`
                        )->ele( `ComboBox`
                            )->a( n = `items` v = client->_bind( t_combo )

                            )->tag( n = `Item` ns = `core`
                                )->a( n = `key`  v = `{KEY}`
                                )->a( n = `text` v = `{TEXT}` ).

    client->view_display( view->stringify( ) ).

  ENDMETHOD.
ENDCLASS.
```

## Other Views
The same call applies to nested views, popups and popovers — just swap the view key:
```abap
" Popup
client->follow_up_action(
    val   = z2ui5_if_client=>cs_event-set_size_limit
    t_arg = VALUE #( ( `500` ) ( client->cs_view-popup ) ) ).

" Popover
client->follow_up_action(
    val   = z2ui5_if_client=>cs_event-set_size_limit
    t_arg = VALUE #( ( `500` ) ( client->cs_view-popover ) ) ).

" Nested view
client->follow_up_action(
    val   = z2ui5_if_client=>cs_event-set_size_limit
    t_arg = VALUE #( ( `500` ) ( client->cs_view-nested ) ) ).
```

::: warning The main view and the two nested views share one limit
Only the popup and the popover own a model of their own. `MAIN`, `NEST` and
`NEST2` are one control tree and inherit **one** JSON model through UI5 model
propagation, so a limit set on any of them lands on that shared model and the
**largest** of the three wins. Raising it for the nested view raises it for the
main view too, and resetting the main view changes nothing while the nested one
still asks for more. Reset all three to get back to `100`.
:::

::: tip **When to raise it**
Raise the limit only as high as you actually need. Large bindings increase memory consumption on the frontend and slow down rendering. For very large datasets, prefer a server-side pattern (OData with `growing`, paging, filtering) instead of pushing everything into the model.
:::

For a runnable sample, see `Z2UI5_CL_SMP_APP_071` in the [samples repository](https://github.com/abap2UI5/samples).

<!-- samples:start (generated by scripts/link-samples.mjs — do not edit) -->

## Working Samples

Complete apps from the [sample catalog](https://github.com/abap2UI5/samples/blob/main/SAMPLES.md)
that use what this page describes. Each is a single class — pull the repository with
[abapGit](https://abapgit.org) and start it with `?app_start=<class>`.

| Sample | Class |
|---|---|
| Model setSizeLimit for Large Tables (A) | [`Z2UI5_CL_SMP_APP_071`](https://github.com/abap2UI5/samples/blob/main/src/01/z2ui5_cl_smp_app_071.clas.abap) |

<!-- samples:end -->
