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

Drop-Down Box Creation

sreeramkumar_madisetty
Active Contributor
0 Likes
819

Hi Friends

I want to create a drop-down list box for the field : P0759-CSTAT with 5 values .

 1 - In Planning

 2 - Submitted

 3 - Approved

 4 - Rejected

 5 - Active (this status should not be included on the selection screen)

Can anyone give me the sample code if you faced this requirement already or give me idea how I can proceed for this.

Thanks for your cooperation.

Regards,

Sree

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
781

Hi,

Please refer the code below:


PARAMETERS:
listbox(1) AS LISTBOX VISIBLE LENGTH 10 DEFAULT 'N'.
AT SELECTION-SCREEN OUTPUT.
DATA:
name TYPE vrm_id,
list TYPE vrm_values,
value TYPE vrm_value.
name = 'LISTBOX'. " Name should be in UPPER CASE

value-key = '1'.
value-text = 'Text 1'.
APPEND value TO list.
value-key = '2'.
value-text = 'Text 2'.
APPEND value TO list.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list
EXCEPTIONS
id_illegal_name = 0
OTHERS = 0. 

Thanks,

Sriram Ponna.

6 REPLIES 6
Read only

former_member404244
Active Contributor
0 Likes
781

Hi,

check the below sample code

TYPE-POOLS: vrm.

PARAMETER: pr_spart TYPE spart AS LISTBOX VISIBLE LENGTH 7.

*AT SELECTION-SCREEN ON VALUE-REQUEST FOR pr_spart.

INITIALIZATION.

*----Code for Drop down list....

DATA: lit_spart_list TYPE vrm_values, "Table for list of Divisions

lwa_spart_list TYPE vrm_value,

lw_name TYPE vrm_id. "Name of parameter with list-box.

*---Assign selected values to table that would be passed to FM VRM_SET_VALUES

CLEAR : lwa_spart_list,

lw_name.

*---Pass required values for list-box display.

lwa_spart_list-key = 'H'.

lwa_spart_list-text = 'HL'.

APPEND lwa_spart_list TO lit_spart_list.

lwa_spart_list-key = 'S'.

lwa_spart_list-text = 'SL'.

APPEND lwa_spart_list TO lit_spart_list.

lwa_spart_list-key = 'P'.

lwa_spart_list-text = 'PP'.

APPEND lwa_spart_list TO lit_spart_list.

lwa_spart_list-key = 'F'.

lwa_spart_list-text = 'FR'.

APPEND lwa_spart_list TO lit_spart_list.

*Name of parameter to which list is to be assigned

lw_name = 'PR_SPART'.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = lw_name

values = lit_spart_list

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.

Regards,

Nagaraj

Read only

p291102
Active Contributor
0 Likes
781

Hi,

Following report is the Drop down sample report.

REPORT YMS_DROPDOWNLISTBOX.

TYPE-POOLS : VRM.

TABLES : AFKO,AFPO,SSCRFIELDS.

DATA : BEGIN OF IAFKO OCCURS 0,

AUFNR LIKE AFKO-AUFNR,

END OF IAFKO.

DATA : BEGIN OF IAFPO OCCURS 0,

MATNR LIKE AFPO-MATNR,

END OF IAFPO.

DATA : ITAB TYPE VRM_VALUE.

DATA : VID TYPE VRM_ID.

DATA : ITAB1 TYPE VRM_VALUES ,

ITAB2 TYPE VRM_VALUES .

DATA : FLAG.

PARAMETERS : P_AUFNR LIKE AFKO-AUFNR AS LISTBOX VISIBLE LENGTH 15.

INITIALIZATION.

SELECT AUFNR FROM AFKO UP TO 10 ROWS INTO TABLE IAFKO WHERE AUFNR LIKE

'%704%'.

LOOP AT IAFKO.

ITAB-KEY = IAFKO-AUFNR.

ITAB-TEXT = IAFKO-AUFNR.

APPEND ITAB TO ITAB1.

ENDLOOP.

AT SELECTION-SCREEN OUTPUT.

VID = 'P_AUFNR'.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = VID

VALUES = ITAB1

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.

Thanks,

Sankar M

Read only

Former Member
0 Likes
781

Hi,

Adding dropdown facility to the input fields is called as LIST OF VALUES.

VRM is a predefined type group which has the following structure and internal table:

VRM_VALUE is a structure with the components KEY and TEXT.

VRM_VALUES is an internal table declared for the above structure without header line.

The above type group is used to fetch values from the internal table declared with user-defined records and insert into the input field in the screen.

'VRM_SET_VALUES' is a function module used to carry the records from the internal table and populate in the input field.

NAVIGATIONS TO CREATE DROPDOWN FACILITY FOR INPUT BOX:

-


1. Create MPP program.

2. Create a screen.

3. Add a input box -> Double click -> Specify name (IO1) -> Select LISTBOX from the dropdown list -> A dropdown facility is added for the input field in the screen.

4. Create two pushbuttons (PRINT, EXIT).

5. In Top Include File, specify following code:

TYPE-POOLS VRM.

DATA IO1(20).

DATA A TYPE I.

DATA ITAB TYPE VRM_VALUES. * To create an internal table of an existing type

DATA WA LIKE LINE OF ITAB. * To create a temporary structure of sameline type of internal table.

6. In PBO, specify following code:

IF A = 0.

WA-KEY = 'ABAP'.

WA-TEXT = 'ADVANCED PROGRAMMING'.

APPEND WA TO ITAB.

WA-KEY = 'BW'.

WA-TEXT = 'BUSINESS WAREHOUSING'.

APPEND WA TO ITAB.

WA-KEY = 'EP'.

WA-TEXT = 'ENTERPRISE PORTAL'.

APPEND WA TO ITAB.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'IO1'

VALUES = ITAB.

A = 1.

ENDIF.

7. In PAI, specify following:

CASE SY-UCOMM.

WHEN 'PRINT'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

8. Create a Tcode -> Activate all -> Execute.

Regards,

Priya.

Edited by: priyadharshini veluswamy on Feb 28, 2008 7:13 AM

Read only

Former Member
0 Likes
781

Hi,

TYPE-POOLS VRM.

DATA: ws_name TYPE vrm_id,

ws_list TYPE vrm_values,

ws_value LIKE LINE OF ws_list,

ws_name2 TYPE vrm_id.

In parameters "P0759-CSTAT" This should be declare as LIST box

AT SELETION-SCREEN OUTPUT.

ws_value-key = '1'.

ws_value-text = 'In Planning'.

APPEND ws_value TO ws_list.

ws_value-key = '2'.

ws_value-text = 'Submitted'.

APPEND ws_value TO ws_list.

Like declare all your fields.

ws_name = your paramenter name.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = ws_name

values = ws_list

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

Read only

Former Member
0 Likes
781

Hi,

Try with this code:

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.

Regards,

Bhaskar

Read only

Former Member
0 Likes
782

Hi,

Please refer the code below:


PARAMETERS:
listbox(1) AS LISTBOX VISIBLE LENGTH 10 DEFAULT 'N'.
AT SELECTION-SCREEN OUTPUT.
DATA:
name TYPE vrm_id,
list TYPE vrm_values,
value TYPE vrm_value.
name = 'LISTBOX'. " Name should be in UPPER CASE

value-key = '1'.
value-text = 'Text 1'.
APPEND value TO list.
value-key = '2'.
value-text = 'Text 2'.
APPEND value TO list.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list
EXCEPTIONS
id_illegal_name = 0
OTHERS = 0. 

Thanks,

Sriram Ponna.