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: 

Listbox value

Former Member
0 Kudos

Hello all,

I have inserted a listbox, a dropdown box in my report filling all the values with month 1 to 12. Now i want to find out what value of the month the user has selected in listbox at event AT selection screen. anyone have suggestions??

thanks and regards,

Gaurav

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

refer sample code:

SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-005.

PARAMETERS : p_field TYPE dd03l-fieldname AS LISTBOX

VISIBLE LENGTH 80 OBLIGATORY.

SELECTION-SCREEN END OF BLOCK c.

INITIALIZATION.

*-- Populate List Box

*-- TEMKSV - Legacy Value

wa_value-key = 'TEMKSV'.

wa_value-text = 'Legacy Key'.

APPEND wa_value TO i_value.

CLEAR: wa_value.

*-- Installation

wa_value-key = 'INSTLN'.

wa_value-text = 'Installation'.

APPEND wa_value TO i_value.

CLEAR: wa_value.

  • Setting the selection

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'P_FIELD'

values = i_value.

CASE p_field.

WHEN 'TEMKSV'.

*-- Delete Object

PERFORM delete_temksv.

WHEN 'INSTLN'.

*-- Delete Installation

PERFORM delete_installation.

endcase.

refer std prg if u need to do the same in Module pool program - RSDEMO_DROPDOWN_LISTBOX

Reward points if this Helps.

Manish

Message was edited by:

Manish Kumar

6 REPLIES 6

Former Member
0 Kudos

HI,

refer sample code:

SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-005.

PARAMETERS : p_field TYPE dd03l-fieldname AS LISTBOX

VISIBLE LENGTH 80 OBLIGATORY.

SELECTION-SCREEN END OF BLOCK c.

INITIALIZATION.

*-- Populate List Box

*-- TEMKSV - Legacy Value

wa_value-key = 'TEMKSV'.

wa_value-text = 'Legacy Key'.

APPEND wa_value TO i_value.

CLEAR: wa_value.

*-- Installation

wa_value-key = 'INSTLN'.

wa_value-text = 'Installation'.

APPEND wa_value TO i_value.

CLEAR: wa_value.

  • Setting the selection

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'P_FIELD'

values = i_value.

CASE p_field.

WHEN 'TEMKSV'.

*-- Delete Object

PERFORM delete_temksv.

WHEN 'INSTLN'.

*-- Delete Installation

PERFORM delete_installation.

endcase.

refer std prg if u need to do the same in Module pool program - RSDEMO_DROPDOWN_LISTBOX

Reward points if this Helps.

Manish

Message was edited by:

Manish Kumar

0 Kudos

thank you manish..

ur answer was very helpful..it almost has solved the problem for it. i was wondering if u look into my program at some specific terms. Basically i intend to insert a list that has values 01 to 12 for months and a blank value as weLL. now when i do it using

Month(2) as listbox visible width 14, it works fine but instead of values 01 to 12 its giving me Jan to Dec.

also when i replace the month variable by month1, the field list is empty.

i m giving u code, see if u can spot anything..i have anyways given u the max points..

thanks mate..

REPORT ZLIST .

Type-Pools : VRM.

Parameter : Month(2) AS LISTBOX VISIBLE LENGTH 14.

DATA: Monthval TYPE vrm_values,

value LIKE LINE OF Monthval,

Initialization.

**Create a list for month selection>

value-text = '01 '.

value-key = 2.

append value to monthval.

value-text = '02'.

value-key = 3.

append value to monthval.

value-text = '03'.

value-key = 4.

append value to monthval.

value-text = '04 '.

value-key = 5.

append value to monthval.

value-text = '05'.

value-key = 6.

append value to monthval.

value-text = '06'.

value-key = 7.

append value to monthval.

value-text = '07'.

value-key = 8.

append value to monthval.

value-text = '08 '.

value-key = 9.

append value to monthval.

value-text = '09 '.

value-key = 10.

append value to monthval.

value-text = '10'.

value-key = 11.

append value to monthval.

value-text = '11 '.

value-key = 12.

append value to monthval.

value-text = '12'.

value-key = 13.

append value to monthval.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'Month'

values = monthval.

end-of-selection.

write : Month.

**************************************************$$$

now if i replace month by month1, no values..

can u check please??

Gaurav

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Try this sample code in at selection-screen.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = L_NAME

DYNUMB = SYST-DYNNR

TRANSLATE_TO_UPPER = C_X " X

TABLES

DYNPFIELDS = L_SCR_FIELDS

EXCEPTIONS

INVALID_ABAPWORKAREA = 1

INVALID_DYNPROFIELD = 2

INVALID_DYNPRONAME = 3

INVALID_DYNPRONUMMER = 4

INVALID_REQUEST = 5

NO_FIELDDESCRIPTION = 6

INVALID_PARAMETER = 7

UNDEFIND_ERROR = 8

DOUBLE_CONVERSION = 9

STEPL_NOT_FOUND = 10

OTHERS = 11

.

IF SY-SUBRC eq 0.

LOOP AT L_SCR_FIELDS.

range1-sign = 'I'.

range1-option = 'EQ'.

range1-low = L_SCR_FIELDS-FIELDVALUE.

range1-high = space.

append range1.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

Hi Gaurav,

What is month1 variable length? Just check if the data type declaration is same.

not sure if I understood your doubt regarding month1. but if you meant to say that you want to display Jan, Feb..... in Listbox, then it should work the same way it works for 01,02...... only thing u have to check if the parameter has enough length to fit List value length.

Hope this helps.

Manish

0 Kudos

month1 has same length as month, 2. only thing i do not understand is just changing the name makes my list empty, i made sure i changed the variable name everywhere, even in FM..

Former Member
0 Kudos

Hi Gaurav,

That what I replied in previous post.

for Month2 should be char3 if you want to hold values Jan, Feb ...etc...

Refer sample code below. Copy and paste in your program and execute.

Hope this helps.

REPORT YTEST21 .

TABLES: temksv.

  • Type pools

TYPE-POOLS : vrm.

DATA:i_value TYPE vrm_values,

wa_value LIKE LINE OF i_value.

SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-005.

PARAMETERS : <b>p_field TYPE dd03l-fieldname AS LISTBOX</b>

VISIBLE LENGTH 80 OBLIGATORY.

SELECTION-SCREEN END OF BLOCK c.

INITIALIZATION.

*-- Populate List Box

*-- TEMKSV - Legacy Value

wa_value-key = '01'.

wa_value-text = 'Jan'.

APPEND wa_value TO i_value.

CLEAR: wa_value.

*-- Installation

wa_value-key = '02'.

wa_value-text = 'Feb'.

APPEND wa_value TO i_value.

CLEAR: wa_value.

  • Setting the selection

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'P_FIELD'

values = i_value.

Reward points if this Helps.

Manish