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 add drop down list in screen

Former Member
0 Kudos

Hi, I have created custom database table and I have created sample data. Now I have to place the table field as a drop down in the screen and when I click on database field in the screen, available data has to be seen in the drop down.

beside drop down I have placed one text field and based on item selected from drop down, text has to be populated in the text field.

Can anyone please advice on this. Thanks in advance,....

Edited by: B K on Mar 23, 2009 10:37 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

U can use following code to fill the list box

write this code in PBO

In layout editor please select listbox in dropdown attribute of input field and put some fctcode attribute

TYPE-POOLS vrm.
  DATA values TYPE vrm_values WITH HEADER LINE.


  TABLES: <ur custom Database table>.
  
  clear values, values[].
  SELECT * FROM <ur custom Database table>.
    values-text = <TABLE FIELD TO DISPLAY IN DROPDOWN> .
    values-key = <TABLE KEY FIELD TO DISPLAY IN DROPDOWN>.
    APPEND values.
  ENDSELECT.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = '<SCREEN INPUT FIELD NAME>'
      values          = values[]
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.

Also please define the following before accessing the listbox value

data: <listbox input field name> type <table field name>,

<inputfield name where text to display> type string in top include

In PAI, select the text from the table into <inputfield name where text to display> depending on value selected which will be called when enter key is pressed or any vale is selected

4 REPLIES 4

Former Member
0 Kudos

Hi,

U can use following code to fill the list box

write this code in PBO

In layout editor please select listbox in dropdown attribute of input field and put some fctcode attribute

TYPE-POOLS vrm.
  DATA values TYPE vrm_values WITH HEADER LINE.


  TABLES: <ur custom Database table>.
  
  clear values, values[].
  SELECT * FROM <ur custom Database table>.
    values-text = <TABLE FIELD TO DISPLAY IN DROPDOWN> .
    values-key = <TABLE KEY FIELD TO DISPLAY IN DROPDOWN>.
    APPEND values.
  ENDSELECT.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = '<SCREEN INPUT FIELD NAME>'
      values          = values[]
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.

Also please define the following before accessing the listbox value

data: <listbox input field name> type <table field name>,

<inputfield name where text to display> type string in top include

In PAI, select the text from the table into <inputfield name where text to display> depending on value selected which will be called when enter key is pressed or any vale is selected

Former Member
0 Kudos

Hi,

Check this DEMO for

Report program RSDEMO_DROPDOWN_LISTBOX

Dailog Program DEMO_DYNPRO_DROPDOWN_LISTBOX

Former Member
0 Kudos

Hi B.K,

Create a seperate module for POV.

PROCESS ON VALUE-REQUEST.

FIELD "FIELD NAME" MODULE fill_values.

Inside the module write a select query to fetch the values of the field in an internal table and pass it to the FM :

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'Field Name'

dynpprog = sy-cprog

dynpnr = sy-dynnr

dynprofield = 'Screen Field'

value_org = 'S'

TABLES

value_tab = 'Internal table'

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

Based on the value selected fetch the value to displayed in the text box.

Thanx & Rgds,

Krishna

Former Member
0 Kudos

REPORT Y16V_SAMPLE.

tables : mara.

TYPE-POOLS vrm.

DATA values TYPE vrm_values WITH HEADER LINE.

parameters : p_mtart like mara-mtart AS LISTBOX VISIBLE LENGTH 30.

start-of-selection.

SELECT * FROM mara.

values-text = mara-mtart.

values-key = mara-matnr.

APPEND values.

ENDSELECT.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'SBOOK-CARRID'

values = values[]

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.