โ€” Code Lab

SAP Code Lab for ABAP Programming (ABAP) Learning

Practise ABAP Programming scenarios in SAP: paste code or a process example and get an explanation, bug review, optimisation or interview-style breakdown.

Code Lab

Live Sample preview

Paste ABAP and get performance findings and refactors.

Do not paste confidential client code, customer data or personally identifying information. Use synthetic or anonymised content only.

Sample preview โ€” illustrative data, not your result
Sample ABAP
ABAP Code
SELECT * FROM vbap INTO TABLE lt_items.LOOP AT lt_items INTO ls_item.  SELECT SINGLE kunnr FROM vbak    INTO lv_kunnr    WHERE vbeln = ls_item-vbeln.ENDLOOP.
Performance finding

SELECT SINGLE inside a LOOP is a classic N+1 pattern โ€” the database is hit once per item row.

Recommendation

Read VBAK once with FOR ALL ENTRIES IN lt_items (guarding against empty tables) or a CDS join, then look up KUNNR from an internal table with a sorted/hashed key.

Analyse My Code

Sign in to run this on your own content. Weโ€™ll bring you right back here.