Application Development 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: 

how to get the values in dropdown listbox

Former Member
0 Kudos

I am trying to implement a program in which i want some static values or some values at design time

8 REPLIES 8

Former Member
0 Kudos

Hi ,

Can you give more details about your problem??

Former Member
0 Kudos

Are you want drop down in ALV. Can you provide more info.

0 Kudos

You requirement is a little unclear, if you are looking to have a listbox with some values, here is how to do it.

In this example, the program gets some user names from the database and then puts them in the listbox.



report zrich_0005 .

type-pools: vrm.

parameters: p_bname type usr01-bname as listbox visible length 20.

at selection-screen output.

  perform build_user_drop_down_list.

start-of-selection.

  write:/ p_bname.

************************************************************************
* 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.

  data: iusr01 type usr01 occurs 0 with header line.

  clear list. refresh list.
  name = 'P_BNAME'.

  select * into corresponding fields of table iusr01
             from usr01.

  sort iusr01 ascending by bname.

  loop at iusr01.
    clear value.
    value-key = iusr01-bname.
    value-text = iusr01-bname.
    append value to list.
  endloop.

* Set the values
  call function 'VRM_SET_VALUES'
       exporting
            id     = name
            values = list.

endform.

Regards,

Rich Heilman

0 Kudos

By the way, Welcome to SDN!

Regards,

Rich HEilman

Former Member
0 Kudos

Making assumptions about your requirements ... but assuming your "listbox" is associated w/ a domain (dictionary object), you create a set of fixed values in the definition (assuming the domain is a "Z" domain).

Otherwise, define the "listbox" w/ reference (i.e., using like or type) to a standard data element that has a value list, range, or table associated w/ the domain.

Former Member
0 Kudos

Hi,

Check the sample program: DEMO_DYNPRO_DROPDOWN_LISTBOX,

RSDEMO_DROPDOWN_LISTBOX

http://help.sap.com/saphelp_46c/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm

A lot of examples are there in this link:

Also try out this sample code:

report test.
type-pools: vrm.
data: it_val type vrm_values,
      w_line like line of it_val.
parameters p_bukrs like t001-bukrs as listbox
           visible length 25 obligatory.
 
initialization.
  select bukrs butxt from t001 into (w_line-key, w_line-text).
    append w_line to it_val.
    check p_bukrs is initial.
    p_bukrs = w_line-key.
  endselect.
 
at selection-screen output.
  call function 'VRM_SET_VALUES'
       exporting
            id     = 'P_BUKRS'
            values = it_val.
 
end-of-selection.
  write: / 'Company Code:', p_bukrs.

Best Regards,

Anjali

0 Kudos

This code will contain the 12months. Pass the month names in the text-001...text-012.

Value text will be

TYPE-POOLS: vrm.
DATA: ws_n_days      LIKE t009b-butag," Calender Period
      ws_c_mon_list1 TYPE vrm_id,
      ws_c_list      TYPE vrm_values,
      value          LIKE LINE OF ws_c_list.

PARAMETERS: p_list LIKE t009b-bumon AS LISTBOX
                     VISIBLE LENGTH 11 OBLIGATORY

  REFRESH: ws_c_list.

AT SELECTION-SCREEN OUTPUT.
  ws_c_mon_list1 = 'P_LIST'.
  value-key = text-001.
  value-text = text-013.

  APPEND value TO ws_c_list.

  value-key = text-002.
  value-text = text-014.

  APPEND value TO ws_c_list.

  value-key = text-003.
  value-text = text-015.

  APPEND value TO ws_c_list.

  value-key = text-004.
  value-text = text-016.

  APPEND value TO ws_c_list.

  value-key = text-005.
  value-text = text-017.


  APPEND value TO ws_c_list.

  value-key = text-006.
  value-text = text-018.

  APPEND value TO ws_c_list.

  value-key = text-007.
  value-text = text-019.

  APPEND value TO ws_c_list.

  value-key = text-008.
  value-text = text-020.
  APPEND value TO ws_c_list.

  value-key = text-009.
  value-text = text-021.
  APPEND value TO ws_c_list.

  value-key = text-010.
  value-text = text-022.
  APPEND value TO ws_c_list.

  value-key = text-011.
  value-text = text-023.

  APPEND value TO ws_c_list.

  value-key = text-012.
  value-text = text-024.

  APPEND value TO ws_c_list.

  CLEAR value-key.


CALL FUNCTION <b>'VRM_SET_VALUES'</b>
       EXPORTING
            id     = ws_c_mon_list1
            values = ws_c_list.

Hope this helps. Reward points if this helps u.

Former Member
0 Kudos

Hi Amrendra Kumar

If you are try Drop Down List box In Dialog Programming.

Go to SE51.

Program: DEMO_DROPDOWN_LIST_BOX

Screen : 0100

This program contains the code you are looking for..

Cheers,

Vijay Raheja