‎2007 May 17 3:11 PM
Hi Experts,
Is it possible to create a Drop Down feature to SELECT-OPTIONS in selection screen?
If so, How?
or I must go for Ranges!
Thanq.
‎2007 May 17 3:14 PM
Hi Sridhar,
Look at the below Example
report zrich_0001.
tables: mara.
type-pools: vrm.
ranges: r_matnr for mara-matnr.
selection-screen begin of line.
selection-screen comment (10) ff_text.
parameters: p_fld1 type mara-matnr as listbox visible length 20.
selection-screen position 50.
selection-screen comment (10) tf_text.
parameters: p_fld2 type mara-matnr as listbox visible length 20.
selection-screen end of line.
initialization.
ff_text = 'From Field'.
tf_text = 'To Field'.
perform build_user_drop_down_list.
start-of-selection.
r_matnr-sign = 'I'.
r_matnr-option = 'BT'.
r_matnr-low = p_fld1.
r_matnr-high = p_fld2.
append r_matnr.
* Now you can use the R_MATNR in a select statement.
************************************************************************
* build user_drop_down_list
************************************************************************
form build_user_drop_down_list.
data: name type vrm_id,
list type vrm_values,
value like line of list.
clear list. refresh list.
clear value.
value-key = 'MATA'.
value-text = 'Material A'.
append value to list.
clear value.
value-key = 'MATB'.
value-text = 'Material B'.
append value to list.
clear value.
value-key = 'MATC'.
value-text = 'Material C'.
append value to list.
clear value.
value-key = 'MATD'.
value-text = 'Material D'.
append value to list.
clear value.
value-key = 'MATE'.
value-text = 'Material E'.
append value to list.
* Set the values for P_FLD1
name = 'P_FLD1'.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
* Set values for P_FLD2
name = 'P_FLD2'.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
endform.Regards
Sudheer
‎2007 May 17 3:14 PM
‎2007 May 17 3:14 PM
Hi Sridhar,
Look at the below Example
report zrich_0001.
tables: mara.
type-pools: vrm.
ranges: r_matnr for mara-matnr.
selection-screen begin of line.
selection-screen comment (10) ff_text.
parameters: p_fld1 type mara-matnr as listbox visible length 20.
selection-screen position 50.
selection-screen comment (10) tf_text.
parameters: p_fld2 type mara-matnr as listbox visible length 20.
selection-screen end of line.
initialization.
ff_text = 'From Field'.
tf_text = 'To Field'.
perform build_user_drop_down_list.
start-of-selection.
r_matnr-sign = 'I'.
r_matnr-option = 'BT'.
r_matnr-low = p_fld1.
r_matnr-high = p_fld2.
append r_matnr.
* Now you can use the R_MATNR in a select statement.
************************************************************************
* build user_drop_down_list
************************************************************************
form build_user_drop_down_list.
data: name type vrm_id,
list type vrm_values,
value like line of list.
clear list. refresh list.
clear value.
value-key = 'MATA'.
value-text = 'Material A'.
append value to list.
clear value.
value-key = 'MATB'.
value-text = 'Material B'.
append value to list.
clear value.
value-key = 'MATC'.
value-text = 'Material C'.
append value to list.
clear value.
value-key = 'MATD'.
value-text = 'Material D'.
append value to list.
clear value.
value-key = 'MATE'.
value-text = 'Material E'.
append value to list.
* Set the values for P_FLD1
name = 'P_FLD1'.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
* Set values for P_FLD2
name = 'P_FLD2'.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
endform.Regards
Sudheer
‎2007 May 17 3:16 PM
In your selection screen statements use something like this..
PARAMETERS: zrunmode(1) AS LISTBOX VISIBLE LENGTH 25 DEFAULT 'R'.
In this case I'm determining a runmode for a BDC (three choices, 1 char long)
Then below add the following event.. Assigning the drop down list items w/text descriptions
AT SELECTION-SCREEN OUTPUT.
name = 'ZRUNMODE'.
value-key = 'R'.
value-text = '(R) Run Direct Update'.
APPEND value TO list.
value-key = 'S'.
value-text = '(S) Show Records and Confirm Update'.
APPEND value TO list.
value-key = 'T'.
value-text = '(T) Run in Test Mode (No Update)'.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
‎2007 May 17 3:17 PM
See the below code :
report yo_maint_zv_024 .
Table diclaration
tables: tvdir.
Add values to list box
at selection-screen output.
type-pools: vrm.
data: name type vrm_id,
list type vrm_values,
value like line of list.
name = 'P_TABNM'.
refresh list.
value-key = 'V_024'.
value-text = text-002. "'V_024-Purchasing Groups'.
append value to list.
value-key = 'V_T024D'.
value-text = text-003. "'V_T024D-MRP Controllers'.
append value to list.
value-key = 'ZT604'.
value-text = text-004. "'T604-Commodity Codes'.
append value to list.
value-key = 'T179'.
value-text = text-005. "'T179-Product Hierarchies'.
append value to list.
value-key = 'TVM1T'.
value-text = text-006. "'TVM1T-Business Manager'.
append value to list.
value-key = 'TVM2T'.
value-text = text-007. "'TVM2T-Division manager'.
append value to list.
value-key = 'TVM3T'.
value-text = text-008. "'TVM3T-Director'.
append value to list.
value-key = 'V_TVV2'.
value-text = text-009. "'V_TVV2-Customer Group 2'.
append value to list.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
start-of-selection.
Selection screento table View
selection-screen skip 2.
parameter p_tabnm(30) as listbox visible length 30 obligatory.
selection-screen skip 1.
selection-screen begin of block s1 with frame title text-001.
parameter: p_radio1 radiobutton group g1,
p_radio radiobutton group g1.
selection-screen end of block s1.
Get flag of corresponding table view
select single tabname flag from tvdir into tvdir
where tabname = p_tabnm.
Set flag of corresponding table view
if p_radio1 eq 'X'.
if tvdir-flag ne 'X'.
update tvdir set: flag = 'X'
where tabname = p_tabnm.
endif.
endif.
if p_radio eq 'X'.
if tvdir-flag eq 'X'.
update tvdir set: flag = ''
where tabname = p_tabnm.
endif.
endif.
Execute View/Table
call function 'VIEW_MAINTENANCE_CALL'
exporting
action = 'U'
view_name = p_tabnm
exceptions
client_reference = 1
foreign_lock = 2
invalid_action = 3
no_clientindependent_auth = 4
no_database_function = 5
no_editor_function = 6
no_show_auth = 7
no_tvdir_entry = 8
no_upd_auth = 9
only_show_allowed = 10
system_failure = 11
unknown_field_in_dba_sellist = 12
view_not_found = 13
others = 14.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Reset flag of corresponding table view
update tvdir set: flag = tvdir-flag
where tabname = p_tabnm.
Reward points if it is helpful
Thanks
Seshu
‎2007 May 17 3:18 PM
Hi,
I dont think this is possible in case of select options, as select options already displays a list of valid values when you go for F4 Help.
Now even still you want to have this functionality then you will have to create two parameters on the same line, provide drop down for each and in the program get there values and populate a range and then use this range for further processing.
Please check this sample code.
TYPE-POOLS : VRM.
TABLES : T134.
DATA : IT_1 TYPE VRM_VALUES ,
V_INDEX TYPE I ,
WA LIKE LINE OF IT_1.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 10(25) TEXT-003 "TEXT-003 is material Type
FOR FIELD S_MTART.
parameter: S_MTART like T134-MTART AS LISTBOX VISIBLE
LENGTH 6 OBLIGATORY.
SELECTION-SCREEN COMMENT 45(5) TEXT-004 " TEXT-004 IS TO
FOR FIELD S_MTART1.
*"You can adjust the coordinates 45(5) , it is basically xpos and lenght
parameter: S_MTART1 like T134-MTART AS LISTBOX VISIBLE
LENGTH 6 OBLIGATORY.
selection-screen end of line.
INITIALIZATION.
CLEAR V_INDEX.
* "Populate the drop down
SELECT MTART INTO T134-MTART FROM T134.
WA-KEY = T134-MTART.
APPEND WA TO IT_1.
ENDSELECT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'S_MTART'
VALUES = IT_1
* EXCEPTIONS
* ID_ILLEGAL_NAME = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'S_MTART1'
VALUES = IT_1
* EXCEPTIONS
* ID_ILLEGAL_NAME = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*" Youcan also add validation to check if the lower value is greater than higher
*" same as that in select-options , but this is optionsl
start-of-selection.
* "Declare the range
ranges : r_mtart for mara-mtart .
*" Populate the range.
r_mtart-sign = 'I'. " Include option of select options
r_mtart-option = 'BT'. " Same to select option , indiating get values
*between
r_mtart-low = S_MTART.
r_mtart-high = s_mtart1.
append r_mtart.
* Get data from MARA.
Data : it_2 type table of mara ,
wa_2 like line of it_2.
*"use the range to get the data from table
select * into table it_2
from mara
where mtart in r_mtart.
loop at it_2 into wa_2.
write :/ wa_2-matnr ,wa_2-mtart.
endloop.
Regards,
Ferry Lianto
‎2007 May 17 3:19 PM
If you are looking for LIST box use the example by Sudheer. If you are looking for F4 Help on the selection screen please use this function module,
PARAMETERS: variant LIKE disvariant-variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR variant.
PERFORM f4_display_variant USING variant 'U'.
FORM f4_display_variant USING varname LIKE disvariant-variant
save TYPE c.
disvariant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = disvariant
i_save = save
IMPORTING
es_variant = disvariant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
varname = disvariant-variant.
ELSE.
MESSAGE s245(56).
Keine Anzeigevariante(n) vorhanden
ENDIF.
ENDFORM. " F4_DISPLAY_VARIANT
Thanks,
Shreekant
‎2007 May 17 3:21 PM
Hi,
You can use addition as LISTBOX in parameters.
parameters : p_mat type matnr as listbox visible length 4.
In select-options its not possible to display dropdown box.
Regards,
Naveen
‎2007 May 17 3:31 PM
Hi,
I dont think this is possible in case of select options , as select options already displays a list of valid values when you go for F4 Help.
Now even still you want to have this functionality then you will ahve to create two parameters on the same line , provide drop down for each and in the program get there values and populate a range and then use this range for further processing.
Regards,
Bhaskar
‎2007 May 17 3:31 PM
Hi,
Go through the code snippet,
https://wiki.sdn.sap.com/wiki/display/Snippets/Drop-downListBoxintheSelectionScreenforWindowsNT%2CR3Release4.7
Regards,
Azaz Ali.