ERPClimb logoERPClimb

Code examples · Modern ABAP · Beginner

ABAP report: selection screen, events and input checks

The problem

Sales wants a report that lists sales orders for a range of order numbers.

How we solve it

  1. 1Selection screenPARAMETERS, SELECT-OPTIONS
  2. 2Defaults and checksINITIALIZATION, AT SELECTION-SCREEN
  3. 3Read and listSTART-OF-SELECTION

The result

A report with a selection screen.

SAP objects in play

Overview drawn by ERPClimb from this example. The steps are the same as in the code below.

1. The requirement

Sales wants a report that lists sales orders for a range of order numbers. The user may limit the number of rows, but a number below 1 or above 1,000 must be refused on the selection screen, before any data is read.

2. How we design it

A report is a set of events that SAP runs in a fixed order. We declare the selection screen at the top, then give each job to the event that fits: defaults in INITIALIZATION, input checks in AT SELECTION-SCREEN, database read in START-OF-SELECTION, output in END-OF-SELECTION. Checks come first so a wrong input never reaches the database.

Why we decided it this way

  1. 1One event per jobCode is easy to find and the order is guaranteed by the runtime.
  2. 2Check the input on the selection screenAn error message there keeps the user on the screen to correct the value.
  3. 3Limit the read with UP TO n ROWSA wide range cannot read the whole table by accident.

Before you start

  • An on-premise SAP system with sales orders (table VBAK) and SAP GUI. Create the report in SE38 or ADT in package $TMP.

3. The code, step by step

Step 1 of 3: Declare the selection screen

A range of order numbers and a row limit.

ABAP · Report ZDEMO_SEL_EVENTS
" Parameter, select-option and frame
REPORT zdemo_sel_events.

DATA gv_vbeln TYPE vbak-vbeln.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t_b1.
  SELECT-OPTIONS s_vbeln FOR gv_vbeln.
  PARAMETERS p_max TYPE i DEFAULT 50.
SELECTION-SCREEN END OF BLOCK b1.
" Result table
TYPES: BEGIN OF ty_order,
         vbeln TYPE vbak-vbeln,
         erdat TYPE vbak-erdat,
         kunnr TYPE vbak-kunnr,
       END OF ty_order.
DATA gt_orders TYPE STANDARD TABLE OF ty_order WITH EMPTY KEY.
Part by part (plain text)
  1. Parameter, select-option and frame. SELECT-OPTIONS creates a range input (from, to, several values) for order numbers. It needs a variable to take its type from. PARAMETERS creates one input field. The frame title is a variable that we fill in INITIALIZATION.
  2. Result table. A local type with the fields we show, and a table of that type.

Open in the portal

The SAP objects named in this code are linked in the code above and listed here. Each opens its page in the SAP Library.

SAP tables

4. The final outcome

A report with a selection screen. Wrong input is refused with a message, and valid input lists orders.

What you should see

Max rows 0: the message 'Max rows must be between 1 and 1000' appears and the report does not run. Max rows 20 with a range of orders: up to 20 lines are listed. A range with no orders: the status line shows 'No sales orders found'.

Try it and check the result

  • Activate and run with F8. Enter 0 in the row limit field and press Execute: the error message appears and you stay on the selection screen.
  • Enter 20 and leave the order range empty: up to 20 orders are listed.
  • Enter a range that has no orders: the status line shows 'No sales orders found' in red and no list appears.

Common mistakes

  • Field labels on the selection screen show the technical names (S_VBELN, P_MAX) until you maintain selection texts (Goto, Text Elements, Selection Texts).
  • Do not read data in AT SELECTION-SCREEN. That event runs on every Enter, not only on Execute.
  • A warning or information message does not stop the program. Use type E in AT SELECTION-SCREEN to block it.
  • A big range with no row limit can read millions of rows. Always limit or filter on the key.

Keep learning

Checking status: Reviewed line by line against SAP documentation. Not executed on a live system. Reviewed 2026-11-25. Release: Classic ABAP on SAP NetWeaver 7.40 SP08 or higher (ECC 6.0 EHP7+) and S/4HANA on-premise (SAP GUI). Not available in ABAP Cloud development. Check on your release.

Original ERPClimb teaching code with illustrative names. Not taken from a customer system. Syntax can differ by release; check the references below and activate in a sandbox first. ERPClimb is independent of SAP SE.