A row limit only makes sense with a meaningful order

A dashboard preview shows the 20 newest orders. If the query limits rows without defining an order, “the first 20” may not consistently mean the newest 20.

Make the order explicit

ORDER BY createdat DESCENDING, dispatchorder ASCENDING

The first field places later timestamps first. The key field breaks ties, making the result order deterministic when timestamps match.

Limit a preview

UP TO 20 ROWS
INTO TABLE @DATA(orders).

This is suitable for a preview, not for silently truncating a business process that needs every qualifying row. For large result sets, consider paging, aggregation, or moving the filtering/processing closer to the data source.

Alternatives and release support

For small results, fetch all required rows and process them. For large user-facing lists, use the paging pattern supported by your source/framework and release. Row-limiting syntax and how it combines with other clauses are release-dependent; consult the target keyword documentation.

Practice

Add a stable two-column ordering and a 20-row limit before the table target. Count returned rows in result. This structural checker does not run the query.

Sources

Version note: Verify UP TO ... ROWS placement and supported syntax for your ABAP release.

Developer practice · ABAP

Practice: sort newest orders first

Order by CreatedAt descending, with DispatchOrder as a tie-breaker, and retrieve at most 20 preview rows.

Choose your ABAP environment

This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.

Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.

0 required structures detected · 0 checks