01-14-2009 11:54 AM
Hello,
i have generated a dropdown list using the VRM_SET_VALUES FM, but i can"t set the default value to this list.
here is a sample of my code :
SELECT pos value
FROM zfee_scr_param
INTO TABLE list
WHERE fieldname = 'CDL'.
SORT list BY key.
name = 'ADRSTREET-ZZ_CONTR_LOC'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
Thank you,
Tom.
01-14-2009 12:42 PM
Hi Tom,
on initialization event, just give the key value (be sure to give the key value) to the listbox parameter.
example:
***
TYPE-POOLS : vrm.
DATA: combo_id TYPE vrm_id,
items TYPE vrm_values WITH HEADER LINE,
item TYPE LINE OF vrm_values.
***
selection-secreen begin of block b1.
PARAMETERS: pp1(20) AS LISTBOX VISIBLE LENGTH 30.
selection-screen end of block b1.
***
for your example
loop at list.
item-key = list-pos.
item-text = list-value.
APPEND item TO items. CLEAR item.
endloop.
*
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'PP1'
values = items[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
***
on initialization.
pp1 = <your default value>.
it gets the initial value..
regards,
Murat Kaya
01-14-2009 12:23 PM
Hi,
Please refer this link http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/frameset.htm
Cheers,
Pravin S
01-14-2009 1:05 PM
Thanks pravin,
is there no way to have a default value while working with VRM_SET_VALUES ?
if i am not wrong, the parameters that most of you are telling me to use, is only for selectionscreens but i am dinamicaly filling a dropdown inside a report dynpro
01-14-2009 12:26 PM
PARAMETERS p_carrid TYPE spfli-carrid
AS LISTBOX VISIBLE LENGTH 20
USER-COMMAND onli
*DEFAULT 'LH' *.
regards,
Jinson
01-14-2009 12:30 PM
hI,
try liek this
for example.
PARAMETER: pr_spart TYPE spart AS LISTBOX VISIBLE LENGTH 7 default 'HL'.
'HL' is one of the value that is there in the list box.
Regards,
Nagaraj
01-14-2009 12:42 PM
Hi Tom,
on initialization event, just give the key value (be sure to give the key value) to the listbox parameter.
example:
***
TYPE-POOLS : vrm.
DATA: combo_id TYPE vrm_id,
items TYPE vrm_values WITH HEADER LINE,
item TYPE LINE OF vrm_values.
***
selection-secreen begin of block b1.
PARAMETERS: pp1(20) AS LISTBOX VISIBLE LENGTH 30.
selection-screen end of block b1.
***
for your example
loop at list.
item-key = list-pos.
item-text = list-value.
APPEND item TO items. CLEAR item.
endloop.
*
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'PP1'
values = items[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
***
on initialization.
pp1 = <your default value>.
it gets the initial value..
regards,
Murat Kaya
01-14-2009 1:27 PM
Thanks,
i thought this was the answer to my question, but as i don't have a dropdown declared as a parameter but created via screen painter, i can't do it this way.
SELECT pos value
FROM zfee_scr_param
INTO TABLE list
WHERE fieldname = 'CDL'.
SORT list BY key.
name = 'ADRSTREET-ZZ_CONTR_LOC'. -> name of the dropdown as defined in screen painter
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
Could there be a way to assign the key value to this dropdown ? could not find the syntax...
01-14-2009 2:26 PM
hi Tom,
as i understand your combo field is not on selection-screen but you can do the same on screen element as well. just create a PBO module and fill your internal table and listbox there.
example:
IN PBO MODULE
CLEAR : items,items[], item.
combo_id = 'GT_MAIN-REASON'.
item-key = '1'.
item-text = 'TOURISTIC'.
APPEND item TO items. CLEAR item.
item-key = '2'.
item-text = 'BUSINESS'.
APPEND item TO items. CLEAR item.
item-key = '3'.
item-text = 'EDUCATION'.
APPEND item TO items. CLEAR item.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = combo_id
values = items[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
READ TABLE items WITH KEY key = gt_main-reason.
gt_main-reason_tx = items-text.
this fills your listbox on the screen (change the names accordingly)
IF gt_main-reason IS INITIAL.
gt_main-reason = '1'.
ENDIF.
this part looks if the field is empty and gives the initial value 'TOURISTIC' (key value is 1 for TOURISTIC)
no need to take points back
regards,
Murat Kaya
Edited by: Murat Kaya on Jan 14, 2009 3:37 PM
02-25-2009 2:06 PM
Hi Murat!
First of all: Thanks 4 your answers which made me find this topic
Unfortunately your coding does not set the value to 'TOURISTIC' (key value is 1 for TOURISTIC), but to 1.
Any help of how i could select a certain list entry instead of setting the value 1?
Cheers & Thx in advance
Jan
03-08-2009 2:51 PM
Hi Jan,
i just saw your reply by chance, i wasn't watching this thread.
this is a working code, it sets the selection to "Touristic" when set to "1". is it possible that you may have given key values with different data type or value so it can not realize matching value? this case you have written happens when you give a value that is not in the combo box. can you double check?
regards,
Murat Kaya
08-23-2010 10:28 AM
Hi,
thx for your fast answer. i checked it in the debugger and made a screen:
http://www5.pic-upload.de/23.08.10/8132e7iepx1l.jpg
I also tried to change it to add '1' to... in the filling form for the listbox. it does not work. seems that abap does not match my G_0300-ddlifnr = 1. (or = '1') to my first entry. Dont know why
g_dd_lb_value_key TYPE i. --> so imho it has to work without the ''....
Maybe i have to try another key for my table, but i need one which i can increase in a loop, cause of not knowing how many values i'll have in my listbox.
kind regards!