sapdev logo background
sapdev logo sapdev logo
Comments

ABAP Radiobutton to Initiate the 'AT selection-screen' EVENT on SAP report




In-order for the Radiobutton selection process to initiate the 'AT selection-screen' event you need to add the 'USER-COMMAND' option to the parameter declaration. See code below or just copy it into an new ABAP program and execute it to see how it works.

The example simply displays or hides the field P_uname based on which radio button the user selects.


*Code used to Initiate the 'AT selection-screen' EVENT from radiobuttons.
selection-screen begin of block group with frame title text-s04.
parameters: p_sel1 type c radiobutton group sel user-command upd.
parameters: p_sel2 type c radiobutton group sel.
parameters: p_sel3 type c radiobutton group sel.
selection-screen end of block group.

DATA: gd_ucomm type sy-ucomm.

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'. "radiobutton selection made
      if p_sel2 eq 'X'. "hide field if second radio button selected
*     loop at screen code is used to change the output/display properties of the
*     screen fields.
        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.
      else. "else show field if 1st or 3rd radiobutton is selected
        LOOP at screen.
*       Use cs as this then captures all elements of the field inc text
          if screen-name cs 'P_UNAME'.
            screen-active = 1. "display field from screen
*          screen-input = 1. "set field as input
            modify screen.
          endif.
        ENDLOOP.
      endif.
  ENDCASE.


Also See:
Initiate AT selection-screen from LISTBOX dropdown
Initiate AT selection-screen from CHECKBOX
<--Report selection screen main menu




comments powered by Disqus