Application Development and Automation 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: 
Read only

finding selected value in listbox

Former Member
0 Likes
1,354

Hi all,

Im using ''VRM_SET_VALUES'' FM to populate values for listbox in the 'At selection-screen output' event.

I want to know how to find the value which the user selects in the list box.

Pls tell me how to achieve the same.

4 REPLIES 4
Read only

Former Member
0 Likes
1,132

Hi,


 CALL FUNCTION 'VRM_SET_VALUES'
  EXPORTING
    id              = 's_list' 

The value is what is in variable "s_list" at the moment.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,132

>

> Im using ''VRM_SET_VALUES'' FM to populate values for listbox in the 'At selection-screen output' event.

You should be using it in the AT SELECTION-SCREEN ON VALUE REQUEST event.

Read only

Former Member
0 Likes
1,132

Hi,

VRM_GET_VALUES will return you the values that is set by the user. The selected value will be in an internal table and you need to read the 1st Index. Have a look at the code below.


data: delimiter type c value '/'.
TYPE-POOLS VRM.
data: VRM_ID TYPE VRM_VALUE-TEXT,
VRM_VALUES TYPE VRM_VALUEs with header line.

vrm_id = 'PO_INFO'.

CALL FUNCTION 'VRM_GET_VALUES'
EXPORTING
ID = vrm_id
IMPORTING
VALUES = vrm_values[]
EXCEPTIONS
ID_NOT_FOUND = 1
OTHERS = 2.

read table vrm_values index 1.

po_info = vrm_values-key. 

The above code will return you all the values for a particular Screen element. You can use the below code snippet to retrieve the value selected by the User.



  DATA: lc_dyname    LIKE sy-repid.
  DATA: lc_dynumb    LIKE sy-dynnr.
  DATA: ltab_fields  LIKE dynpread OCCURS 0 WITH HEADER LINE.
    ltab_fields-fieldname = 'TB_01'.
  APPEND ltab_fields.

CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     = lc_dyname
      dynumb     = lc_dynumb
    TABLES
      dynpfields = ltab_fields
    EXCEPTIONS
      OTHERS     = 01.

The above code snippet will retrieve the particular row information in your PAI event for processing.

Hope this code snippet will help you.

Thanks,

Samantak.

Edited by: Samantak Chatterjee on Apr 28, 2010 10:02 PM

Read only

Former Member
0 Likes
1,132

Hi shanthi,

PARAMETERS:po_list TYPE name1 AS LISTBOX VISIBLE LENGTH 20

DEFAULT 'OPTION1' OBLIGATORY.

AT SELECTION-SCREEN OUTPUT.

TYPE-POOLS: vrm .

DATA:

l_name TYPE vrm_id,

li_list TYPE vrm_values,

lwa_list LIKE LINE OF li_list.

l_name = 'PO_LIST'.

CLEAR lwa_list.

REFRESH li_list.

lwa_list-text = lwa_list-key = 'OPTION1'.

APPEND lwa_list TO li_list.

CLEAR lwa_list.

lwa_list-text = lwa_list-key = 'OPTION2'.

APPEND lwa_list TO li_list.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = l_name

values = li_list.

Output will have OPTION1 and OPTION2 in the listbox.

If OPTION1 is selected in the selection screen then po_list will have value as 'OPTION1'

If OPTION2 is selected in the selection screen then po_list will have value as 'OPTION2'

Hope this will help.