Entering content frameScreen Sequences: Example Transaction Locate the document in its SAP Library structure

You can use Transaction DEMO_SCREEN_FLOW as a sample transaction for screen sequences. This transaction is in package SABAPDOCU and is delivered with the system. You can display and change flight data in Transaction DEMO_SCREEN_FLOW.

Features

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

This graphic is explained in the accompanying text

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

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

This graphic is explained in the accompanying text

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

This graphic is explained in the accompanying text

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 graphic is explained in the accompanying text

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 EXIT 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:

*---------------------------------------------------------------*
*   Screen 200: Flow logic                                      *
*&--------------------------------------------------------------*
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 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.

*&---------------------------------------------------------------*

*& Module 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 trigger calls to the SAFETY_CHECK routine. This subroutine checks to see whether there is unsaved data on the screen, and, if required, calls screen 210.

*&---------------------------------------------------------------*

*& Module 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.

*---------------------------------------------------------------*

* Subroutine 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 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.

 

 

Leaving content frame