banner ads

At Selection Screen event

At Selection Screen event



AT-SELECTION SCREEN is an event which is used in ABAP at the time of processing the selection screen. Any validation for the screen fields are done with this event. It is triggered at the run time environment during the processing of selection screen. This event occurs immediately before sending a selection screen. AT SELECTION SCREEN is triggered twice. The first time when the system calls the selection screen, it triggers and second time when the called screen links to another screen which is basically a sub screen, it triggers again. This event is triggered internally if we don’t mention in the program. Otherwise we mention this when we need to modify the screen operation.

In the following program we have used AT-SELECTION SCREEN event with an error message. Though it is an error message, we see that the fields are enabled in the output.

REPORT  zsr_test.

PARAMETERS: p_matnr TYPE mara-matnr,
            p_werks TYPE marc-werks,
            p_lgort TYPE mard-lgort.

AT SELECTION-SCREEN.

  IF p_werks IS INITIAL.
    MESSAGE 'Enter Plant' TYPE 'E'.
  ENDIF.


Now we shall modify this event with adding a clause – ON FIELD. Here we see that the declared field is enabled only and the rest of the fields are disabled.

REPORT  zsr_test.

PARAMETERS: p_matnr TYPE mara-matnr,
            p_werks TYPE marc-werks,
            p_lgort TYPE mard-lgort.

AT SELECTION-SCREEN ON p_werks.

  IF p_werks IS INITIAL.
    MESSAGE 'Enter Plant' TYPE 'E'.
  ENDIF.

No comments