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

add value to dropdownlist

Former Member
0 Likes
547

Hi all,

I have a student table. I wan to add all the student name to the dropdownlist.

i created the dropdownlist using screen printer not selection list.

Advise on how to do? Code are most prefered.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
516

Hi Gary

You need to use the FUNCTION 'VRM_SET_VALUES'

try it.

***TOP

TYPE-POOLS: vrm.

TABLES: <table>.

DATA: ivrm_values TYPE vrm_values,

xvrm_values LIKE LINE OF ivrm_values,

name TYPE vrm_id,

  • name of the drop down ( at screen painter )

<DropDown>(80),

<ti_table> type standard table of <table> with header line.

***PROCESS BEFORE OUTPUT.

      • MODULE vrm_0100.

MODULE vrm_0100 OUTPUT.

select * from <table> into table <ti_table> order by <student name>.

clear ivrm_values.

  • name of the drop down ( at screen painter )

name = '<DropDown>'.

loop at <ti_table>.

xvrm_values-key = <student name>.

xvrm_values-text = <student name>.

APPEND xvrm_values TO ivrm_values.

endloop.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

values = ivrm_values.

ENDMODULE. " vrm_0100 OUTPUT

Regards

Allan Cristian

2 REPLIES 2
Read only

Former Member
0 Likes
516

HI

Try with this sample report:

 
TYPE-POOLS vrm.
 
DATA: name  TYPE vrm_id,
      list  TYPE vrm_values,
      value LIKE LINE OF list.
 
DATA: wa_spfli TYPE spfli,
      ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.
 
TABLES demof4help.
 
name = 'DEMOF4HELP-CONNID'.
 
CALL SCREEN 100.
 
MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.
 
MODULE init_listbox OUTPUT.
 
  CLEAR demof4help-connid.
 
  SELECT  connid cityfrom cityto deptime
    FROM  spfli
    INTO  CORRESPONDING FIELDS OF wa_spfli
   WHERE  carrid = demof4help-carrier2.
 
    value-key  = wa_spfli-connid.
 
    WRITE wa_spfli-deptime TO value-text USING EDIT MASK '__:__:__'.
 
    CONCATENATE value-text
                wa_spfli-cityfrom
                wa_spfli-cityto
                INTO value-text SEPARATED BY space.
    APPEND value TO list.
 
  ENDSELECT.
 
  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            id     = name
            values = list.
 
ENDMODULE.
 
MODULE user_command_100.
  save_ok = ok_code.
  CLEAR ok_code.
  IF save_ok = 'CARRIER' AND NOT demof4help-carrier2 IS INITIAL.
    LEAVE TO SCREEN 200.
  ELSE.
    SET SCREEN 100.
  ENDIF.
ENDMODULE.
 
MODULE user_command_200.
  save_ok = ok_code.
  CLEAR ok_code.
  IF save_ok = 'SELECTED'.
    MESSAGE i888(sabapdocu) WITH text-001 demof4help-carrier2
                                        demof4help-connid.
  ENDIF.
ENDMODULE.

Take the Screen in the screen painter T.Code SE51 or screen layoyut in SE80 and double click the screen field & Select DropDown -> Listbox in the Screen attributes window.

Try this one too

type-pools: vrm.

data: p_field(20) type c.
data: ivrm_values type vrm_values.
data: xvrm_values like line of ivrm_values.
data: name type vrm_id.

start-of-selection.

* Set default value, before calling the screen
p_field = 'DEF'.

call screen 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.

name = 'P_FIELD'.

xvrm_values-key = 'ABC'.
xvrm_values-text = 'ABC'.
append xvrm_values to ivrm_values.

xvrm_values-key = 'DEF'.
xvrm_values-text = 'DEF'.
append xvrm_values to ivrm_values.

xvrm_values-key = 'GHI'.
xvrm_values-text = 'GHI'.
append xvrm_values to ivrm_values.

call function 'VRM_SET_VALUES'
exporting
id = name
values = ivrm_values.

endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.

endmodule. " USER_COMMAND_0100 INPUT

For DropDownIndx :

