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: 

Dependent Listboxes in ALV

Former Member
0 Kudos

Hi,

I need to display two listboxes in alv.I need the containts of second list box should come on the base of first list box.

For example: If in my listbox there are two options say 'Teacher' and 'Student', then if I select 'Teacher' then 'Age' and 'Department' should appear in the second list box.If I select 'Student', then second listbox should display 'Class' 'Marks' etc.Please help me out.Thanks in advance.

6 REPLIES 6

tolga_polat
Active Participant
0 Kudos

Hi Ankit,

Check BCALV_EDIT_07 for your request.

Regards

Tolga POLAT

0 Kudos

Hi Tolga,

Thanks for your reply..but this program is not useful for me..

I need to display two listboxes in alv.I need the containts of second list box should come on the base of first list box.

regards,

Ankit

0 Kudos

you can write like this.

in fcat for field1

drdn_hndl = '1'.

for field2

drdn_field = 'DROP_DOWN_HANDLE2'. " this value will be 2 or 3

and for dropdown list:

    ls_dropdown-handle = '1'.
    ls_dropdown-value = 'Teacher'.
    APPEND ls_dropdown TO lt_dropdown.

    ls_dropdown-handle = '1'.
    ls_dropdown-value = 'Student'.
    APPEND ls_dropdown TO lt_dropdown.

    ls_dropdown-handle = '2'.
    ls_dropdown-value = 'Age'.
    APPEND ls_dropdown TO lt_dropdown.

    ls_dropdown-handle = '2'.
    ls_dropdown-value = 'Department'.
    APPEND ls_dropdown TO lt_dropdown.

    ls_dropdown-handle = '3'.
    ls_dropdown-value = 'Class'.
    APPEND ls_dropdown TO lt_dropdown.

    ls_dropdown-handle = '3'.
    ls_dropdown-value = 'Marks'.
    APPEND ls_dropdown TO lt_dropdown.

then at first field2 will be empty, because drop_down_handle2 eq space. when data_changed event triggered for field1 fill drop_down_handle2

Former Member
0 Kudos

Hi Anit,

For this type of ALV,

use cl_salv_table class to create and display ALV.

Now,use class cl_salv_column_table to make required column drop down.

myalv type ref to cl_salv_table.

mycolumns type ref to cl_salv_columns_table.

mycolumn type ref to cl_salv_column_table.

now,

mycolumns = myalv -> get_columns( ).

mycolumn  ?=  mycolumns -> get_column( <name of your list box column> ).

mycolumn ->set_cell_type ( if_salv_c_cell_type =>DROPDOWN)

Similarly,do for second column.

Now you have two columns with drop down.

now set event for drop down.

In second event,set values in 2nd drop down depending on first.

If you are not able to create this logic, let me know.

Regards,

Abdul.

0 Kudos

Hi Abdul,

Thanks for your reply can you please send me some sample code for the same..

Regards,

Ankit

former_member188827
Active Contributor
0 Kudos

Please check BCALV_EDIT_08. It has same functionality. only difference is that it uses search help instead of dropdown list. You can get an idea from this program to achieve your requirement.

Regards