6 Columns with Active Background
6 Columns with Active Background
Active List Item Background

24DDIC1108 – SELECT-OPTIONS and Its Screen Components

SELECT-OPTIONS allow users to specify ranges or individual values for a selection field. These options are stored in an internal table with several important components that help define the selection criteria:

  1. SIGN: Indicates whether the selection is an inclusion ( I for “Include”) or exclusion ( E for “Exclude”).
  2. OPTION: Specifies the type of selection, such as EQ (Equal),  BT  (Between),  GT  (Greater Than), etc.
  3. LOW: The lower limit of the range or the actual value.
  4. HIGH: The upper limit of the range (relevant for range options like BT ).

Example: Using  SELECT-OPTIONS  with Components

Let’s create a report that demonstrates how to access and use these components of  SELECT-OPTIONS  with an internal table. We will filter flight data from the  SFLIGHT  table based on a range of dates provided by the user.

REPORT zexample_select_options_components.

  • Define selection screen with SELECT-OPTIONS

SELECT-OPTIONS: so_fldate FOR sflight-fldate.

  • Internal table to hold data from the database

DATA: lt_flights TYPE TABLE OF sflight.

  • Internal table to process selection criteria

DATA: lt_select_options TYPE TABLE OF sflight-fldate.

  • Start of the report logic

START-OF-SELECTION.

  • Clear internal table before fetching data

  CLEAR lt_flights.

  • Access and process the SELECT-OPTIONS components

LOOP AT so_fldate INTO DATA(ls_option).

    WRITE: / ‘Sign:’, ls_option-sign,

           ‘Option:’, ls_option-option,

           ‘Low:’, ls_option-low,

           ‘High:’, ls_option-high.

  ENDLOOP.

  • Fetch data based on the user’s input range

SELECT * FROM sflight

    INTO TABLE lt_flights

    WHERE fldate IN so_fldate.

  • Check if data was retrieved

IF lines( lt_flights ) > 0.

  • Display the retrieved data

LOOP AT lt_flights INTO DATA(ls_flight).

      WRITE: / ‘Carrier ID:’, ls_flight-carrid,

             ‘Connection ID:’, ls_flight-connid,

             ‘Flight Date:’, ls_flight-fldate,

             ‘Price:’, ls_flight-price.

    ENDLOOP.

  ELSE.

 

  • No data found

WRITE: / ‘No flights found for the selected date range.’.

  ENDIF.

 

Explanation of Components

  1. SELECT-OPTIONS Declaration:

 SELECT-OPTIONS: so_fldate FOR sflight-fldate.

– This line declares  so_fldate  as a selection option for the  fldate  field from the  SFLIGHT  table.

  1. Internal Table for Data:

DATA: lt_flights TYPE TABLE OF sflight.

 –  lt_flights  is an internal table used to store the flight records fetched from the database.

  1. Internal Table for Selection Criteria:

 DATA: lt_select_options TYPE TABLE OF sflight-fldate

   –  lt_select_options  is defined to hold selection criteria. However, it’s not used directly in this example but demonstrates how you might process selection criteria.

  1. Accessing SELECT-OPTIONS Components:

   LOOP AT so_fldate INTO DATA(ls_option).

     WRITE: / ‘Sign:’, ls_option-sign,

            ‘Option:’, ls_option-option,

            ‘Low:’, ls_option-low,

            ‘High:’, ls_option-high.

   ENDLOOP.

 

   – This loop iterates over the  so_fldate  internal table (which is implicitly created by  SELECT-OPTIONS ) and writes out each component:

     –  SIGN  indicates whether the criterion is an inclusion ( I ) or exclusion ( E ).

     –  OPTION  shows the type of comparison (e.g.,  BT  for between,  EQ  for equal).

     –  LOW  and  HIGH  define the range for the selection criterion.

  1. Fetching and Displaying Data:

SELECT * FROM sflight

     INTO TABLE lt_flights

     WHERE fldate IN so_fldate.

 

– This  SELECT  statement retrieves records from the  SFLIGHT  table based on the range of dates specified by  so_fldate .

  1. Processing Results:

   IF lines( lt_flights ) > 0.

  • Display the retrieved data

LOOP AT lt_flights INTO DATA(ls_flight).

       WRITE: / ‘Carrier ID:’, ls_flight-carrid,

              ‘Connection ID:’, ls_flight-connid,

              ‘Flight Date:’, ls_flight-fldate,

              ‘Price:’, ls_flight-price.

     ENDLOOP.

   ELSE.

  • No data found

     WRITE: / ‘No flights found for the selected date range.’.

   ENDIF.

   – If data is found, it is displayed. If no records are found, a message is displayed indicating that no data matches the criteria.

This example shows how  SELECT-OPTION  works with its components and how to use them effectively in ABAP to filter and display data from a database table.

