The selection screen in SAP is the primary interface for users to interact with the reports or transactions designed by developers. Often, it is the first component that developers create in the entire application. In fact, this screen serves as the first impression you can give to your business or end users.
In this article, we have outlined some common requirements in real-world projects and how we can achieve them. One important feature to consider is the Selection Screen in SAP, which plays a critical role in customizing user inputs for various programs. You can treat this article as a reference document for future use.
1. Multiple Elements in a Selection Screen Line
Now and then we have explicit prerequisites while planning a choice screen. We might need to put more than one Boundary (or Select Choice or Radio Button). This can be effectively finished by utilizing the determination screen Start OF LINE/END OF LINE proclamations.The following code extract will help you in designing such a selection screen.
DATA: l_field TYPE char10, l_pos TYPE char4. SELECTION-SCREEN BEGIN OF BLOCK out WITH FRAME TITLE text-s01. * Line 1 SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 5(15) nam1 FOR FIELD p_field1. PARAMETERS: p_field1 LIKE l_field. SELECTION-SCREEN COMMENT 45(15) nam2 FOR FIELD p_pos11. PARAMETERS: p_pos11 LIKE l_pos. SELECTION-SCREEN COMMENT 75(15) nam3 FOR FIELD p_pos12. PARAMETERS: p_pos12 LIKE l_pos. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK out. AT SELECTION-SCREEN OUTPUT. nam1 = 'Parameter'. nam2 = 'Start Position'. nam3 = 'End Position'.
Let’s check how the output looks.
Kindly note: Rather than using just parameters, you can easily include various elements like radio buttons or select options on the Selection Screen in SAP. The key point here is to maintain the correct spacing and positioning; otherwise, you may encounter a selection screen generation error during code activation, even if your code is syntactically correct.
2. Restricting Range entry for Select-Option
At some point it is expected to limit range input for a select choice. SAP gives an expansion which is for the most part utilized for this is NO INTERVALS. In any case, is it sufficient?
SELECT-Choices: mat FOR mara-matnr NO Stretches.
Evidently it appear to be that prerequisite is met yet assuming somebody presses Select Reaches tab, client can enter the reach.
********************************************************************** * TYPE-POOLS: ********************************************************************** TYPE-POOLS: sscr. *----------------------------------------------------------------------* * T A B L E S * *----------------------------------------------------------------------* TABLES: mara. *----------------------------------------------------------------------* * S E L E C T I O N S C R E E N * *----------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME. SELECT-OPTIONS: mat FOR mara-matnr NO INTERVALS. SELECT-OPTIONS: mtype FOR mara-mtart NO INTERVALS. SELECTION-SCREEN: END OF BLOCK b2.
With simply NO INTERVALS order. In the wake of squeezing Select Reaches tab you can enter range esteem.
How to really restrict the range? We need to use FM ‘SELECT_OPTIONS_RESTRICT’ as shown below.
INITIALIZATION. CONSTANTS: lc_opt_list TYPE rsrest_opl VALUE 'OPT_LIST', lc_s TYPE rsscr_kind VALUE 'S', lc_mat TYPE blockname VALUE 'MAT', lc_inc TYPE c VALUE 'I'. DATA: lw_opt_list TYPE sscr_opt_list, lw_restrict TYPE sscr_restrict, lw_ass TYPE sscr_ass. lw_opt_list-name = lc_opt_list. lw_opt_list-options-bt = space. lw_opt_list-options-eq = 'X'. APPEND lw_opt_list TO lw_restrict-opt_list_tab. lw_ass-kind = lc_s. lw_ass-name = lc_mat. lw_ass-sg_main = lc_inc. lw_ass-op_main = lc_opt_list. APPEND lw_ass TO lw_restrict-ass_tab. CALL FUNCTION 'SELECT_OPTIONS_RESTRICT' EXPORTING restriction = lw_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.
Notwithstanding NO Spans, in the wake of limiting with the capability module, you can’t enter range esteem now. This would be a vigorous arrangement.
There are other choice accessible in this capability module. Investigate and appreciate
3. Select-Choices in a module pool screen
Technique 1
a) Make a subscreen region in your screen design where you need to make the select choices.
b) In the top incorporate of your module pool program proclaim a choice screen as a subscreen for example
Determination SCREEN Start OF SCREEN 100 AS SUBSCREEN.
select-choices s_matnr for mara-matnr.
Determination SCREEN END OF SCREEN.
c) In the PBO and PAI of the principal screen where the select choices should be made do a call subscreen of the above screen (100).
CALL SUBCREEN sub_area INCLUDING
This call subscreen explanation is essential for transport of values among screen and program.
Note: All approvals of the determination screen fields for example the s_matnr field made above ought to be finished in choice screen occasions like AT Determination SCREEN and so on and not in PAI. These choice screen approvals and so on ought to be finished in the top incorporate as it were.
Strategy 2
a) Make 2 separate fields in your screen design – one for the low worth and one for the high worth. Embed a symbol alongside the high worth which will call the different determinations popup screen on client order. Use capability module ‘COMPLEX_SELECTIONS_DIALOG’ to accomplish this.
struc_tab_and_field-fieldname = con_cust. ” ‘KUNNR’ struc_tab_and_field-tablename = con_kna1. ” ‘KNA1’. CALL FUNCTION ‘COMPLEX_SELECTIONS_DIALOG’ EXPORTING * TITLE = ‘ ‘ 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 utilize the return table rng_kunnr to populate your own inside range table with the qualities entered by the client. Fundamentally, here you are simply recreating crafted by a select-choices boundary by module pool screen components.
4. Displaying the Selection Screen value in report automatically
Esteem entered in the choice screen can be shown consequently by the capability modules ‘RS_REFRESH_FROM_SELECTOPTIONS‘ and ‘RS_LIST_SELECTION_TABLE‘ is decent even style. Extremely supportive when the determination screen is immense having a ton of boundaries and select choices.
* T A B L E S * *----------------------------------------------------------------------* TABLES: mara. *----------------------------------------------------------------------* * S E L E C T I O N S C R E E N * *----------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME. SELECT-OPTIONS: mat FOR mara-matnr NO INTERVALS. SELECT-OPTIONS: mtype FOR mara-mtart NO INTERVALS. SELECTION-SCREEN: END OF BLOCK b2. END-OF-SELECTION. WRITE:/ 'Thank you for visiting'. TOP-OF-PAGE. DATA: i_sel TYPE STANDARD TABLE OF rsparams INITIAL SIZE 0. IF sy-pagno EQ 1. * Call function for getting selection screen details CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS' EXPORTING curr_report = sy-cprog TABLES selection_table = i_sel EXCEPTIONS not_found = 1 no_report = 2 OTHERS = 3. IF sy-subrc <> 0. WRITE:/ 'Fails to get the selection screen details'(201). ENDIF. * Displaying selection screen details CALL FUNCTION 'RS_LIST_SELECTION_TABLE' EXPORTING report = sy-cprog seltext = 'X' screennr = ' ' TABLES sel_tab = i_sel EXCEPTIONS sel_tab_empty = 1 OTHERS = 2. IF sy-subrc <> 0. WRITE:/ 'Fails to display the selection screen details'(202). ENDIF. ENDIF.
Really look at the picture underneath. Every one of the upsides of choice screen input are imprinted in the report.
5. Dynamic Selection Screen
Determination screen is the primary thing which client can see when he/she executes a program or exchange. For essential need, we can make a choice screen exclusively by utilizing ABAP orders and we don’t need to go for a module pool programming.
There are a few expansions which can be utilized with select choice to meet the prerequisite.
If it’s not too much trouble, really look at F1 for the augmentations and their belongings.
At some point it is expected to populate a default esteem in the choice screen. There is an ABAP order which can be utilized for this.
Eg. SELECT-Choices: matn FOR mara-matnr DEFAULT ‘AA’.
Some of the time the default esteem should be determined at run-time. Use Introduction Occasion or AT Choice SCREEN Result Occasion.
Dynamic Choice Screen: You can initiate a field or can impair contribution to a specific field contingent upon certain rules at your will. The accompanying code might assist you with making a powerful screen. There are a few other choice in SCREEN structure. Investigate and you can intrigue some client by delivering a conspicuous choice screen. Recall determination screen is the initial feeling of your program.
TABLES: mara. *----------------------------------------------------------------------* * S E L E C T I O N S C R E E N * *---------------------------------------------------------------------- SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME. PARAMETERS : mat RADIOBUTTON GROUP opt1 DEFAULT 'X' USER-COMMAND aa. PARAMETERS : mtype RADIOBUTTON GROUP opt1. SELECTION-SCREEN: END OF BLOCK b1. SELECTION-SCREEN: BEGIN OF BLOCK b2. SELECT-OPTIONS: matn FOR mara-matnr DEFAULT 'AA' MODIF ID a. SELECT-OPTIONS: mtypen FOR mara-mtart MODIF ID b. SELECTION-SCREEN: END OF BLOCK b2. *----------------------------------------------------------------------* * AT S E L E C T I O N S C R E E N O U T P U T * *---------------------------------------------------------------------- AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF mat = 'X'. IF screen-group1 = 'B'. screen-input = 0. ENDIF. ELSE. IF screen-group1 = 'A'. screen-active = 0. ENDIF. ENDIF. MODIFY SCREEN. ENDLOOP.
6. Search Help from the values in Internal table
Some of the time the prerequisite is to such an extent that search help is expected from the qualities got at run time or from steady qualities. In such cases, you can utilize the FM ‘F4IF_INT_TABLE_VALUE_REQUEST’ to meet your motivation. The fundamental rationale is that it utilizes information from the inward table to show in the F4 search help.
Model: Here an interior table is populated for certain constants. This program is only for idea.
* Type for internal table for populating the file-type TYPES: BEGIN OF x_filtyp, filetype TYPE char3, " File type description TYPE char50, " description END OF x_filtyp. *********************************************************************** * DATA * *********************************************************************** DATA: * File type i_filtyp TYPE STANDARD TABLE OF x_filtyp INITIAL SIZE 0, wa_filtyp TYPE x_filtyp. PARAMETERS: p_file(3) TYPE c. *********************************************************************** * INITIALIZATION * *********************************************************************** INITIALIZATION. *Populating file type in an internal table PERFORM sub_filtyp. *********************************************************************** * AT SELECTION-SCREEN * *********************************************************************** AT SELECTION-SCREEN. * On value request for p_filtyp AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file . PERFORM sub_get_help_filtyp USING p_file. *&---------------------------------------------------------------------* *& Form sub_filtyp *&---------------------------------------------------------------------* FORM sub_filtyp. * local variables DATA: l_wa_filtyp TYPE x_filtyp. "work area * Appending row l_wa_filtyp-filetype = 'A'. l_wa_filtyp-description = 'Alphabet A'. APPEND l_wa_filtyp TO i_filtyp. * Appendng row l_wa_filtyp-filetype = 'B'. l_wa_filtyp-description = 'Alphabet B'. APPEND l_wa_filtyp TO i_filtyp. ENDFORM. "sub_filtyp *&---------------------------------------------------------------------* *& Form sub_get_help_filtyp *&---------------------------------------------------------------------* FORM sub_get_help_filtyp USING l_filtyp . * local vairables DATA: l_dynfld TYPE dynfnam, "Screen Field Name l_retfld TYPE fieldname, "Return Field Name l_i_fields TYPE STANDARD TABLE OF dfies, "for call function l_i_return TYPE TABLE OF ddshretval, "for call function l_wa_field TYPE dfies, "work area l_wa_return TYPE ddshretval, "work l_wa_value TYPE seahlpres, l_i_value TYPE STANDARD TABLE OF seahlpres, l_i_mapping TYPE STANDARD TABLE OF dselc, l_wa_mapping TYPE dselc. l_wa_mapping-fldname = 'DESCRIPTION'. APPEND l_wa_mapping TO l_i_mapping. l_wa_field-fieldname = 'FILETYPE'. l_wa_field-tabname = 'I_FILTYP'. l_wa_field-intlen = 6. l_wa_field-leng = 6. l_wa_field-outputlen = 6. l_wa_field-position = 1 . l_wa_field-scrtext_s = l_wa_field-fieldname. l_wa_field-scrtext_m = l_wa_field-fieldname. l_wa_field-scrtext_l = l_wa_field-fieldname. l_wa_field-reptext = l_wa_field-fieldname. APPEND l_wa_field TO l_i_fields. CLEAR l_wa_field . l_wa_field-fieldname = 'DESCRIPTION'. l_wa_field-tabname = 'I_FILTYP'. * l_wa_field-OFFSET = 3. l_wa_field-intlen = 50. l_wa_field-leng = 50. l_wa_field-outputlen = 50. l_wa_field-position = 2 . l_wa_field-scrtext_s = l_wa_field-fieldname. l_wa_field-scrtext_m = l_wa_field-fieldname. l_wa_field-scrtext_l = l_wa_field-fieldname. l_wa_field-reptext = l_wa_field-fieldname. APPEND l_wa_field TO l_i_fields. LOOP AT i_filtyp INTO wa_filtyp. l_wa_value-string = wa_filtyp-filetype. APPEND l_wa_value TO l_i_value. l_wa_value-string = wa_filtyp-description. APPEND l_wa_value TO l_i_value. ENDLOOP. l_retfld = 'FILETYPE'. l_dynfld = l_filtyp. * call fucntion for search help CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = l_retfld dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = l_dynfld window_title = 'Filetype' * value_org = 'S' callback_program = sy-repid TABLES value_tab = l_i_value field_tab = l_i_fields return_tab = l_i_return * dynpfld_mapping = l_i_mapping EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc EQ 0. READ TABLE l_i_return INTO l_wa_return WITH KEY fieldname = 'FILETYPE'. IF sy-subrc EQ 0. l_filtyp = l_wa_return-fieldval. ENDIF. ENDIF. ENDFORM. " sub_get_help_filtyp
Check the Pursuit Help is from our custom interior table. Isn’t it helpful in genuine activities?
Thank you very much for your time! I hope this post has helped you better understand the Selection Screen in SAP and its functionality.
YOU MAY BE INTERESTED IN
IDoc to EDI Mapping: Bridging the Gap
Software Development Life Cycle (SDLC) Phases & Models