Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Dynpros →  Statements in the Screen Flow Logic →  FIELD →  Handling of messages at event PAI →  Input Checks - Examples 

Screens, Input Checks in Dialog Modules

The example shows how to check input fields in dialog modules.

Other versions: 7.31 | 7.40 | 7.54

Source Code

PROGRAM demo_dynpro_field_chain.

DATA: ok_code TYPE sy-ucomm,
      input1 TYPE i, input2 TYPE i, input3 TYPE i,
      input4 TYPE i, input5 TYPE i, input6 TYPE i,
      sum TYPE i.

CALL SCREEN 100.

MODULE init_screen_100 OUTPUT.
  CLEAR: input1, input2, input3, input4, input5, input6.
  SET PF-STATUS 'STATUS_100'.
ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE module_1 INPUT.
  IF input1 < 50.
    MESSAGE e888(sabapdemos) WITH text-001 '50' text-002.
  ENDIF.
ENDMODULE.

MODULE module_2 INPUT.
  IF input2 < 100.
    MESSAGE e888(sabapdemos) WITH text-001 '100' text-002.
  ENDIF.
ENDMODULE.

MODULE module_3 INPUT.
  IF input3 < 150.
    MESSAGE e888(sabapdemos) WITH text-001 '150' text-002.
  ENDIF.
ENDMODULE.

MODULE chain_module_1 INPUT.
  IF input4 < 10.
    MESSAGE e888(sabapdemos) WITH text-003 '10' text-002.
  ENDIF.
ENDMODULE.

MODULE chain_module_2 INPUT.
  CLEAR sum.
  sum = sum + : input4, input5, input6.
  IF sum <= 100.
    MESSAGE e888(sabapdemos) WITH text-004 '100' text-002.
  ENDIF.
ENDMODULE.

MODULE execution INPUT.
  MESSAGE i888(sabapdemos) WITH text-005.
ENDMODULE.

Description

The static next screen number of screen 100 is 100. The input fields are assigned the screen fields input1 to input6. The function code of the pushbutton is EXECUTE.

In the GUI status STATUS_100, the icon Cancel (F12) has been activated using the function code CANCEL with the function type E. The function key F8 is assigned the function code EXECUTE without any specific function type. The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.
  MODULE init_screen_100.
PROCESS AFTER INPUT.
  MODULE cancel AT EXIT-COMMAND.
  FIELD input1 MODULE module_1.
  FIELD input2 MODULE module_2.
  FIELD input3 MODULE module_3.
  CHAIN.
    FIELD input4.
    MODULE chain_module_1.
    FIELD input5.
    FIELD input6 MODULE chain_module_2.
  ENDCHAIN.
  MODULE EXECUTION.

The fields input1 to input3 are checked separately in the modules module_1 to module_3. Unless the user specifies an appropriate value, the screen is dislayed again and again with the corresponding field in ready-for-input mode.

The fields input4 to input6 are checked jointly in the processing chain. If input4 does not match the condition in chain_module_1, all three fields are reset as ready for input. The same happens if the three fields do not match the condition in chain_module_2.

It is not before all six fields match the conditions that the module EXECUTION is executed which issues an information message.