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: 

ALV Drop Down (How to Show text instead of Key)

knitinkumarsethy
Explorer
0 Kudos
3,872

Hi experts,

I have used set_drop_down_table() for displaying the dropdown. And used lvc_t_dral structure for filling it_drop_down_alias.

ls_dropdown-handle = '1'.

ls_dropdown-value = 'C001'.

ls_dropdown-int_value = 'Current Account'.

append ls_dropdown to lt_dropdown.

call method gr_alv_contract->set_drop_down_table

exporting

it_drop_down_alias = lt_dropdown.

In field catalog

ls_fcat-fieldname = 'KEY-RELATIONSHIP_TYPE'.

ls_fcat-col_pos = lv_col_pos.

ls_fcat-outputlen = 20.

ls_fcat-coltext = 'Relationship Type'.

ls_fcat-drdn_hndl = '1'.

ls_fcat-drdn_alias = 'X'.

ls_fcat-drdn_field = 'KEY-RELATIONSHIP_TYPE'."'DROPDOWN'.

append ls_fcat to lt_fcat.

But in my ALV drop down, only Key is coming ('C001') not the text. I need to show the Text to the user('Current Account' instead of 'C001').

Kindly Suggest me the way.

Regards,

Nitin

1 ACCEPTED SOLUTION

knitinkumarsethy
Explorer
0 Kudos
459

I read the GUI settings from front end service class. And according to settings, I have concatenated the key.

6 REPLIES 6

Former Member
0 Kudos
459

Move this text and value of dropdowns into 1 internal table.

declare one more field in table and give the same text as the dropdown in alv and pass the texts from the above inteernal table and capture the changes after selecting the value.

Regards,

Raghu.

MarcinPciak
Active Contributor
0 Kudos
459

I think the issue might seat in the dropdown table type. In my report I am using LVC_T_DROP . The rest seems fine.

Regards

Marcin

Clemenss
Active Contributor
0 Kudos
459

Hi K Nitin Kumar,

adding to the valuable comments already given just one hint: Check the SAPGui settings: The right-most color screen icon on the toolbar on top of the screen opens the local sapgui settings. In options, see tab 'expert', mark or unmark display/sort for dropdown lists.

Regards,

Clemens

knitinkumarsethy
Explorer
0 Kudos
460

I read the GUI settings from front end service class. And according to settings, I have concatenated the key.

0 Kudos
459

I think your main problem is that you are firstly swapping around the key and value fields in the alias table. Secondly your field catalog table needs an alias field as well which you then need to map using the:

ls_fcat-drdn_field

field.

ls_fcat-drdn_field is mapped to a field that will contain the displayed text, and ls_fcat-fieldname will be the key field.

459

You definately are right about the swap of internal fields and output fields though.

Though on the drdn_field, from what I understand if you specify the dropdown handle using drdn_hndl, you do not need the drdn_field.

You would only ever use this if you dynamically want to change the dropdown values during run-time and possibly differ the list for each line in the list.

What I did to solve the internal value / output value issue in ALV grid  is :

In the ALV grid I used in the Field catalogue field CONVEXIT to set a conversion exit.

I created the conversion exit by copying CONVERSION_EXIT_ALV3_OUPUT and _INPUT to my own Z version (for example CONVERSION_EXIT_ZXXXX_OUPUT and _INPUT). Please note ZXXXX should be a maximum of 5 characters.

The Input function CONVERSION_EXIT_ZXXXX_INPUT  I coded as OUTPUT = INPUT. No other code.

In the output function CONVERSION_EXIT_ZXXXX_OUPUT I get the description from the INPUT value from a text table and set this as the output. e.g.

OUTPUT =  INPUT.

SELECT SINGLE BEZEI FROM ZTEXTTABLE INTO OUTPUT

  WHERE SPRAS = SY-LANGU

   AND ZZCODE = INPUT.

As mentioned, in the fieldcat (in your program) I then use field CONVEXIT to call the conversion exit.

ls_fieldcat-drdn_hndl = '1'.

ls_fieldcat-output_len = '35'.

ls_fieldcat-drdn_alias = 'X'.

ls_fieldcat-convexit = 'ZXXXX'.

This will result in the ALV grid displaying descriptions instead of internal values and when selecting from the drop downs in edit mode, the description remains after a refresh.

I looked long and hard and tried various things and this is the only one that worked for me. Happy to receive other solutions as this is a bit of a round-about way in my opinion. I believe it should be handled by ALV grid automatically when you define the drop down handle and the alias flag, but as mentioned I could not get this to work properly.