Tuesday 11 March 2014

Enable only the Select Single and Select Exclude in Select-Option

Sometime we have requirement to display the select single or select single with the exclude single excluding the other tab in select-option.


Like below:
Select Single and Exclude Single –



OR Only the Select Single –




Use the below code to enable the select single and exclude single in select-option.

REPORT  z_test_select_option.
* Include type pool SSCR
TYPE-POOLS: slis, sscr.
TABLES : sscrfields.

 
DATA: lk_selopt   TYPE sscr_ass,
       lk_opt_list
TYPE sscr_opt_list,
       li_restrict
TYPE sscr_restrict,
       v_kunnr     
TYPE kunnr,
       v_matnr     
TYPE matnr.
* defining the selection-screen
SELECT-OPTIONS : s_kunnr FOR v_kunnr NO INTERVALS,
                s_matnr
FOR v_matnr NO INTERVALS.
INITIALIZATION.
************** SELECT SINGLE and EXCLUDE SINGLE *****************
 
CLEAR lk_opt_list.
 lk_opt_list
-name          = 'EQ'.
 lk_opt_list
-options-eq    = 'X'.
 
APPEND lk_opt_list TO li_restrict-opt_list_tab.

 
CLEAR lk_selopt.
 lk_selopt
-kind            = 'S'.
 lk_selopt
-name            = 'S_KUNNR'.
 lk_selopt
-sg_main         = '*'.
 lk_selopt
-op_main         = 'EQ'.
 lk_selopt
-op_addy         = 'EQ'.
 
APPEND lk_selopt  TO li_restrict-ass_tab.
*****************************************************************
************** SELECT SINGLE *****************
 
CLEAR lk_opt_list.
 lk_opt_list
-name          = 'EQ'.
 lk_opt_list
-options-eq    = 'X'.
 
APPEND lk_opt_list TO li_restrict-opt_list_tab.

 
CLEAR lk_selopt.
 lk_selopt
-kind            = 'S'.
 lk_selopt
-name            = 'S_MATNR'.
 lk_selopt
-sg_main         = 'I'.
 lk_selopt
-op_main         = 'EQ'.
 lk_selopt
-op_addy         = 'EQ'.
 
APPEND lk_selopt  TO li_restrict-ass_tab.
**********************************************

   
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
   
EXPORTING
     restriction            
= li_restrict
   
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.

No comments:

Post a Comment