Complex Joins & Subqueries
Task
Fetch all sales documents along with theiritem count using a JOIN between header and item tables. Use a subquery or aggregation to calculate item count per document.
Write Your ABAP Code
Loading...
📥 Sample Output
VBELN ITEM_COUNT 50000123 5 50000124 2
💡 Hint
Use INNER JOIN with GROUP BY or a correlated subquery to calculate item counts.
✅ View Reference Solution
SELECT vbak~vbeln,
COUNT( vbap~posnr ) AS item_count
FROM vbak
INNER JOIN vbap
ON vbak~vbeln = vbap~vbeln
GROUP BY vbak~vbeln
INTO TABLE @DATA(lt_result).