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 insert values in list box

Former Member
0 Kudos

Hi all,

I want to know how to insert values in a list box in dialog programining statically.

thanks

bye

8 REPLIES 8

Former Member
0 Kudos

Hi,

Please check:

Cheers,

Bhanu

Former Member
0 Kudos

Define your input field as List box/List box with key from attributes.

krzysztof_konitz4
Contributor
0 Kudos

Hi,

Set "Dropdown" atribute of input/output field to "List box".

Use PROCESS ON VALUE-REQUEST event in screen logic to fill list with values. For example let's assume that we have field XXX on screen:

PROCESS ON VALUE-REQUEST.
  FIELD XXX MODULE FILL_XXX_VALUES.


MODULE FILL_XXX_VALUES INPUT.
  FIELD XXX MODULE FILL_XXX_VALUES.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      RETFIELD               = 'XXX'
      VALUE_ORG              = 'S'
    TABLES
      VALUE_TAB              = XXX_TAB
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 2
      OTHERS                 = 3.
ENDMODULE.

where XXX_TAB is internal table which contains value list for your list box.

Krzys

Former Member
0 Kudos

see below code

loop at itab.

value-key = itab-id.

value-text = itab-name.

append value to list.

clear value.

endloop.

call function 'VRM_SET_VALUES'

exporting

id = p_id

values = list.

Cheers,

Satya

Former Member
0 Kudos

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

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.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

<b>Sample code1</b>:

In this,whatever values you are passing in it_val will be the list box values.

report z.

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 = <b>it_val</b>.

end-of-selection.

write: / 'Company Code:', p_bukrs.

<b>Sample Code2:</b>

PROGRAM zcmtest01.

TYPE-POOLS: vrm.

DATA: name TYPE vrm_id,

list TYPE vrm_values,

value LIKE LINE OF list.

PARAMETERS: ps_parm(10) AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN OUTPUT.

name = 'PS_PARM'.

value-key = '1'.

value-text = 'Line 1'.

APPEND value TO list.

value-key = '2'.

value-text = 'Line 2'.

APPEND value TO list.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING id = name

values = list.

START-OF-SELECTION.

WRITE: / 'Parameter:', ps_parm.

Kindly reward points by clicking the star on the left of reply,if it helps.

Former Member
0 Kudos

Hi Aashish,

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

Former Member
0 Kudos

Hi Aashish Garg

Go to SE51.

Program: DEMO_DROPDOWN_LIST_BOX

Screen : 0100

This program contains the code you are looking for..

Cheers,

Vijay Raheja