Google Search - Blog...........

ABAP - Selection Screen To Restrict Options.

REPORT ZRESTRICT_SELOPT.

* Include type pool SSCR
TYPE-POOLS sscr.

TABLES: EKPO.

* Selection-screen
select-options : so_ebeln for ekpo-ebeln,
so_ebelp for ekpo-ebelp.

* Variables for populating restriction data
DATA: gd_restrict TYPE sscr_restrict. "structure containing 2 tables
DATA: gd_optlist TYPE sscr_opt_list, "header line for table 1
gd_ass TYPE sscr_ass. "header line for table 2

*INITIALIZATION.
INITIALIZATION.

* Restrict SO_EBELN to only except EQ, BT and NE.
gd_optlist-name = 'KEY1'. "Can be anything
gd_optlist-options-eq = 'X'.
gd_optlist-options-bt = 'X'.
gd_optlist-options-ne = 'X'.
APPEND gd_optlist TO gd_restrict-opt_list_tab.
clear: gd_optlist.

gd_ass-kind = 'S'.
gd_ass-name = 'SO_EBELN'.
gd_ass-sg_main = 'I'.
gd_ass-sg_addy = SPACE.
gd_ass-op_main = 'KEY1'. "Must be same as above
APPEND gd_ass TO gd_restrict-ass_tab.
clear: gd_ass.

* Restrict SO_EBELP to only except CP, GE, LT.
gd_optlist-name = 'KEY2'. "Can be anything
gd_optlist-options-cp = 'X'.
gd_optlist-options-ge = 'X'.
gd_optlist-options-lt = 'X'.
APPEND gd_optlist TO gd_restrict-opt_list_tab.
clear: gd_optlist.

gd_ass-kind = 'S'.
gd_ass-name = 'SO_EBELP'.
gd_ass-sg_main = 'I'.
gd_ass-sg_addy = SPACE.
gd_ass-op_main = 'KEY2'. "Must be same as above
APPEND gd_ass TO gd_restrict-ass_tab.
clear: gd_ass.


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


ALSO READ:

- Select Input Only Through F4 (Value On Request).

- Selection Screen With Radio Buttons.

- Selection Screen With Push Buttons.

- Selection Screen Events.

- Selection Screen With Push Buttons With Events.

No comments:

Post a Comment