Dominic
Dominic

Reputation: 11

How to display keys in dropdown menus programmatically?

I want to display the keys in a dropdown field next to the text. I know how I can do this via the options but for our customers I am looking to set this up via my ABAP coding. Is there a way to do this in my ABAP code or does the customers set this by himself via the options?

Greetings Dominic

I looked for any setting in the VRM_SET_VALUES function and stuff like that.

Upvotes: 1

Views: 858

Answers (1)

Sandra Rossi
Sandra Rossi

Reputation: 13656

The listbox values may contain anything you want, you can simulate the option to force the display of key values... No need to look for a setting in VRM_SET_VALUES.

With the below program, according to the user's SAP GUI option "Show keys in dropdown list" whether it's on or off: SAP GUI option "Show keys in dropdown list"

If off, the user will see:

SAP GUI option "Show keys in dropdown list" = OFF

If on, the user will see the same output:

SAP GUI option "Show keys in dropdown list" = ON

Demo code:

REPORT zdemo.
PARAMETERS country(40) LOWER CASE OBLIGATORY AS LISTBOX VISIBLE LENGTH 40.
AT SELECTION-SCREEN OUTPUT.
  DATA(values) = VALUE vrm_values(
      ( key = 'FRA' text = 'France' )
      ( key = 'GER' text = 'Germany' ) ).
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'COUNTRY'
      values          = values
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
AT SELECTION-SCREEN.
  MESSAGE substring( val = country len = 3 ) TYPE 'I'.

Upvotes: 3

Related Questions