SAP ABAP-AT SELECTION-SCREEN Event, Example With Output.


At Selection-Screen Event gets triggered right after the Initialization event. This event is basically used to validate fields present in selection screen. Through this event, checks can be incorporated on selection screen fields and appropriate message can be sent back to the screen/user.

In simple words, when the user enters the value in the fields of the selection screen and executes it, AT SELECTION-SCREEN event gets triggered. It is used to check or validate the values entered by the user for the fields on selection screen.

Authority checks can also be performed in this event.

This event gets triggered in two ways:
  • When the user enters the value in the fields of selection screen and executes it (F8).
  • When the user enters the “ENTER” BUTTON on the selection screen.


DIFFERENT TYPES OF AT SELECTION-SCREEN EVENTS (In order of execution):

  • At Selection-Screen Output.
  • At Selection-Screen On Value Request For <Field>.
  • At Selection-Screen On Help Request For <Field>.
  • At Selection-Screen On <field- select-options>.
  • At Selection-Screen On <field-Parameter>.
  • At Selection-Screen On Block <blockname>.
  • At Selection-Screen On Radiobutton Group <groupname>.
  • At Selection-Screen.


SAMPLE PROGRAM - 1:



REPORT ztest MESSAGE-ID zebg1.

TABLES: bsid, vbrk.

DATA: temp_vkorg TYPE vbrk-vkorg,
temp_bukrs TYPE bsid-bukrs.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE title.
PARAMETER: s_bukrs LIKE bsid-bukrs. " Company Code
PARAMETER: s_hkont LIKE bsid-hkont OBLIGATORY. " G/L Account
PARAMETER: s_vkorg LIKE vbrk-vkorg. " Sales Organization


PARAMETER: p_budat LIKE bsid-budat OBLIGATORY DEFAULT sy-datum. " As On Date
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN SKIP.

INITIALIZATION.
s_hkont = '0015515001'.
title = 'Please enter the following details'.


AT SELECTION-SCREEN.

IF s_bukrs IS NOT INITIAL.

SELECT SINGLE bukrs FROM bsid INTO temp_bukrs
WHERE bukrs EQ s_bukrs.
IF sy-subrc NE 0 .
MESSAGE 'Please enter correct Company Code' TYPE 'E'.
ENDIF.

ENDIF.

IF s_vkorg IS NOT INITIAL.

SELECT SINGLE vkorg FROM vbrk INTO temp_vkorg
WHERE vkorg EQ s_vkorg.
IF sy-subrc NE 0 .
MESSAGE 'Please enter correct Sales Organisation' TYPE 'E'.
ENDIF.

ENDIF.

IF p_budat CP '2011*'.
MESSAGE 'The report will be generated For year 2011' TYPE 'I'.
ENDIF.


START-OF-SELECTION.
WRITE: 'This is a test program.'


OUTPUT:



Enter Company Code: 2522. Execute the report or press enter.


Enter Sales Organization: 5436. Execute the report or press enter.



When the user enters valid company code and sales organization and executes the report or press enter button on the screen.



On executing the report:



ALSO READ:

- ABAP EVENTS During Runtime Of A Report Program.

- INITIALIZATION Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN OUTPUT Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN ON VALUE REQUEST- Introduction With A Sample Code.

- AT SELECTION-SCREEN ON HELP REQUEST- Introduction With A Sample Code.

- AT SELECTION-SCREEN ON - Introduction With A Sample Code.


- Sample Program On AT SELECTION-SCREEN OUTPUT - 1.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 2.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 3.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 4.

- Sample Program On AT SELECTION-SCREEN ON VALUE REQUEST FOR field - 1.

- Sample Program On AT SELECTION-SCREEN ON VALUE REQUEST FOR field - 2.

- Sample Program On AT SELECTION-SCREEN ON HELP REQUEST FOR field- 1.


Your suggestions and comments are welcome in this section.

Please mail all your contributions to administrator@abapmadeeasy.com We request you to mention your Name, Designation, Experience & Organization you are working for. Your posts will be verified and posted in this site with your name.