11-08-2011 7:42 AM
This is a small piece of code, which I thought of sharing to all the people so that it might be useful if they are not aware of.
I was given a situation to design a selection screen with a selection option acting as a parameter, but where it should be allowed to enter only Single values and exclude all the Ranges and Exclude Single Values.
When I searched on SDN but I not able find much information on this, so trying to share a idea of how I achieved it.
Code to Be applied.
TYPE-POOLS: sscr. "For Selection build
Data:t_restrict TYPE sscr_restrict, " for selection restrict
t_optlist TYPE sscr_opt_list,
t_sscr TYPE sscr_ass,
CONSTANTS c_x TYPE c VALUE 'X'.
INITIALIZATION.
PERFORM selection_restrict.
FORM selection_restrict .
t_optlist-name = 'OBJECTKEY1'. u201CAny random Name
t_optlist-options-eq = c_x. u201COther available Options Given Below as a note.
APPEND t_optlist TO t_restrict-opt_list_tab.
t_sscr-kind = 'S'. " A(ll), Apply restrictions to all the select-options in a selection screen.
u201CS(elect-Option) , Apply restrictions to specified select options.
t_sscr-name = 'S_PERNR'. " Blockname, maximal 20 (Select-Options Name)
t_sscr-sg_main = 'I'. " (only) I / SPACE = both(I-Include/E-Exclude) values would be taken.
t_sscr-sg_addy = space.
t_sscr-op_main = 'OBJECTKEY1'. "Any Random Name of option list for main selection screen same as above.
APPEND t_sscr TO t_restrict-ass_tab.
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
EXPORTING
program = sy-repid
restriction = t_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.
"Error message
ENDIF.
ENDFORM. " SELECTION_RESTRICT
Note:
***comments***
( Since I need only t_optlist-options-eq option active I have made use of this option, you can also make use other below option according to the need.)
Eg: instead of eq u can use below one of them.
u201CBT SELECT-OPTIONS: Range active
u201CCP SELECT-OPTIONS: Pattern active
u201CEQ SELECT-OPTIONS: Single value active
u201CGE SELECT-OPTIONS: Greater than or equal active
u201CGT SELECT-OPTIONS: Greater than active
u201CLE SELECT-OPTIONS: Less than or equal active
u201CLT SELECT-OPTIONS: Less than active
u201CNB SELECT-OPTIONS: Exclude range active
u201CNE SELECT-OPTIONS: Exclude single value active
u201CNP SELECT-OPTIONS: Exclude pattern active
***End of comments***.
***********************************************************************
Kindly ignore this ,if you are already aware.
Moderator Message: Please see Keshav's response.
Edited by: Suhas Saha on Nov 8, 2011 1:19 PM
11-08-2011 7:43 AM
Hi,
Welcome to SCN.
Please share your contributions in SCN - WIKI.
Kesav