ERPClimb logoERPClimb
OData Gateway
Architect / Cross-trackadvanced 10 min read

OData Gateway Part 7: GET_ENTITYSET with Filters, Paging and Sorting

Preview · a free account unlocks the full lesson

Key takeaway

Implement production-grade list reads: translate $filter into SELECT-OPTIONS-like ranges, apply $top/$skip paging in the database, map $orderby to a dynamic ORDER BY, return $inlinecount/$count, handle $search, and avoid reading everything and filtering in ABAP.

In this lessonShow sections

Visual overview

OData Gateway Part 7: GET_ENTITYSET with Filters, Paging and Sorting — learning sheetFlow: Map Customer and CreatedOn filters to ranges → Build ORDER BY from it_order with key as default → Apply top+skip in SELECT, then remove skipped rows → Return inlinecount with a COUNT(*) using the same WHERE. Key ideas: $FILTER; RANGES IN WHERE; $ORDERBY; PAGING. Watch out: A Fiori list with growing/paging calls GET_ENTITYSET repeatedly with $skip. Without a stable ORDER BY, rows appear twice or go missing between pages.ERPClimb.com / ARCH / LESSON 7/10 / LEARNING SHEETOData Gateway Part 7: GET_ENTITYSET with Filters, Pagingand Sorting1 · HOW IT FLOWS1Map Customer andCreatedOnfilters to…2Build ORDER BYfrom it_orderwith key as…3Apply top+skipin SELECT, thenremove skipped…4Returninlinecount witha COUNT(*) using…2 · KEY IDEAS EXPLAINED$FilterSimple filters (eq, ne, gt, ge, lt, le, between,startswith for strings) arrive init_filter_select_options: property +…Property names here are external names (Customer);io_tech_request_context->get_filter()->get_filter_select_options( ) gives ABAP…Ranges In WhereBuild DATA lt_r_kunnr TYPE RANGE OF kunnr; fillfrom select_options; ALPHA-convert low/high.SELECT … WHERE kunnr IN lt_r_kunnr AND erdat INlt_r_erdat.$Orderbyit_order: property + order ('asc'/'desc').Map properties to DB fields (CreatedOn → ERDAT)and build a dynamic ORDER BY string; default tothe key for stable paging.Pagingis_paging-top and is_paging-skip.Classic: SELECT … ORDER BY … UP TO (top + skip)ROWS, then DELETE the first skip rows.3 · REMEMBER · WATCH OUTRememberQuery options arrive as method parameters: it_filter_select_options($filter), is_paging ($top/$skip), it_order ($orderby)…Filters must reach the database: convert them into ranges and use themin WHERE. Reading all rows and filtering in ABAP kills performance.Paging must be applied after sorting and in the database: ORDER BY +UP TO (top+skip) ROWS, then drop the first skip rows — or a dedicated…!Watch outA Fiori list with growing/pagingcalls GET_ENTITYSET repeatedly with$skip. Without a stable ORDER BY,rows appear twice or go missingbetween pages.4 · IN A REAL PROJECTA Fiori "My Customers' Orders" list took 40 seconds to show 20 rows. GET_ENTITYSET read all 3million VBAK rows, then applied the Customer filter and paging with /iwbep/cl_mgw_data_util in memory. Thedeveloper moved the filter into WHERE via ranges, applied ORDER BY plus UP TO top+skip ROWS in the database…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 6 covered reading a single record; now comes the list read that every Fiori list report depends on. Query options arrive as method parameters: it_filter_select_options carries $filter, is_paging carries $top/$skip, it_order carries $orderby, iv_search_string carries $search, and io_tech_request_context carries things like inlinecount and $select.

For $filter, simple conditions (eq, ne, gt, ge, lt, le, between, startswith for strings) arrive in it_filter_select_options as a property plus select_options (sign, option, low, high) — note the property names here are the external OData names, so io_tech_request_context->get_filter( )->get_filter_select_options( ) is what gives you the ABAP field names instead.

More complex filters, such as those spanning several properties or using functions, may only arrive as iv_filter_string, which needs to be parsed carefully or rejected if it's too complex to handle safely.

These filters have to actually reach the database — build a range such as DATA lt_r_kunnr TYPE RANGE OF kunnr, fill it from the select_options with an ALPHA conversion on low/high, and use it directly in a SELECT ... WHERE kunnr IN lt_r_kunnr AND erdat IN lt_r_erdat; an empty range simply means no restriction, just as with classic SELECT-OPTIONS.

Reading all rows and filtering in ABAP instead of in the database kills performance and should be avoided.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.