ERPClimb logoERPClimb

Code examples · Modern ABAP · Beginner

Dialog program (module pool): a screen with an input field, a Show button and a transaction code

The problem

Support staff want a tiny transaction ZCUST where they type a customer number, press Show and see the customer name.

How we solve it

  1. 1Datascreen fields
  2. 2PBOstatus and title
  3. 3PAIread the button

The result

The name appears for a known customer.

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

1. The requirement

Support staff want a tiny transaction ZCUST where they type a customer number, press Show and see the customer name. Back, Exit and Cancel must leave the program. An unknown customer shows a message at the bottom.

2. How we design it

A dialog program is a module pool: ABAP code that is not run by itself but by screens. Each screen has a layout, flow logic with the two events PBO (process before output) and PAI (process after input), and the program holds the modules that the flow logic calls. The function code of the pressed button arrives in the OK_CODE field. A transaction code starts the first screen.

Why we decided it this way

  1. 1Copy OK_CODE into SAVE_OK and clear itThe field is shared with the screen. Working on a copy avoids that an old code is processed again on the next round trip.
  2. 2The screen fields have the same names as the program variablesThe dynpro and the program exchange data by field name. GV_KUNNR and GV_NAME in the program are the fields of the same name on the screen.
  3. 3Information message shown as an errorA status message keeps the user on the screen with all input kept, while DISPLAY LIKE 'E' paints it red.

Before you start

  • SE80 with a new program ZCUST_DIALOG (type: module pool).
  • A GUI status ZSTATUS_0100 with the function codes SHOW, BACK, EXIT and CANC, created in the Menu Painter from the program.

3. The code, step by step

Step 1 of 3: Declare the screen fields and start the screen

Global fields that match the screen fields.

ABAP · Program · ZCUST_DIALOG (top include)
" Fields, OK code and the first call
PROGRAM zcust_dialog.

DATA: gv_kunnr TYPE kna1-kunnr,
      gv_name  TYPE kna1-name1,
      ok_code  TYPE sy-ucomm,
      save_ok  TYPE sy-ucomm.
Part by part (plain text)
  1. Fields, OK code and the first call. GV_KUNNR is the input field and GV_NAME the output field of screen 0100. In the screen painter the same names are used, and in the Element list the OK_CODE field is named OK_CODE. CALL SCREEN 100 in the transaction's start step shows the screen. The transaction ZCUST is created with SE93 as a program-and-screen transaction pointing to the program and screen 0100.

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

Transaction codes

4. The final outcome

The name appears for a known customer. For an unknown one the status bar shows a red message.

What you should see

Customer 1000 -> Name: Example Customer Inc. Customer 99999999 -> status bar: Customer not found

Try it and check the result

  • Activate everything (program, screen 0100, GUI status), create transaction ZCUST in SE93 and run it.
  • Enter 1000 and press Show: the name appears. Enter a wrong number: a red message appears and the field keeps its value.
  • Press Back: the transaction ends. Set a breakpoint in user_command_0100 to watch save_ok change.

Common mistakes

  • If the OK_CODE field is not named in the element list of the screen, save_ok stays empty and no button works.
  • A screen field and its program variable must have the same name and compatible type, or the data does not arrive.
  • An error message (type E) in PAI blocks the whole screen. A status message with DISPLAY LIKE 'E' is friendlier, or use the FIELD statement in the flow logic to open only the wrong field for input.
  • New developments in S/4HANA are usually built with Fiori or RAP, not with dialog screens. Dialog programming is still common in older code you will have to maintain.

Keep learning

Checking status: Reviewed line by line against SAP documentation. Not executed on a live system. Reviewed 2026-11-26. Release: Any ABAP system with ADT (S/4HANA, ECC 7.40 or newer, or a trial system). Classic techniques, not ABAP Cloud.

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.