SAP Gateway Part 4: Paging, Filtering, CSRF and Authorization
Preview · a free account unlocks the full lesson
Implement Gateway services that behave well in production: server-side paging ($top/$skip), filtering and sorting via the request context, $inlinecount, CSRF handling, and authorization checks per operation.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 1 through 3 built and registered a Gateway service. The most common production problem with SEGW services is that GET_ENTITYSET selects everything and ignores the query options the client sent, and this part fixes that.
The anti-pattern looks like SELECT * FROM zpr_head INTO TABLE et_entityset, after which the framework applies $top and $skip in memory — so-called generic paging. With two million rows in the table, every single list request ends up reading all two million rows before the framework throws most of them away.
The fix is to read the query options from the request context instead of letting the framework guess. io_tech_request_context->get_osql_where_clause_convert( ) returns an ABAP SQL WHERE clause built from $filter, with property names already mapped to ABAP field names; because it is generated safely by the framework from the model, it can be used directly in a dynamic WHERE.
Paging comes from io_tech_request_context->get_top( ) and get_skip( ), and sorting from get_orderby( ), which you map to an ORDER BY clause. For the count, call io_tech_request_context->has_inlinecount( ) and, when it is set, run a COUNT with the same WHERE clause and fill es_response_context-inlinecount so the client knows the total result size for $inlinecount=allpages.
If you only want to read the columns the client actually asked for, get_select_with_mandtry_fields( ) gives you the $select list.
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
Interview questions on this topic
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
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.