Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create select-options in a custom screen?

Former Member
0 Kudos

Hello,

I would like to have something similar to the code below in a screen that I designed.

SELECTION-SCREEN BEGIN OF BLOCK b1
                  WITH FRAME TITLE TEXT-001.
         SELECT-OPTIONS aux0 FOR aux2.
         SELECT-OPTIONS aux1 FOR aux2.
SELECTION-SCREEN END OF BLOCK b1.

For example, I need to create a screen with parameters that support intervals, so when I click in the arrow button the SAP dialog box appears.

However, I can only add a 'input field' using the screen painter.

Thank you in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rafael,

Method 1
a) Create a sub-screen area in your screen layout where you want to create the select options.
b) In the top include of your module pool program declare a selection screen as a sub-screen
e.g.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
select-options s_matnr for mara-matnr.
SELECTION-SCREEN END OF SCREEN.
c) In the PBO and PAI of the main screen where the select options needs to be created do a
call subscreen of the above screen (100).
CALL SUBCREEN sub_area INCLUDING
This call subscreen statement is necessary for transport of values between screen and
program.
Note: All validations of the selection screen fields e.g. the s_matnr field created above should
be done in selection screen events like AT SELECTION-SCREEN etc and not in PAI. These
selection screen validations etc should be done in the top include only.

  

  

Method 2

  

a) Create 2 separate fields in your screen layout - one for the low value and one for the high

value. Insert an icon beside the high value which will call the multiple selections popup screen

on user command. Use function module COMPLEX_SELECTIONS_DIALOG to achieve this.

struc_tab_and_field-fieldname = con_cust. " 'KUNNR'

   struc_tab_and_field-tablename = con_kna1. " 'KNA1'.

  

CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'

EXPORTING

text = g_titl1 " 'Customers'

tab_and_field = struc_tab_and_field

TABLES

RANGE = rng_kunnr

EXCEPTIONS

NO_RANGE_TAB = 1

CANCELLED = 2

INTERNAL_ERROR = 3

INVALID_FIELDNAME = 4

OTHERS = 5.

IF NOT rng_kunnr[] IS INITIAL.

* Read the very first entry of the range table and pass it to

* dynpro screen field

READ TABLE rng_kunnr INDEX 1.

IF sy-subrc = 0.

g_cust = rng_kunnr-low.

ENDIF.

   

  

You can use the return table rng_kunnr to populate your own internal range table with the

values entered by the user. Basically here you are just simulating the work of a select-options

parameter by module pool screen elements.

Regards,

DN.

5 REPLIES 5

Former Member
0 Kudos

Former Member
0 Kudos

Hi Rafael,

Method 1
a) Create a sub-screen area in your screen layout where you want to create the select options.
b) In the top include of your module pool program declare a selection screen as a sub-screen
e.g.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
select-options s_matnr for mara-matnr.
SELECTION-SCREEN END OF SCREEN.
c) In the PBO and PAI of the main screen where the select options needs to be created do a
call subscreen of the above screen (100).
CALL SUBCREEN sub_area INCLUDING
This call subscreen statement is necessary for transport of values between screen and
program.
Note: All validations of the selection screen fields e.g. the s_matnr field created above should
be done in selection screen events like AT SELECTION-SCREEN etc and not in PAI. These
selection screen validations etc should be done in the top include only.

  

  

Method 2

  

a) Create 2 separate fields in your screen layout - one for the low value and one for the high

value. Insert an icon beside the high value which will call the multiple selections popup screen

on user command. Use function module COMPLEX_SELECTIONS_DIALOG to achieve this.

struc_tab_and_field-fieldname = con_cust. " 'KUNNR'

   struc_tab_and_field-tablename = con_kna1. " 'KNA1'.

  

CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'

EXPORTING

text = g_titl1 " 'Customers'

tab_and_field = struc_tab_and_field

TABLES

RANGE = rng_kunnr

EXCEPTIONS

NO_RANGE_TAB = 1

CANCELLED = 2

INTERNAL_ERROR = 3

INVALID_FIELDNAME = 4

OTHERS = 5.

IF NOT rng_kunnr[] IS INITIAL.

* Read the very first entry of the range table and pass it to

* dynpro screen field

READ TABLE rng_kunnr INDEX 1.

IF sy-subrc = 0.

g_cust = rng_kunnr-low.

ENDIF.

   

  

You can use the return table rng_kunnr to populate your own internal range table with the

values entered by the user. Basically here you are just simulating the work of a select-options

parameter by module pool screen elements.

Regards,

DN.

Former Member
0 Kudos

Thanks a lot, guys!
It worked

bastinvinoth
Contributor
0 Kudos

raymond_giuseppi
Active Contributor

Just for reference : read Selection Screens as Subscreens in help.sap.com Abap documentation.

Regards,

Raymond