Thursday, July 2, 2026

๐Ÿš€ SAP ABAP Mock Interview — Question 2/50

 

⚠️ The Empty Driving Table Trap in FOR ALL ENTRIES

๐Ÿ“‹ Scenario

Consider the following code:

SELECT *
 FROM vbak
 INTO TABLE lt_vbak.
SELECT *
  FROM vbap
  INTO TABLE lt_vbap
  FOR ALL ENTRIES IN lt_vbak
  WHERE vbeln = lt_vbak-vbeln.

❓ Question

1️⃣ What will happen if lt_vbak is empty?
2️⃣ Why is this dangerous? ๐Ÿค”


⚙️ What Happens?

If the driving internal table (lt_vbak) is empty, the FOR ALL ENTRIES condition is ignored.

Effectively, SAP executes:

SELECT *
  FROM vbap
  INTO TABLE lt_vbap.

๐Ÿ”ด All records from VBAP are fetched!


⚠️ Why Is This Dangerous?

  • ๐Ÿ—„️ Massive and unnecessary data retrieval
  • ๐Ÿ’พ High memory consumption
  • ๐Ÿ“‰ Significant performance degradation
  • ⏱️ Potential TIME_OUT dump
  • ๐Ÿ“Š Potential TSV_TNEW_PAGE_ALLOC_FAILED dump
  • ๐Ÿšจ Can severely impact system resources in production


๐Ÿ›ก️ Correct Prevention

Always check whether the driving internal table contains data before using FOR ALL ENTRIES.

Classic Approach:

IF lt_vbak IS NOT INITIAL.
  SELECT *
    FROM vbap
    INTO TABLE lt_vbap
    FOR ALL ENTRIES IN lt_vbak
    WHERE vbeln = lt_vbak-vbeln.
ENDIF.

Modern ABAP:

CHECK lt_vbak IS NOT INITIAL.

๐Ÿ’ก This ensures the query runs only when there is data to fetch.


๐ŸŽ“ Interview Tip

Many developers answer:
๐Ÿ‘‰ "It causes high database hits."

That's not entirely accurate.

The real issue is usually:
๐Ÿ‘‰ One extremely expensive database read that can fetch millions of records.

Precise terminology matters in senior-level interviews.


๐Ÿ’ฌ Bonus Question

Would your answer change if lt_vbak contained duplicate VBELN values?
Let's discuss in the comments! ๐Ÿ‘‡


๐Ÿ“Œ Always validate your driving table and remove duplicates for safe and efficient data retrieval.

Wednesday, July 1, 2026

๐Ÿš€ SAP ABAP Mock Interview — Question 1/50

 

๐ŸŽฏ VBAK-VBAP Data Retrieval for 100,000 Sales Orders

๐Ÿ“‹ Scenario

You're asked to fetch data from VBAK (Sales Document Header) and VBAP (Sales Document Item) for 100,000 Sales Orders.



❓ Which Approach Would You Choose?

A) ๐Ÿ—„️ Nested SELECT
B) ๐Ÿ” FOR ALL ENTRIES
C) ๐Ÿ”— INNER JOIN
D) ๐Ÿ“ฆ CDS VIEW

๐Ÿ‘‡ Comment your answer below!


๐Ÿ’ก My Answer

For this scenario, I would primarily choose an INNER JOIN.

1️⃣ Nested SELECT

  • Avoid.
  • Causes excessive database round-trips.
  • Performance degrades significantly as data volume grows.

2️⃣ FOR ALL ENTRIES ๐Ÿค”

  • Better than Nested SELECT.
  • Useful when JOINs are not feasible.
  • With a very large driving table, SQL generation can become complex and less efficient.


3️⃣ INNER JOIN

  • Best fit for VBAK-VBAP header-item retrieval.
  • Single database access.
  • Optimized by SAP HANA.
  • Cleaner and easier to maintain.


4️⃣ CDS View
⚠️
My choice if the data model needs:

  • Reusability
  • OData exposure
  • Analytics
  • Semantic modeling
  • Future extensibility

๐Ÿ‘‰ For a straightforward report, INNER JOIN is usually the simplest and most performant solution.


๐ŸŽ“ Interview Tip

Many candidates immediately answer "CDS View" because it's the modern approach.

A good interviewer is evaluating your decision-making, not your ability to memorize buzzwords.

The best answer is always:
๐Ÿ‘‰ "It depends on the requirement."


๐Ÿ’ฌ Discussion Question

Would your answer change if this requirement was for an OData service instead of a report? Let's discuss in the comments! ๐Ÿ‘‡