In-order for the Listbox selection process to initiate the 'AT selection-screen' event you need to
add the USER-COMMAND option to the parameter declaration. See code below for exact syntax or simply
create an BAP report with the following code. You can then execute it to see the code in action.
The example simply hides the field P_uname when the user selects and option from the listbox dropdown.
*Code used to Initiate the 'AT selection-screen' EVENT from LISTBOX. REPORT LISTBOX_UCOMM. DATA: gd_ucomm type sy-ucomm. PARAMETERS p_cid TYPE spfli-carrid AS LISTBOX VISIBLE LENGTH 25 USER-COMMAND UPD. PARAMETERS: p_uname type uname. AT SELECTION-SCREEN. *This event is then triggered when a user selects an option from the LISTBOX gd_ucomm = sy-ucomm. "capture user command If sy-ucomm eq 'UPD'. "listbox selection made * add code here to process data ENDIF. AT SELECTION-SCREEN OUTPUT. * The OUTPUT event is also trigged to re-draw ABAP report screen allowing it to * be used to hide, display or deactivate fields. Please note at this point sy-ucomm field * has been refreshed so you need to use value captured above in gd_ucomm case gd_ucomm. when 'UPD'. "listbox selection made * loop at screen code is used to change the display properties of the screen fields. * I.e. allows you to hide, display or set as output only fields on the ABAP selection * screen LOOP at screen. * Use cs as this then captures all elements of the field inc text if screen-name cs 'P_UNAME'. screen-active = 0. "remove field from screen * screen-input = 0. "set field as display only modify screen. endif. ENDLOOP. ENDCASE.
Also See:
Add dropdown list (listbox)
Initiate AT selection-screen from RADIOBUTTON
Initiate AT selection-screen from CHECKBOX
<--Report selection screen main menu