Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Screens →  Statements in the Screen Flow Logic 

MODULE

Other versions: 7.31 | 7.40 | 7.54

Syntax


MODULE mod [ AT {EXIT-COMMAND|CURSOR-SELECTION} ] 
          [ ON {CHAIN-INPUT|CHAIN-REQUEST} ]
           [ SWITCH switch ].

Extras

1. ... AT EXIT-COMMAND

2. ... AT CURSOR-SELECTION

3. ... ON {CHAIN-INPUT|CHAIN-REQUEST}

4. ... SWITCH switch

Effect

The statement MODULE of the dynpro flow logic calls the dialog module mod of the ABAP program. You can use MODULE either as a keyword or as an addition of statement FIELD. When using it as an addition, the call of the dialog module depends on conditions for the screen fields.

As a keyword, the statement calls the dialog module mod of the respective ABAP program. At the event PAI, you can use the additions AT and ON to specify conditions for the call of the dialog module.

At the event PBO, you can call any dialog module defined in the ABAP program with the addition OUTPUT. At the events PAI, POH and POV, you can call any dialog module defined with the addition INPUT or without any addition. If the dialog module mod does not exist in the ABAP program, an untreatable exception is triggered. After processing a dialog module in the ABAP program, processing of the dynpro flow logic is resumed after the position of the call, unless the screen processing is completed within the dialog module.

You can use MODULE as a keyword only at the events PBO and PAI. At the events POH and POV, you can use MODULE only as an addition to the FIELD statement.


Note

Do not mix up the MODULE statement of the dynpro flow logic with the identically called statement MODULE for defining dialog modules in the ABAP program.

Addition 1

... AT EXIT-COMMAND

Effect

Addition AT EXIT-COMMAND at the event PAI causes module mod to be called exactly if:

  • The function used to trigger event PAI has function type "E"
  • Into the command field of the standard toolbar, the user entered a character string starting with "E" and confirmed it using ENTER.

The dialog module is called before the automatic input checks defined in the system or in the ABAP Dictionary and independently of its position in the event block. The only screen field transported to the ABAP program is the OK field. If the function that triggered the PAI event does not fulfill any of the above prerequisites, the MODULE statement is not executed.

If several MODULE statements have the AT EXIT COMMAND addition, only the first one is executed. If no MODULE statement has the addition AT EXIT COMMAND, a normal PAI processing is executed: The predefined input checks are executed and then the PAI event block is processed sequentially. Provided the screen processing is not terminated in the dialog module mod, after the return from the dialog module, the complete PAI processing is executed. You must not use the addition AT EXIT COMMAND in connection with the statement FIELD.


Note

The function type of a function is determined in the Screen Painter or Menu Painter. Usually those functions of the user interface are defined with function type "E" that are assigned to the icons Back, Exit and Cancel in the standard toolbar of the GUI status. Therefore, the called dialog module should terminate the screen processing and allow security checks, if required.

Addition 2

... AT CURSOR-SELECTION

Effect

The AT CURSOR-SELECTION addition at the event PAI causes the module mod to be called only if

  • The function used to trigger event PAI has function code "CS" and function type "S"
  • The cursor is placed on a single input or output field of the screen at the moment of the user action

The call occurs within the usual PAI processing, meaning that the automatic input checks defined in the system or in the ABAP Dictionary are executed and the MODULE statement is called according to its position in the event block. You can use the addition in connection with the FIELD statement.

If the PAI event is triggered under the above circumstances, the function code is not passed to sy-ucomm and the OK field. They keep their previous values.


Note

The function type and function code of a function are determined in the Screen Painter or in the Menu Painter. We recommend to assign function code "CS" in the Menu Painter to function key F2 in order to simultaneously assign the double-click function of the mouse to it. This allows you to assign dialog modules to the selection of input or output fields.

Addition 3

... ON {CHAIN-INPUT|CHAIN-REQUEST}

Effect

These conditions make sense only within chains using the CHAIN and ENDCHAIN statements. They check the individual conditions ON INPUT or ON REQUEST ON INPUT or ON REQUEST for all screen fields that are specified so far within the current chain after FIELD. The dialog module is called if at least on of the screen fields fulfills the respective condition.

Addition 4

...SWITCH switch

Effect

If the addition SWITCH is specified, the dialog module mod is called only if the switch specified by switch has the state on.

With switch, a switch defined in the Repository must be specified directly. If the specified switch does not exist, the dialog module will not be called.

You cannot specify the addition together with the statement FIELD. There, the switch assigned to the screen field in the Screen Painter applies.


Example

Typical structure of a simple dynpro flow logic. At PBO, a dialog module status_0100 is called to set the GUI status, at PAI, a dialog module leave_100 is called to handle functions with function type "E" and a dialog module user_command_0100 to handle the other user actions.

PROCESS BEFORE OUTPUT.
  MODULE status_0100.
PROCESS AFTER INPUT.
  MODULE leave_100 AT EXIT-COMMAND.
  MODULE user_command_0100.

The relevant ABAP program must implement the dialog modules and may have a structure like the one below. Because dialog module have no local data, we recommend to handle the actual processing within procedures that you call depending on the function code.

DATA: ok_code TYPE sy-ucomm,
      ...
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
ENDMODULE.

MODULE leave_100 INPUT.
  CASE ok_code.
    WHEN 'BACK'.
      ...
    WHEN 'CANCEL'.
      ...
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    ...
  ENDCASE.
ENDMODULE.

MODULE user_command_0100 INPUT.
  CASE ok_code.
    WHEN ...
      CALL ...
      ...
  ENDCASE.
ENDMODULE.

Continue

Module Call - Examples