06-12-2011 8:20 AM
Hi,
I am trying to use a listbox in a subscreen.
I saw all the demo programs :
RSDEMO_DROPDOWN_LISTBOX
DEMO_DROPDOWN_LIST_BOX
DEMO_DYNPRO_DROPDOWN_LISTBOX all of them refer to a field of type carrid, i want to put vsalues 1....10 in the listbox which don't refer any table.
and also used vrm_set_values in PBO of screen.
The problem is when I use vrm_set_values to set values for dropdown,the values are set and are shown in the dropdown.
But when i select from listbox nothing comes up in the scren field value.
I have assigned a function code to the listbox and made the value help of type 'A'.
but when select any value from listbox the screen field gets cleared, nothing comes up in pai.
I have also tried creating a database table and a field for providing reference to list box.
i want to trigger pai on selection of value from listbox and run the rest of logic based on the value selected.
Please give some advice on this ,if anyone of you has developed a similar program.
I have checked many threads with topic of listbox in sdn, but they were not helpful.
Thanks & Regards,
Kamini
06-12-2011 10:48 AM
There you go
TYPE-POOLS vrm.
"screen field for listbox of key field C1
DATA: listbox.
"value table
DATA: name TYPE vrm_id,
value_tab TYPE vrm_values WITH HEADER LINE.
CALL SCREEN 0900.
MODULE init_listbox OUTPUT.
REFRESH value_tab.
value_tab-key = '1'.
value_tab-text = 'TRUE'.
APPEND value_tab.
value_tab-key = '0'.
value_tab-text = 'FALSE'.
APPEND value_tab.
name = 'LISTBOX'. "name of control
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = value_tab[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF listbox IS INITIAL.
READ TABLE value_tab INDEX 1.
listbox = value_tab-key.
ENDIF.
ENDMODULE. "init_listbox INPUT
MODULE user_command_0900 INPUT.
IF sy-ucomm = 'FC_LIST'.
MESSAGE listbox TYPE 'I'.
ENDIF.
ENDMODULE.
Regards
Marcin
06-12-2011 10:48 AM
There you go
TYPE-POOLS vrm.
"screen field for listbox of key field C1
DATA: listbox.
"value table
DATA: name TYPE vrm_id,
value_tab TYPE vrm_values WITH HEADER LINE.
CALL SCREEN 0900.
MODULE init_listbox OUTPUT.
REFRESH value_tab.
value_tab-key = '1'.
value_tab-text = 'TRUE'.
APPEND value_tab.
value_tab-key = '0'.
value_tab-text = 'FALSE'.
APPEND value_tab.
name = 'LISTBOX'. "name of control
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = value_tab[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF listbox IS INITIAL.
READ TABLE value_tab INDEX 1.
listbox = value_tab-key.
ENDIF.
ENDMODULE. "init_listbox INPUT
MODULE user_command_0900 INPUT.
IF sy-ucomm = 'FC_LIST'.
MESSAGE listbox TYPE 'I'.
ENDIF.
ENDMODULE.
Regards
Marcin
06-12-2011 11:06 AM
Hi Marcin,
Thank you very much.
This works.
But I just wanted to know one thing.
Do we have to give a default value, to the listbox ?
I have tried the same many times , the only difference i find here is you are giving a default value to the listbox in PBO.
Regards,
Kamini
06-13-2011 4:53 AM
Found the bug.
I was trying to give value 1..8 directly without quotes to the table to be passed to vrm_set_values.
When i enclosed them in quotes like '1','2' then the aqpplication works fine..
Regards,
Kamini
02-21-2012 6:23 AM
hi kamini,
you can also give direct values to the key filed, but u need to use condense stmt before appending it.
i also faced the same problem and i got it corrected by doing this.
regards,
somesh