Starting Lists from Screen Processing 

This section describes how to switch from screen processing to list processing. It contains a short technical introduction, followed by a recommended procedure.

Switching Between Screen and List Processing

Screen processing always involves a

screen sequence that you start either using CALL SCREEN or a transaction code. During screen processing, the ABAP program is controlled by the dialog processor. In the ABAP program, the PBO and PAI modules are executed as they are called from the screen flow logic.

To pass control from the dialog processor to the list processor, you must include the following statement in one of the dialog modules:

LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN <nnnn>].

You can include this statement in either the PBO or the PAI event. Its effect is to start the list processor and display the basic list after the PAI processing of the current screen. The basic list contains any list output from all PBO and PAI modules that have been executed up to that point.

If detail lists are defined in the corresponding event blocks of the ABAP program (AT LINE-SELECTION, AT USER-COMMAND), user actions on the basic list will lead to the detail list, and further interaction will lead to further list levels.

You can leave list processing in two ways:

  • By leaving the basic list using the Back, Exit, or Cancel function.
  • By using the following statement during list processing:

    LEAVE LIST-PROCESSING.

In both cases, control returns from the list processor to the dialog processor. Each time this occurs, the entire list system is initialized. Any subsequent list output statements in PBO and PAI modules apply to an empty basic list.

By default, the dialog processor returns to the PBO processing of the screen from which the list processor was called. The optional addition AND RETURN TO SCREEN allows you to specify a different screen in the current screen sequence at whose PBO event you want to resume processing. In particular, the statement

LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.

can be used to end the current screen sequence and return to the point from which it had originally been called.

Recommended Procedure

If you want to display lists during screen processing, you should create a separate screen for each list system that you want to call. This screen encapsulates the creation and display of the basic list. It can then be called from anywhere in the program using CALL SCREEN.

The actual screen mask of this screen can remain empty. You do not need any PAI modules, and only a single PBO module. In the PBO module, you define the basic list of the list system and call the list processor.

  1. First, use the

    LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.

    statement to call the list display at the end of the screen, and to ensure that, after leaving the list, you return to the point from which the screen was called.
  2. Next, set a GUI status for the list; for example, the default list status SPACE or a list status of your own.
  3. Use one of the following statements to ensure that the empty screen is not displayed:

    SUPPRESS DIALOG.

    or

    LEAVE SCREEN. Instead, the list is displayed immediately at the end of the screen.
  4. Now define the entire basic list, and place any necessary data in the HIDE area.

If you want to process user actions on the list, you need to define the relevant event blocks in your ABAP program. If you want to call more than one independent list system in the program, you must ensure that you can tell them apart in the list event processing. You cannot do this using SY-DYNNR, since the container screen for a list is always number 120. Instead, you could assign a different GUI status to each list, and distinguish between the list systems using the value of SY-PFKEY, or you could place some unique information in the HIDE area of each list system.

Example

REPORT demo_leave_to_list_processing .

TABLES sdyn_conn.

DATA: wa_spfli TYPE spfli,
 flightdate TYPE sflight-fldate.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
 SET PF-STATUS 'SCREEN_100'.
ENDMODULE.

MODULE cancel INPUT.
 LEAVE PROGRAM.
ENDMODULE.

MODULE user_command_0100.
 CALL SCREEN 500.
 SET SCREEN 100.
ENDMODULE.

MODULE call_list_500 OUTPUT.
 LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
 SET PF-STATUS space.
 SUPPRESS DIALOG.
 SELECT carrid connid cityfrom cityto
 FROM spfli
 INTO CORRESPONDING FIELDS OF wa_spfli
 WHERE carrid = sdyn_conn-carrid.
 WRITE: / wa_spfli-carrid, wa_spfli-connid,
  wa_spfli-cityfrom, wa_spfli-cityto.
 HIDE: wa_spfli-carrid, wa_spfli-connid.
 ENDSELECT.
 CLEAR: wa_spfli-carrid.
ENDMODULE.

TOP-OF-PAGE.
 WRITE text-001 COLOR COL_HEADING.
 ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.
 WRITE sy-lisel COLOR COL_HEADING.
 ULINE.

AT LINE-SELECTION.
 CHECK not wa_spfli-carrid is initial.
 SELECT fldate
 FROM sflight
 INTO flightdate
 WHERE carrid = wa_spfli-carrid AND
 connid = wa_spfli-connid.
  WRITE / flightdate.
 ENDSELECT.
 CLEAR: wa_spfli-carrid.

This example switches to list processing during the screen processing for screen 100. Screen 100 has a single input field - the component CARRID from the ABAP Dictionary structure SDYN_CONN.

It has the following flow logic:

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100.

PROCESS AFTER INPUT.
 MODULE CANCEL AT EXIT-COMMAND.
 MODULE USER_COMMAND_0100.

The PAI module USER_COMMAND_100 calls screen 500 using the CALL SCREEN statement. This screen encapsulates a basic list. It has the following flow logic:

PROCESS BEFORE OUTPUT.
 MODULE CALL_LIST_500.

PROCESS AFTER INPUT.

The module CALL_LIST_500 defines the basic list and switches to list processing. Since the next screen after list processing is screen 0, screen 500 is a one-screen screen chain. After list processing, control returns to the position in USER_COMMAND_100 from which screen 500 was called.

If the user selects a line on the basic list, a detail list appears. This is achieved through the event block AT LINE-SELECTION. The program also contains event blocks for TOP-OF-PAGE and TOP-OF-PAGE DURING LINE-SELECTION, which define page headers for both the basic list and detail list.

Since there is only one list system in this program, there is no need for case distinctions within the list events.