Show TOC

Screen Sequences: Example TransactionLocate this document in the navigation structure

Use

Transaction DEMO_SCREEN_FLOW is an example of screen sequences. This transaction belongs to the package SABAPDOCU and is delivered with the system. DEMO_SCREEN_FLOW lets users display and change flight data.

Function

DEMO_SCREEN_FLOW uses three screens. The screens 100 and 200 form a sequence. Screen 210 is a modal dialog box and is only called under special circumstances. The possible screen sequences can be represented as follows:

The user working in the system will see the following sequence:

  • Screen 100:

    The user enters an airline and flight number, and either presses ENTER to request the flight data or ends the transaction.

  • Screen 200:

    The system displays complete details about the flight, in input fields. The user types over the display to enter the changes.

  • Screen 210:

    The modal dialog box is only displayed if you try to leave screen 200 using Back or Exit without saving your changes. It allows you either to save or cancel the changes.

This transaction provides a good example of how screen sequences are implemented. Let us look at screen 200 to see how the modal dialog box is called.

Screen Flow Logic

When handling a BACK or EXI T function code, the PAI module must check whether flight details have changed since the screen display or last save. If this is the case, screen 210 is called as a modal dialog box. The following parts of the flow logic of screen 200 are as follows:

          
*---------------------------------------------------------------*
          
* Dynpro 200: Ablauflogik *
          
*---------------------------------------------------------------*
          
PROCESS AFTER INPUT.
          
MODULE exit_0200 AT EXIT-COMMAND.
          
...
          
MODULE user_command_0200.
            

Two dialog modules are called in the PAI event.

ABAP Code

The user interface of Transaction DEMO_SCREEN_FLOW has three functions for leaving a screen - Back, Exit, and Cancel. On screen 200, the user should only be able to leave the screen directly to screen 100 using Cancel. The function code is processed in the module EXIT_200. The next screen is set dynamically to 100, and screen 200 is terminated immediately with the LEAVE SCREEN statement.

          
*&---------------------------------------------------------------*
          
*& Modul EXIT_0200 INPUT
          
*&---------------------------------------------------------------*
          
MODULE exit_0200 INPUT.
          
CASE ok_code.
          
WHEN 'CANC'.
          
CLEAR ok_code.
          
SET SCREEN 100. LEAVE SCREEN.
          
ENDCASE.
          
ENDMODULE.
            

The remaining function codes for screen 200 are processed in the module USER_COMMAND_200.

  • The SAVE function triggers an update of the database.

  • The EXIT and BACK functions call the safety_check subroutine. This subroutine checks to see whether there is unsaved data on the screen, and, if required, calls screen 210.

          
*&---------------------------------------------------------------*
          
*& Modul USER_COMMAND_0200 INPUT
          
*&---------------------------------------------------------------*
          
MODULE user_command_0200 INPUT.
          
CASE ok_code.
          
WHEN 'SAVE'.
          
UPDATE spfli.
          
IF sy-subrc = 0.
          
MESSAGE s001 WITH spfli-carrid spfli-connid.
          
ELSE.
          
MESSAGE a002 WITH spfli-carrid spfli-connid.
          
ENDIF.
          
CLEAR ok_code.
          
WHEN 'EXIT'.
          
CLEAR ok_code.
          
PERFORM safety_check USING rcode.
          
IF rcode = 'EXIT'. SET SCREEN 0. LEAVE SCREEN. ENDIF.
          
WHEN 'BACK'.
          
CLEAR ok_code.
          
PERFORM safety_check USING rcode.
          
IF rcode = 'EXIT'. SET SCREEN 100. LEAVE SCREEN. ENDIF.
          
ENDCASE.
          
ENDMODULE.
            

If the user chooses Exit (function code EXIT), the screen sequence is terminated dynamically using SET SCREEN 0, and the transaction ends. If the user chooses Back (function code BACK), the next screen is changed dynamically to 100 using the statement SET SCREEN 100.

The subroutine safety_check checks the current screen values against the old values. If the values match, no save is needed, and the routine terminates.

          
*---------------------------------------------------------------*
          
* Unterprogramm SAFETY_CHECK *
          
*---------------------------------------------------------------*
          
FORM safety_check USING rcode.
          
LOCAL ok_code.
          
rcode = 'EXIT'.
          
CHECK spfli NE old_spfli.
          
CLEAR ok_code.
          
CALL SCREEN 210 STARTING AT 10 5.
          
CASE ok_code.
          
WHEN 'SAVE'. UPDATE spfli.
          
WHEN 'EXIT'.
          
WHEN 'CANC'. CLEAR spfli.
          
ENDCASE.
          
ENDFORM.
            

If the values differ, safety_check calls the modal dialog box of screen 210. This asks the user if he wants to save, and returns the answer (SAVE, EXIT and CANC) to the field okĀ­_code. The static next screen for screen 210 is 210. However, the processing logic (module USER_COMMAND_210) always sets the next screen dynamically to 0, which returns control to the subroutine.