IT CanvassTalk to an advisor
SAP examples · LessonBy , SAP Trainer, 10 yrs · Published · SAP S/4HANA 2023 · all levels

ABAP examples

These ABAP examples show the everyday patterns, a report, a class, database access and an ALV grid, that make up most custom SAP development, with commentary on doing them well.

Quick answer

These embody the core habits: use ALV for output, select only needed data with a WHERE, read into internal tables rather than looping the database, and write clear, typed code.

Key takeaways
  • Watch out: SELECT in a loop, the classic performance killer.
  • Worked examples: a simple report with alv, efficient database access, what the examples teach.
  • How ABAP examples fits into SAP development and the wider SAP landscape

A simple report with ALV

REPORT z_open_pos.
SELECT ebeln, ebelp, matnr, menge FROM ekpo
  INTO TABLE @DATA(lt_items) UP TO 100 ROWS.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
                        CHANGING t_table = lt_items ).
lo_alv->display( ).

Efficient database access

" read once into a table, then work in memory (never SELECT in a loop)
SELECT matnr, maktx FROM makt
  FOR ALL ENTRIES IN @lt_items WHERE matnr = @lt_items-matnr
  INTO TABLE @DATA(lt_texts).

What the examples teach

These embody the core habits: use ALV for output, select only needed data with a WHERE, read into internal tables rather than looping the database, and write clear, typed code. Adapt them into your own reports and classes.

Common pitfalls

  • SELECT in a loop, the classic performance killer.
  • Hand-coded output instead of ALV.
  • Untyped, unclear code.

Practice challenge

+0 XPStreak ×0
Question 1 of 3
Which statement is true of ABAP examples?

Frequently asked questions

What does the term ABAP examples refer to in SAP?
These ABAP examples show the everyday patterns, a report, a class, database access and an ALV grid, that make up most custom SAP development, with commentary on doing them well.
What else is worth knowing about ABAP examples?
These embody the core habits: use ALV for output, select only needed data with a WHERE, read into internal tables rather than looping the database, and write clear, typed code.
What tends to go wrong with ABAP examples?
SELECT in a loop, the classic performance killer. Hand-coded output instead of ALV. Untyped, unclear code.
Already working on SAP and stuck on a live ticket?Get an expert SAP developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support