1
votes

I am trying to toggle(hide) the selection screens based on radio button input. But the code seems not working.

" Radio button block

SELECTION-SCREEN BEGIN OF BLOCK search_block WITH FRAME TITLE text-001.
PARAMETER: rad_flt RADIOBUTTON GROUP rgb DEFAULT 'X',
    rad_cus RADIOBUTTON GROUP rgb.
SELECTION-SCREEN END OF BLOCK search_block.


" Selection screen 1

SELECTION-SCREEN BEGIN OF BLOCK flight_block WITH FRAME TITLE text-002.
PARAMETER: carrid TYPE sbook-carrid,
   connid TYPE sbook-connid,
   fldate TYPE sbook-fldate MODIF ID sc1.
SELECTION-SCREEN END OF BLOCK flight_block.

" Selection screen 2

SELECTION-SCREEN BEGIN OF BLOCK customid_block WITH FRAME TITLE text-002.
PARAMETER: customid TYPE sbook-customid MODIF ID sc2.
SELECTION-SCREEN END OF BLOCK customid_block.


AT SELECTION-SCREEN OUTPUT.
*Toggle the selection screens based on radio buttons
LOOP AT SCREEN.
    IF rad_flt = 'X' AND screen-group1 = 'sc2'.
        screen-active = 0.
        MODIFY SCREEN.
    ELSEIF rad_cus = 'X' AND screen-group1 = 'sc1'.
        screen-active = 0.
        MODIFY SCREEN.
    ENDIF.
 ENDLOOP.

The screen displays all the screens. Not able to track the issue using debugger.

1
Why "not able [to debug]"? I can debug your code without any issue and I see that your bug is because 'sc1' and 'sc2' are written in lower case, but the actual value is all upper case (which is automatically done by SAP). NB: use PARAMETERS (with trailing "S"), PARAMETER is obsolete. Now, if you are saying that clicking a radio button does not trigger an action at SAP, that's how SAP works by default, but you can change the behavior by adding the words USER-COMMAND any_ucomm.Sandra Rossi
Question also asked at SAP Community, which has got some answers.Sandra Rossi

1 Answers

4
votes

By default radio buttons don't trigger any events, which is what you need to perform some actions on radio button toggle (and not on Enter press or execution). You can do it by adding user-command <eventcode> to your radio button group and then handling those events in At selection-screen output .

tables: sscrfields. "Only needed if you need to tell different events apart.
select-options:
 so_1_1 for lfa1-lifnr modif id g1, 
 so_1_2 for lfa1-kunnr modif id g1,
 so_2_1 for kna1-lifnr modif id g2,
 so_2_2 for kna1-kunnr modif id g2,

parameters:
  p_1 radiobutton group prct user-command rb_prct default 'X', 
  p_2 radiobutton group prct, 
  p_3 radiobutton group prct.
at selection-screen.
  lv_ucomm = sscrfields-ucomm. "only needed if you need to tell different events apart.
At selection-screen output.
    "In here you can check if lv_ucomm = 'RB_PRCT' before doing anything
    case abap_true.
      when p_1.
        lv_group = 'G1'.
      when p_2.
        lv_group = 'G2'.
      when p_3.
        lv_grou = ' '.
    endcase.
    loop at screen.
      screen-active = boolc( screen-group1 is initial or screen-group1 = lv_group )
      modify screen.
    endloop.

Something like this will fit your needs, but if you need more processing on radio button press (and not to anything on other actions) you might want to use the SSCRFIELDS related logic to check which event is fired and only process the one that comes from your radio buttons.