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 Create a DropDown Box in a Selection Screen.

former_member193471
Active Contributor
0 Kudos
533

Hi,

I have a question. i.e, How to create a dropdown box in a Selection Screen. Could you please assist me.

Thanks & Regards

Sathish Kumar

5 REPLIES 5

Former Member
0 Kudos
186

Hi satish,

use the function module vrm_set_values..

this will help you.

Thnanks,

Tirumal.

Former Member
0 Kudos
186

hi satish,

The following can assist u to create a drop down ....

Drop down list box can be created in a dialog screen(SE51) as well as selection screen.

The sap list box allows to select a value from the list but we cannot enter our own value in the list box .The value list that will be displayed consists of two

fields TEXT field of TYPE 80(C) and internal KEY field of TYPE 40(C).

In screen painter to create a input/output field into list box we use

'L" as a value for dropdown attribute for the i/o field.

In screen painter to determine the type of method that will be used to fill the value

list we use the attribute value list.

If it is blank the value list will be filled by the first column of the input help assigned to the screen field.This input help can be defined in the ABAP Dictionary, on screen using SELECT,VALUES screen statements or in event POV (PROCESS ON VALUE-REQUEST ) and the input help that will be passed to the field should consists of 2 columns ,the key column is filled automatically by the system.SAP recommends value list field should be blank.

or

The value can be 'A' meaning that the value list will be filled in the event PBO(PROCESS BEFORE OUTPUT) or before the screen is displayed.In this method we use function module VRM_SET_VALUES to fill the values and pass it to the i/o field.

If a function code is attached to the list box the selection of a value triggers a PAI

otherwise PAI will not trigger.

Example

Dropdown list boxes

REPORT DEMO_DYNPRO_DROPDOWN_LISTBOX.

TYPE-POOLS VRM.

DATA: NAME TYPE VRM_ID,

LIST TYPE VRM_VALUES,

VALUE LIKE LINE OF LIST.

DATA: WA_SPFLI TYPE SPFLI,

OK_CODE LIKE SY-UCOMM,

SAVE_OK LIKE 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(BCTRAIN) WITH TEXT-001 DEMOF4HELP-CARRIER2

DEMOF4HELP-CONNID.

ENDIF.

ENDMODULE.

Reward if useful.

Thank you,

Regards.

Former Member
0 Kudos
186

Hi Satish,

Just paste this code: u will get idea..

report YH642_DROP_DOWN_BOX.

TYPE-POOLS vrm.

**"Table declarations...................................................

*TABLES sscrfields.

*"Table declarations...................................................

PARAMETERS:

p_connid(11) AS LISTBOX

VISIBLE LENGTH 20 default 'FOREX-ANANTH'.

p_value TYPE i MODIF ID QWR.

*" Data declarations...................................................

"----


Work variables *

"----


DATA:

w_char(20) TYPE c,

w_flag TYPE i.

"----


INITIALIZATION. EVENT *

"----


INITIALIZATION.

"----


Internal table to hold delivery header data *

"----


DATA:

t_table TYPE

STANDARD TABLE

OF vrm_value,

vrm_values1 LIKE LINE OF t_table.

vrm_values1-key = 'a'.

vrm_values1-text = 'sap'.

APPEND vrm_values1 TO t_table.

vrm_values1-key = '2'.

vrm_values1-text = 'testing'.

APPEND vrm_values1 TO t_table.

vrm_values1-key = '2'.

vrm_values1-text = 'java'.

APPEND vrm_values1 TO t_table.

vrm_values1-key = '4'.

vrm_values1-text = '.net'.

APPEND vrm_values1 TO t_table.

vrm_values1-key = '5'.

vrm_values1-text = 'vc++'.

APPEND vrm_values1 TO t_table.

vrm_values1-key = 'che'.

vrm_values1-text = 'chetta-ram'.

APPEND vrm_values1 TO t_table.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'p_connid'

values = t_table

EXCEPTIONS

ID_ILLEGAL_NAME = 1

OTHERS = 2

.

Thanks,

Sakthi C

*Rewards if usefull*

Former Member
0 Kudos
186

HI,

see this code.

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.

rgds,

bharat.

vallamuthu_madheswaran2
Active Contributor
0 Kudos
186

Hi friend,

Try the given below.

parameter p_name(10) type c.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF screen-name = 'P_NAME'.

SCREEN-VALUES_IN_COMBO = 1.

endifi.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

Thanks & regards,

vallamuthu.M