Skip to Content
author's profile photo Former Member
Former Member

Dropdown in ALV with description only and fcode triggering

Hello,

may be this kind of question have many times duscussed before, but i didn't find any of them as answered,

May requirement is something 2 fold.

I have a Editable alv with dropdowns using class cl_gui_alv_grid, below screenshot.

What i want:

1. I need the description to appear strictly without key, in place of key.

For example:

01 should be replaced by primary school

02 should be replaced by lower secandary and so on.


When ever user select any description, its key should gets captured in internal table.

It seems that this can be achieved using conversion exits, but i don't have enough info how to use them exactly.

2. Whenever any value is selected from dropdown, Function code should gets triggered(like in module pool)

and based on that values choosed, i want to change/refresh grid.

Please guide me .

Screenshot.jpg (43.0 kB)
Add comment
10|10000 characters needed characters exceeded

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2015 at 09:04 AM

    uncheck extras->settings - display technical names

    if not

    under sap gui options

    uncheck interaction desing->visulization 1 - Show keys within dropdown lists

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2015 at 09:53 AM

    Hello!

    You can explicitly control the behaviour of the dropdown boxes over the field catalog. Where do you get your field catalog from? In order to give you proper advise, you may have to provide additional information. Is the field you are referring to a dictionary field?

    One option you have is, roughly speaking, the following: You can always append a field to your field catalog and explicitly control the content of the dropdown list.

    Then handle the event data_changed of cl_gui_alv_grid (you have to do that anyways) to fill your internal table with the corresponding key values rather than the description texts.

    Inside the same event handler method, you may also call the transactions required.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      OK then, I'm afraid you have to control the dropdown content as well as your table display explicitly, for the following reasons:

      1. To my knowledge, there is no way to directly influence the behaviour of dropdown fields defined only by their dictionary reference.

      2. As you noted yourself, the "alias"-mechanism does work only if you pass explicit contents to your dropdown list and has the major drawback, that after a table refresh, the aliases are not shown anymore, instead the key values are displayed.

      Hence I suggest you do the following: divide your data up into two internal tables: one (itab1) for display and one (itab2) for storing into your db table.

      Before display, read your data into itab2 and fill itab1 with the corresponding description texts. Then display itab1 in your ALV grid.

      In the field catalog, you can explicitly control the contents of the dropdown boxes via something like this:

      data:

      lt_dropdown type lvc_t_drop,

      ls_dropdown type lvc_s_drop,

      [...]

      ls_dropdown-handle = '1'.

      ls_dropdown-value = 'Description 1'.

      append ls_dropdown to lt_dropdown.

      ls_dropdown-handle = '2'.

      ls_dropdown-value = 'Description 2'.

      append ls_dropdown to lt_dropdown.


      [...]


      your_alv->set_drop_down_table(

      it_drop_down = lt_dropdown ).

      Then, upon saving, translate the content of itab1 into itab2 and save it.

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2015 at 10:10 AM

    hello,

    when you append the values to drop down internal table at that time pass only descrption and that valeus only appear in the screen

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      if you display only the description then user can select description it wil appear in screen

      LW_CATALOG-DRDN_HNDL = GC_COUNT_TWO.

      LW_CATALOG-DRDN_ALIAS = 'X'.

  • Posted on Apr 07, 2015 at 10:38 AM

    Hi Abhishek,

    In your first requirement you need to have the drop down to only have the key description inside of showing both key and description

    for that kindly check the code

    in the code where you are defining the drop down

    DATA: lt_dropdown TYPE lvc_t_drop,
    ls_dropdown TYPE lvc_s_drop.

    * First row'educational est'.
    ls_dropdown-handle = '1'.
    ls_dropdown-value = '01 Primary school'. // change this to ls_dropdown-value = 'Primary school'
    APPEND ls_dropdown TO lt_dropdown.

    to fill the internal table with the key you need to write the logic as

    ls_dropdown-int_value = '01'. pass this value to the required internal table for processing.

    and in the second requirement

    In the PAI logic you have to write the refreshing code

    module PAI

    case refresh *place this in the button*

    perform alv_output *the subroutine where you are showing the ALV display*

    end module.

    hope that i have answered the queries.

    vishnu

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 07, 2015 at 10:51 AM

    Dear Abhishek,

    press ALT + F12 -----> Options...

    Select visualization1 and uncheck Show keys with dropdown list

    Following is the screen shot

    Thanks....


    pastedImage_0.png (17.6 kB)
    Add comment
    10|10000 characters needed characters exceeded