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: 

Dropdown in ALV with description only and fcode triggering

Former Member
0 Kudos
3,213

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 .

16 REPLIES 16

Former Member
0 Kudos
969

uncheck extras->settings - display technical names

if not

under sap gui options

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

0 Kudos
969

no use...both of them

Former Member
0 Kudos
969

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.

0 Kudos
969

Hi Christian ,

The field catalogue is generated by the function module 'LVC_FIELDCATALOG_MERGE' and passing DDIC Structure in parameter ' i_structure_name'.

Something Like This:


CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

    EXPORTING

      i_structure_name      = w_tabname

    CHANGING

      ct_fieldcat            = et_fieldcat_lvc

    EXCEPTIONS

      inconsistent_interface = 1

      program_error          = 2

      OTHERS                = 3.

  IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF

.

Dropdown Handles are created like that:


*--- Create Dropdowns Handles

   LOOP AT et_fieldcat_lvc INTO gs_et_fieldcat_lvc.

     l_index = sy-tabix.

     READ TABLE gt_dfies WITH KEY

                           fieldname = gs_et_fieldcat_lvc-fieldname

                               valexi = zedit_x TRANSPORTING NO FIELDS.

     CHECK sy-subrc IS INITIAL.

     ADD 1 TO l_count.

     gs_et_fieldcat_lvc-drdn_hndl = l_count.

     gs_et_fieldcat_lvc-drdn_alias = zedit_x.

     gs_et_fieldcat_lvc-convexit = 'ZABCD'."use of conversion exits

     gs_et_fieldcat_lvc-outputlen = 15.

     MODIFY et_fieldcat_lvc FROM gs_et_fieldcat_lvc INDEX l_index.

     CLEAR gs_et_fieldcat_lvc.

ENDLOOP


I have used 'ALIAS' also but they are not working in my case.

I am still seeing keys.

I tried convesion exit in field catalgue, they seems ok, but i need to pass something also in conversion FM,other than input.

Based on which i'll fetch alias.

0 Kudos
969

In the snippet you are providing you only create the dropdown handles, but not the actual content of the dropdown boxes. If there is no other code related to dropdown fields, the content of the dropdown boxes is managed via the ddic reference of your table fields, which is not sufficient for your requirement.

As far as I have understood, you want to have description texts displayed in your grid, but key values saved in the corresponding db table, am I correct?

Also, you may eventually take a look at the BCALV* example programs, it may as well be the case that these cover your requirement.

0 Kudos
969

Christian Kuhl wrote:

As far as I have understood, you want to have description texts displayed in your grid, but key values saved in the corresponding db table, am I correct?

Yes Correct. Exactly.

These are actually domain fixed values, i want their description to show in alv and key to be stored in db table.

0 Kudos
969

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.

Former Member
0 Kudos
969

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

0 Kudos
969

that values are appearing on screen indeed.

But i want the description to appear instead of key

0 Kudos
969

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'.

gabmarian
Active Contributor
0 Kudos
969

I managed to find a great step-by-step guide with same methodology, but with more detail: ABAP &amp;#8211; Problems with combo box in ALV | Spider&amp;#039;s web

former_member206650
Active Participant
0 Kudos
969

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

former_member196157
Active Participant
0 Kudos
969

Dear Abhishek,

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

Select visualization1 and uncheck Show keys with dropdown list

Following is the screen shot

Thanks....

0 Kudos
969

tried...works with module pool...not alv

Former Member
0 Kudos
969

The example you have quoted is nice and would have been helpful if:

There is hardcoded domain name:ZDOM_TEST

  1. FUNCTION CONVERSION_EXIT_ZPRIO_OUTPUT.
  2. *"----------------------------------------------------------
  3. *"*"Local Interface:
  4. *" IMPORTING
  5. *" VALUE(INPUT)
  6. *" EXPORTING
  7. *" VALUE(OUTPUT)
  8. *"----------------------------------------------------------
  9.   DATA:
  10.   lt_dd07v TYPE TABLE OF dd07v.
  11.   FIELD-SYMBOLS:
  12.   <ls_dd07> TYPE dd07v.
  13.   CALL FUNCTION 'DDIF_DOMA_GET'
  14.    EXPORTING
  15.   name = 'ZDOM_TEST'
  16.   langu = sy-langu
  17.    TABLES
  18.   dd07v_tab = lt_dd07v.
  19.   READ TABLE lt_dd07v ASSIGNING <ls_dd07>
  20.    WITH KEY domvalue_l = input.
  21.   CHECK sy-subrc = 0.
  22.   output = <ls_dd07>-ddtext.
  23. ENDFUNCTION.

I have more than 15 domains.

how can i pass the domain name into this conversion exit and thus i will call this FMDDIF_DOMA_GET

and fetch fixed values and assign them to output .

gabmarian
Active Contributor
0 Kudos
969

I'm afraid you cannot do that, since the interface of the conversion routines are fixed.

The most you can do is to write generic routines in the function pool where you place the exits, which will be called from each of them, but the wrapper FM's are still needed.