Define a node (named 'TEXT') with cardinality '0..n' with attribute ('TEXT').

Create a UI element DropDownIndx

Bind the text property of DropDownbyIndex UI element to attribute Text of context node Text.

In the WDDOINIT method you can prepare an internal table with the values and bind it to the node and the lead selection defines the selected element.

The below code sample may help.

method WDDOINIT .

data:

node_text type ref to if_wd_context_node,

stru_text type if_componentcontroller=>element_text,

tab_text type if_componentcontroller=>elements_text .

node_text = wd_context->get_child_node( name = if_componentcontroller=>wdctx_text ).

  • Set/fill your values

stru_text-text = 'Value1'.

append stru_text to tab_text.

stru_text-text = 'Value2'.

append stru_text to tab_text.

  • set values to the node

call method node_ddi_also_text->bind_table

exporting

new_items = tab_text.

endmethod.

2nd code

data: l_node type ref to if_wd_context_node,

l_node_info type ref to if_wd_context_node_info,

l_value_set type wdr_context_attr_value_list,

wa_value_set like line of l_value_set.

l_node = wd_context->get_child_node( 'MSG_TYPE' ).

l_node_info = l_node->get_node_info( ).

*-- loop --

wa_value_set-text = 'Test1'.

wa_value_set-value = 'KEY1'.

insert wa_value_set into table l_value_set.

  • -- endloop --

l_node_info->set_attribute_value_set(

name = 'MY_ATTRIBUTE'

value_set = l_value_set ).

drop down in report

TYPE-POOLS : vrm.

tables: bkpf.

DATA : values TYPE vrm_values.

DATA : wa LIKE LINE OF values.

PARAMETERS : list_box(10) TYPE c AS LISTBOX VISIBLE LENGTH 10.

PARAMETERS: dd type bkpf-BSTAT user-command abc.

select-options: a for bkpf-bukrs MODIF ID buk.

select-options: b for bkpf-belnr MODIF ID SEL.

at selection-screen output.

If list_box = 2.

loop at screen.

if screen-group1 = 'SEL'.

screen-input = 0.

modify screen.

endif.

endloop.

endif.

INITIALIZATION.

wa-key = '1'.

wa-text = 'Orange'.

APPEND wa TO values.

wa-key = '2'.

wa-text = 'Red'.

APPEND wa TO values.

wa-key = '3'.

wa-text = 'Blue'.

APPEND wa TO values.

wa-key = '4'.

wa-text = 'Gray'.

APPEND wa TO values.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'LIST_BOX'

values = values

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

Ref Program: DEMO_DROPDOWN_LIST_BOX

You can also refer :

http://help.sap.com/saphelp_nw2004s/helpdata/en/5f/b6b441b60e3331e10000000a155106/frameset.htm

?

http://www.sapdesignguild.org/resources/MiniSG/2_Layout/2_Dropdown_Listbox.htm

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

check this link it will solve ur problem

as i said earlier u can get easier through screen painter

http://www.sapdesignguild.org/community/design/combo.asp

<b><REMOVED BY MODERATOR></b>

Regards

Pavan

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
517

Hi Gary

You need to use the FUNCTION 'VRM_SET_VALUES'

try it.

***TOP

TYPE-POOLS: vrm.

TABLES: <table>.

DATA: ivrm_values TYPE vrm_values,

xvrm_values LIKE LINE OF ivrm_values,

name TYPE vrm_id,

  • name of the drop down ( at screen painter )

<DropDown>(80),

<ti_table> type standard table of <table> with header line.

***PROCESS BEFORE OUTPUT.

      • MODULE vrm_0100.

MODULE vrm_0100 OUTPUT.

select * from <table> into table <ti_table> order by <student name>.

clear ivrm_values.

  • name of the drop down ( at screen painter )

name = '<DropDown>'.

loop at <ti_table>.

xvrm_values-key = <student name>.

xvrm_values-text = <student name>.

APPEND xvrm_values TO ivrm_values.

endloop.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

values = ivrm_values.

ENDMODULE. " vrm_0100 OUTPUT

Regards

Allan Cristian