Selection list for selection screen field ABAP

The task is to add only the necessary elements to the selection list for the field from the selection screen. For example, do not display several specific elements or vice versa delete all leaving only a few. The task is solved simply.

We describe the field of the selection screen. The description is made using a string because it is often necessary to display selection screen parameters that are longer than 30 characters, so you have to declare a string and place the name and element in it taking into account the indent:

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(15) text-s01 FOR FIELD so_ct.
SELECT-OPTIONS: so_ct FOR gs_subssc-typecase.
SELECTION-SCREEN END OF LINE.	

We describe the type of internal table into which we will write the elements available for selection and the table itself:

TYPES:
  	BEGIN OF ts_typecase,
    	casetype TYPE ze_sd_typecase,
    	text TYPE  text50,
  	END OF    ts_typecase.
DATA lt_typecase TYPE STANDARD TABLE OF  ts_typecase.

After that, fill out the table only with the values we need. For example, we select the object code and its name from the database, excluding those that are not needed:

AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_ct-low.

SELECT typecase text
    INTO TABLE lt_typecase
    FROM zs_sd_typecase
    WHERE typecase NOT IN ('02', '05').	

Be careful not to exclude entries by code, as shown in this example, in all cases. Since different systems can have different codes for the same elements. After that, we transfer this table to the FM filling in the same field name:

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield  = 'TYPECASE'
      value_org = 'S'
    TABLES
      value_tab = lt_typecase
   EXCEPTIONS
     PARAMETER_ERROR  = 1
     NO_VALUES_FOUND  = 2
     OTHERS           = 3 .	

The problem is solved. In our selection list of the selection screen, only those elements that we need will be displayed.
Final code:

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(15) text-s01 FOR FIELD so_ct.
SELECT-OPTIONS: so_ct FOR gs_subssc-typecase.
SELECTION-SCREEN END OF LINE. 

TYPES:
  BEGIN OF ts_typecase,
    casetype TYPE zs_sd_typecase,
    text TYPE  text50,
  END OF    ts_typecase.
DATA lt_typecase TYPE STANDARD TABLE OF ts_typecase.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_ct-low.

  SELECT typecase text
    INTO TABLE lt_typecase
    FROM zs_sd_typecase
    WHERE typecase NOT IN ('02', '05').

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield  = 'TYPECASE'
      value_org = 'S'
    TABLES
      value_tab = lt_typecase
   EXCEPTIONS
     PARAMETER_ERROR = 1
     NO_VALUES_FOUND = 2
     OTHERS          = 3 .