cancel
Showing results for 
Search instead for 
Did you mean: 

How to Display DropDown in ALV

Former Member
0 Kudos

Hello,

I have a Dynamic  ALV Table with a DropDown by Key, everything is working fine,

ls_dropdown-VALUE = 'AAA'

ls_dropdown-TEXT  = 'Germany'

append ls_dropdown to lt_Dropdown.

ls_dropdown-VALUE = 'BBB'

ls_dropdown-TEXT  = 'England'

append ls_dropdown to lt_Dropdown.

when the user choose  'Germany', so 'Germany' will be shown in the ALV Table and after saving only the Key 'AAA' will be saved. and this is fine.

my requirement is, when the user shoose 'Germany', I want the key  'AAA'  will be Displayed and Not the text 'Germany' and after saving, i want the Key will be saved and not the Text.

i will be very happy of any kind of Help

Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Agadir,

You can show KEY along with text in drop down after selection.

Use the method SET_KEY_VISIBLE to set whether key to be visible or not.

Example:

               data lo_ddbk type ref to CL_SALV_WD_UIE_DROPDOWN_BY_KEY.

....... here goes your logic to create new drop down by key element

         

               lo_ddbk->set_key_visible( value =  abap_true ).

Now, your drop down value should be as below

Select "Germanay" -----> AAA - Germany

          "England"    -----> BBB - England

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hello Rama,

I've done this methode  lo_ddbk->set_key_visible( value =  abap_true ) I cann see both Key and Text.

but as I said, i need after selection that only Key will be shown in the table and Not the Text.

example:


the user click on the DropDown, he see :


Germany      AAA

England       BBB


he select  Germany, so i want in this case only AAA will be shown in the Table for this entry  and not the Text 'Germany'


Regards Agadir

ramakrishnappa
Active Contributor
0 Kudos

Hi Agadir,

To show only KEY without TEXT is not possible but other way around is possible.i.e you can show TEXT alone without KEY.

By the way, what it is the exact requirement?

I don't see any point in showing only KEY without descriptive text for user. Also, user selects GERMANY but he see AAA instead of GERMANY.

Don't you think the user would be surprised to see some non-relevant info.

Regards,

Rama

Former Member
0 Kudos

Hello Rama,

I think you still did not understand the rquirements,

on the DropDown, bouth are shown Key and Text, BUT after selecting an entry, only the Key should be displayed in the table... and not the text

this is the rquirement from customer.

regards

ramakrishnappa
Active Contributor
0 Kudos

Hi Agadir,

I think, there is something missing in understanding your exact requirement.

Which table are you referring to ?

If you are referring to alv table

  • Here drop down by key is used for a cell editor in alv table where countries list is being populated as drop down list
  • Now, user clicks on drop down list, chooses GERMANY, after selection the cell editor ( drop down ) in alv table gets filled with either GERMANY or GERMANY  AAA

Now in any case you cannot be able display only KEY : AAA  in alv table on selecting GERMANY

If you are referring to save data back to database table

     No need to worry, always only KEY: AAA gets saved into the database.

I appreciate you provide more details in case if my understanding is away from your expectation.

Regards,

Rama

Former Member
0 Kudos

Hello Rama,

as you describe her :

Now in any case you cannot be able display only KEY : AAA  in alv table on selecting GERMANY


thats exactely waht am looking for !!


how can do this, only Key should be displayed in ALV table , is there any way to do this?

Dropdown by Index ?



Regards

Agadir

ramakrishnappa
Active Contributor
0 Kudos

Hi Agadir,

Even drop down by Index would not help in this case.

Its better you go for an input field with search help country key and country name. Upon use selection, only key appears in the input field.

Also, you can set property  VALUE_SUGGEST  of the input field, so that as soon as user types in the field,the countries list gets populated as drop down.

Hope this helps you.

Regards,

Rama