Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  SAP GUI User Dialogs →  General Dynpros →  Statements in the Dynpro Flow Logic →  MODULE →  Module Call - Examples 

Dynpros, Simple Module Calls

This example demonstrates how to call a module.

Other versions: 7.31 | 7.40 | 7.54

Source Code

PROGRAM demo_dynpro_module.

TABLES demo_conn.

DATA: ok_code TYPE sy-ucomm,
      save_ok LIKE ok_code,
      wa_spfli TYPE spfli.

CALL SCREEN 100.

MODULE init_screen_100 OUTPUT.
  MOVE-CORRESPONDING wa_spfli TO demo_conn.
ENDMODULE.

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_100'.
  SET TITLEBAR '100'.
ENDMODULE.

MODULE clear_ok_code INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
ENDMODULE.

MODULE get_data INPUT.
  MOVE-CORRESPONDING demo_conn TO wa_spfli.
  CLEAR demo_conn.
ENDMODULE.

MODULE user_command_0100 INPUT.
  CASE sy-dynnr.
    WHEN 0100.
      CASE save_ok.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
        WHEN 'DISPLAY'.
          PERFORM read_data.
        WHEN 'CLEAR'.
          CLEAR wa_spfli.
      ENDCASE.
      ...
  ENDCASE.
ENDMODULE.

FORM read_data.
  SELECT  SINGLE
          cityfrom, airpfrom, cityto, airpto, fltime, deptime, arrtime
    FROM  spfli
    WHERE carrid = @wa_spfli-carrid AND connid = @wa_spfli-connid
    INTO  CORRESPONDING FIELDS OF @wa_spfli.
ENDFORM.

Description

The static next dynpro number of dynpro 100 is 100. Its layout is taken from the fields of the structure DEMO_CONN in ABAP Dictionary. The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.
   MODULE init_screen_100.
   MODULE status_0100.
PROCESS AFTER INPUT.
   MODULE clear_ok_code.
   MODULE get_data.
   MODULE user_command_0100.

In the GUI status STATUS_100, the icon Cancel (F12) is activated using the function code CANCEL and the function keys F5 and Shift+F2 are assigned the function codes DISPLAY and CLEAR. The way this program works is similar to the executable example Processing Input/Output Fields, but the processing logic is distributed across multiple dialog modules and a subroutine is used to read the data from the database.