ERPClimb logoERPClimb
Login
All topics
ABAPIntermediate

Open SQL

Master Open SQL for fast, clean and HANA-friendly ABAP data access with joins, filters, aggregation, package processing and real project performance patterns.

Overview

Master Open SQL for fast, clean and HANA-friendly ABAP data access with joins, filters, aggregation, package processing and real project performance patterns.

Lessons in this topic

Interview questions covered

  • A SELECT statement into an internal table takes 30 seconds. After analyzing the code, you realize the WHERE clause doesn't use any indexed fields, and a full table scan is occurring. How would you refactor this, and what tools would you use to verify improvement?
  • Design a robust error handling and monitoring strategy for a production Open SQL batch job that processes 10 million rows. Include recovery, logging, and performance tracking.
  • Compare CDS Views vs. Open SQL for data retrieval in SAP S/4HANA. When would you recommend each approach?
  • You are tasked with fetching 500,000 sales orders and their line items for a month-end batch. Describe your approach to avoid memory issues and database timeouts, including PACKAGE SIZE, batching, and commit strategy.
  • You are debugging a SELECT query using ST05 (SQL Trace). Walk through the key metrics you would examine to diagnose performance issues and identify the root cause.
  • Explain the GROUP BY and HAVING clauses in Open SQL. Provide an example that counts orders by customer and filters for customers with > 10 orders.
  • Explain the relationship between index field order and WHERE-clause selectivity in Open SQL. Does the written order of conditions in the WHERE clause matter?
  • Describe the ORDER BY clause in Open SQL. What is the default sort order, and how do you specify descending order for specific fields? What are the performance implications?
  • You are designing a high-performance batch job to export 2 million sales orders to a data warehouse. Walk through your Open SQL strategy, including PACKAGE SIZE, indexing, and monitoring.
  • Write an Open SQL SELECT INTO TABLE statement that fetches material master header data from MARA for a list of materials. Include proper field selection, WHERE clause, and no-data handling.
  • Explain the difference between SELECT SINGLE and SELECT ... UP TO 1 ROWS in Open SQL. When would you use each, and what are the performance and determinism implications?
  • A SELECT statement returns duplicate rows due to a JOIN with a table that has multiple matches. How would you identify this issue and resolve it?
  • Explain aggregate functions in Open SQL (SUM, COUNT, AVG, MAX, MIN) and how they work with GROUP BY. Include how to handle NULL values.
  • A SELECT query returns results, but you notice unexpected NULL values in certain fields. How would you handle NULL values in Open SQL, and what are the implications for business logic?
  • A performance report queries sales data across 10 SAP tables. Explain your approach to optimize this using Open SQL, including when you would consider a CDS View or materialized aggregates.
  • You notice that a SELECT statement with an IN operator and a large list (5000 values) is slow. Explain the performance issue and propose alternatives.
  • Explain the concept of database pushdown in S/4HANA and how it influences your Open SQL design decisions.
  • A report uses multiple SELECT statements inside a loop, fetching related data for each order. Redesign this using a single query with JOINs and explain the performance benefit.
  • Your SELECT statement uses FOR ALL ENTRIES but the driver table is sometimes empty during execution. How does this affect the query result, and how would you code defensively?
  • Describe how client handling (MANDT) works in Open SQL. When is client filtering automatic, and when must it be handled explicitly?

How to study Open SQL

Open SQL has 10 lessons (3 beginner, 3 intermediate, 4 advanced) with about 85 minutes of reading in total. Start with the lesson that matches your level, then read the real project scenario and common mistakes in each one before moving on. After the lessons, say the 45 interview questions out loud in your own words, then check yourself against the model answer in each question (shown once you open it). Use the 29 mock questions to check recall. Finish with the 2 code lab scenarios: read the buggy code first, say what is wrong, and only then open the optimized version.

Mock test questions covered

Try answering each one before you open the mock test; the answer options and scoring are in the Mock Questions tab.

  • What happens when the FOR ALL ENTRIES driver table is empty?
  • Which change is a typical code pushdown on HANA?
  • Which SELECT uses a selection-screen range correctly?
  • When is SELECT SINGLE the right choice?
  • A join of order items and partners doubles item amounts in totals. What is the cause?
  • Which clause filters groups after aggregation?
  • Which construct keeps a database cursor open across COMMIT WORK?
  • In ST05, what does "identical selects" indicate?
  • Which strict-syntax feature lets the database classify rows?
  • Where should a join-and-calculation used by several programs and services be modeled?
  • How should an ABAP program change SAP standard application data (e.g. sales orders)?
  • Aggregate functions like SUM/COUNT require:
  • Best practice for large result sets in ABAP is to:
  • Which clause is NOT allowed with FOR ALL ENTRIES?
  • What must you check before using FOR ALL ENTRIES?

Code lab scenarios

  • SELECT inside LOOPFor each order in an internal table, read the customer name and print it. The current program is very slow when the table has 20k rows.
  • FOR ALL ENTRIES with an empty driver tableOn days when no materials are collected the report returns every row from MARA instead of nothing, and downstream logic corrupts inventory reports.

Related topics

Interview questions on this topic

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.