Dynamically change the selection screen of a report based on the radio buttons.

SAP Radio biutton

Dynamically change the selection screen of a report based on the radio buttons.
Here we have requirement to enable a selection screen (second selection screen) based on radio button RAD2 in first selection screen .Also restricting input to single values using  FM SELECT_OPTIONS_RESTRICT.



When RAD1 is selected :

When RAD2 is selected:

All multiple option available for connection number :
 




Restricting for single value for Arline :

 




Code :
*&---------------------------------------------------------------------*
*& Report  ZTEST_RADIO
*&http://sapmatrix.blogspot.in/
*&---------------------------------------------------------------------*
**********************************************************************
*In this code we can change the selection screen based on the radio button
**********************************************************************

REPORT  ztest_radio.
TABLES :sflight.
TYPE-POOLS:sscr.

**********************************************************************
*Data Declaration
**********************************************************************
DATA:
* Selection screen data for restriction
wa_restrict 
TYPE sscr_restrict.
* Auxiliary objects for filling RESTRICT
DATA : wa_optlist TYPE sscr_opt_list.
DATA : wa_sccr TYPE sscr_ass.
**********************************************************************
*Clear work area
**********************************************************************
CLEAR :wa_restrict,wa_optlist,wa_sccr.
**********************************************************************
*First selection screen for Radio button
**********************************************************************

SELECTION-SCREEN: BEGIN OF BLOCK b11 WITH FRAME TITLE text-001.
PARAMETERS :p_rad1  RADIOBUTTON GROUP rad1 USER-COMMAND ur1
            
DEFAULT 'X' MODIF ID m_r,
            p_rad2  
RADIOBUTTON GROUP rad1  MODIF ID m_r.
SELECTION-SCREEN :END OF  BLOCK b11.

**********************************************************************
*Second selection block
**********************************************************************
SELECTION-SCREEN: BEGIN OF BLOCK bl2 WITH FRAME TITLE text-002.
PARAMETERS p_userid    TYPE sy-uname MODIF ID m_s .
SELECT-OPTIONS s_acode FOR sflight-carrid MODIF ID m_s.
SELECT-OPTIONS s_anum  FOR sflight-connid MODIF ID m_s.
SELECTION-SCREEN: END   OF BLOCK bl2.

INITIALIZATION.

**********************************************************************
*Here we can change the selection field  option to only " EQ "for Arline code
**********************************************************************
* Restricting the Airline code selection to only EQ
  wa_optlist
-name 'OBJECTKEY'.
  wa_optlist
-options-eq 'X' .
  
APPEND wa_optlist TO wa_restrict-opt_list_tab.
  
CLEAR wa_optlist.
  wa_sccr
-kind 'S'."Field type Select-Option or Parameter
  wa_sccr
-name 'S_ACODE'."Field name
  wa_sccr
-sg_main 'I'.
  wa_sccr
-sg_addy space.
  wa_sccr
-op_main 'OBJECTKEY'.
  
APPEND wa_sccr TO wa_restrict-ass_tab.
  
CLEAR wa_sccr.

**********************************************************************
*Disable selection in the field
**********************************************************************
  
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    
EXPORTING
      
program                      sy-repid
      restriction                  
wa_restrict
*   DB                           = ' '
   
EXCEPTIONS
     too_late                     
1
     repeated                     
2
     selopt_without_options       
3
     selopt_without_signs         
4
     invalid_sign                 
5
     empty_option_list            
6
     invalid_kind                 
7
     repeated_kind_a              
8
     
OTHERS                       9
            .
  
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  
ENDIF.

AT SELECTION-SCREEN OUTPUT.

**********************************************************************
*Loop at screen to change the screen dynamically
**********************************************************************
  
LOOP AT SCREEN.
    
IF p_rad1 'X' AND screen-group1 'M_S'.“Modify ID
      
screen-active 0.

    
ENDIF.
    
MODIFY SCREEN.
  
ENDLOOP.

START-OF-SELECTION.

END-OF-SELECTION.


 



Protected by Copyscape Web Copyright Checker

No comments:

Post a Comment

/*Newer Post*/ Older Post Home