Author : Aniket Pawar, 9373518385             

24DDIC1108 – SELECT-OPTIONS and Its Screen Components

SELECT-OPTIONS allow users to specify ranges or individual values for a selection field. These options are stored in an internal table with several important components that help define the selection criteria:

  1. SIGN: Indicates whether the selection is an inclusion ( I for “Include”) or exclusion ( E for “Exclude”).
  2. OPTION: Specifies the type of selection, such as EQ (Equal),  BT  (Between),  GT  (Greater Than), etc.
  3. LOW: The lower limit of the range or the actual value.
  4. HIGH: The upper limit of the range (relevant for range options like BT ).

Example: Using  SELECT-OPTIONS  with Components

Let’s create a report that demonstrates how to access and use these components of  SELECT-OPTIONS  with an internal table. We will filter flight data from the  SFLIGHT  table based on a range of dates provided by the user.

REPORT zexample_select_options_components.

  • Define selection screen with SELECT-OPTIONS

SELECT-OPTIONS: so_fldate FOR sflight-fldate.

  • Internal table to hold data from the database

DATA: lt_flights TYPE TABLE OF sflight.

  • Internal table to process selection criteria

DATA: lt_select_options TYPE TABLE OF sflight-fldate.

  • Start of the report logic

START-OF-SELECTION.

  • Clear internal table before fetching data

  CLEAR lt_flights.

  • Access and process the SELECT-OPTIONS components

LOOP AT so_fldate INTO DATA(ls_option).

    WRITE: / ‘Sign:’, ls_option-sign,

           ‘Option:’, ls_option-option,

           ‘Low:’, ls_option-low,

           ‘High:’, ls_option-high.

  ENDLOOP.

  • Fetch data based on the user’s input range

SELECT * FROM sflight

    INTO TABLE lt_flights

    WHERE fldate IN so_fldate.

  • Check if data was retrieved

IF lines( lt_flights ) > 0.

  • Display the retrieved data

LOOP AT lt_flights INTO DATA(ls_flight).

      WRITE: / ‘Carrier ID:’, ls_flight-carrid,

             ‘Connection ID:’, ls_flight-connid,

             ‘Flight Date:’, ls_flight-fldate,

             ‘Price:’, ls_flight-price.

    ENDLOOP.

  ELSE.

 

  • No data found

WRITE: / ‘No flights found for the selected date range.’.

  ENDIF.

 

Explanation of Components

  1. SELECT-OPTIONS Declaration:

 SELECT-OPTIONS: so_fldate FOR sflight-fldate.

– This line declares  so_fldate  as a selection option for the  fldate  field from the  SFLIGHT  table.

  1. Internal Table for Data:

DATA: lt_flights TYPE TABLE OF sflight.

 –  lt_flights  is an internal table used to store the flight records fetched from the database.

  1. Internal Table for Selection Criteria:

 DATA: lt_select_options TYPE TABLE OF sflight-fldate

   –  lt_select_options  is defined to hold selection criteria. However, it’s not used directly in this example but demonstrates how you might process selection criteria.

  1. Accessing SELECT-OPTIONS Components:

   LOOP AT so_fldate INTO DATA(ls_option).

     WRITE: / ‘Sign:’, ls_option-sign,

            ‘Option:’, ls_option-option,

            ‘Low:’, ls_option-low,

            ‘High:’, ls_option-high.

   ENDLOOP.

 

   – This loop iterates over the  so_fldate  internal table (which is implicitly created by  SELECT-OPTIONS ) and writes out each component:

     –  SIGN  indicates whether the criterion is an inclusion ( I ) or exclusion ( E ).

     –  OPTION  shows the type of comparison (e.g.,  BT  for between,  EQ  for equal).

     –  LOW  and  HIGH  define the range for the selection criterion.

  1. Fetching and Displaying Data:

SELECT * FROM sflight

     INTO TABLE lt_flights

     WHERE fldate IN so_fldate.

 

– This  SELECT  statement retrieves records from the  SFLIGHT  table based on the range of dates specified by  so_fldate .

  1. Processing Results:

   IF lines( lt_flights ) > 0.

  • Display the retrieved data

LOOP AT lt_flights INTO DATA(ls_flight).

       WRITE: / ‘Carrier ID:’, ls_flight-carrid,

              ‘Connection ID:’, ls_flight-connid,

              ‘Flight Date:’, ls_flight-fldate,

              ‘Price:’, ls_flight-price.

     ENDLOOP.

   ELSE.

  • No data found

     WRITE: / ‘No flights found for the selected date range.’.

   ENDIF.

   – If data is found, it is displayed. If no records are found, a message is displayed indicating that no data matches the criteria.

This example shows how  SELECT-OPTION  works with its components and how to use them effectively in ABAP to filter and display data from a database table.

Author : Aniket Pawar, 9373518385