cancel
Showing results for 
Search instead for 
Did you mean: 

Display 2 columns in a Drop Down for WD Abap

Former Member
0 Kudos

Hi,

I have a requirement where I need to display 2 columns in a drop down ( Col1 - Key, Col2 - Text ).

Is it possible to display in a dropdown?

Please help with your pointers.

Regards,

Sujay.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Instead of concatenating key and text in the text, you could use set_key_visible( ) method to display key and text ( appears like columns)

code snippet: Write the below code in WDDOMODIFYVIEW method.

  DATA lr_drop_down     TYPE REF TO cl_wd_dropdown_by_key.

  lr_drop_down ?= view->get_element( 'DRP_DWN' ). "DRP_DWN is the name of Drop down UI element

  lr_drop_down->set_key_visible( abap_true ).

hope this helps,

Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

It worked. Thanks for the response.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Create two columns of type dropdown and bind the data accordingly..

If you want to display data in 2nd column dropdown based on selected 1st column dropdown, create and action and bind the value accordingly.

Thanks

KH

Former Member
0 Kudos

Hi KH,

Thanks for the response.

I would require to display 2 columns in the same Dropdown when the user clicks on it.

Regards,

Sujay

hitesh_gabani
Participant
0 Kudos

Hi Sujay,

if you have requirement where you need to display 2 columns in a drop down for example,

TYPES: BEGIN OF TY_OUT,

               KEY TYPE I,

               TEXT TYPE STRING,

             END OF TY_OUT.

DATA : IST_OUT TYPE TABLE OF TY_OUT,

           WA_OUT TYPE TY_OUT.

and Data in IST_OUT LIke,

KEY  TEXT

1         A

2         B

3         C

You want to display KEY as well as TEXT . It is directly not possible for that you have to take another internal table such as below,

DATA: IST_BIND TYPE TABLE OF TY_OUT,

          WA_BIND TYPE TY_OUT.

DATA: GD_TMP TYPE STRING.

LOOP AT IST_OUT INTO WA_OUT.

    CLEAR : WA_BIND,GD_TMP.

    CONCATENATE WA_OUT-KEY WA_OUT-TEXT INTO GD_TMP SEPARATED BY '-'.

    WA_BIND-KEY = WA_OUT-KEY.

    WA_BIND-TEXT = WA_OUT-TEXT.

    APPEND WA_BIND TO IST_BIND.

    CLEAR : WA_BIND.

ENDLOOP.

Use IST_BIND for display value in drop down.

Rewards if Helpful or Correct answer.

Regards,

Hitesh

Former Member
0 Kudos

Hi Hitesh,

Thanks for the response.

I have tried it before posting but the values in the drop down doesn't look like 2 columns.

It just displays in a single column with key and text separated by Space.

Regards,

Sujay.

hitesh_gabani
Participant
0 Kudos

Hi,

Call set_key_visible method to abap_true on your Dropdown List object e.g.:

Data: lr_chr_dropdown type ref to cl_salv_wd_uie_dropdown_by_key.

lr_chr_dropdown->set_key_visible(abap_true ).


regards,

Hitesh