Application Development and Automation 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: 
Read only

Dropdown values from dictionary

Former Member
0 Likes
2,191

I am trying to dsplay 2 dropdown lists on the first screen of my dialog program with the values being plant numbers and cost center numbers. I tried creating fields from the dictionary which creates the variable field name for me with a "-", but in my program if I name the data attribute the same I get an error saying "-" is not allowed in the name of the attribute. If I change it to "_" the program is fine, but the screen painter doesn't allow me to make it a dictionary referenced field. Is there some way to get them named so they are synchronized and so the value list is from the dictionary?

7 REPLIES 7
Read only

surajarafath
Contributor
0 Likes
1,229

If you want to fill the Listbox you can use FM 'VRM_SET_VALUES'

Example:

DATA: NAME TYPE VRM_ID, 
            LIST TYPE VRM_VALUES, 
            VALUE LIKE LINE OF LIST. 
 
 NAME = 'Your_field_name'. 
  VALUE-KEY = '1'. 
  VALUE-TEXT = 'LINE 1'. 
  APPEND VALUE TO LIST. 
  VALUE-KEY = '2'. 
  VALUE-TEXT = 'LINE 2'. 
  APPEND VALUE TO LIST. 

  CALL FUNCTION 'VRM_SET_VALUES' 
  EXPORTING 
  ID = NAME 
  VALUES = LIST.

Read only

0 Likes
1,229

Thanks for your help. It is still not working. Where do I place the code? I am using a module pool program and have put it in the PBO and POV-R. The table with the values is in the top include with the dropdown field.

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,229

I think if you would give a specific example of what you are trying to do, that'd be helpful to understand your scenario.

Read only

0 Likes
1,229

Here is the code from my top include and the module that I have placed in the PBO and POV-R. The table is populated with all plants, then loops throught the table and assigns the value to the values structure with the value-key being assigned to sy-index, and appends the line to the LIST table. Then it calls the function to populate. Thanks for any help.

*TOP INCLUDE*

TYPE-POOLS: vrm.

DATA: DD_NAME TYPE VRM_ID,

DD_LIST TYPE VRM_VALUES,

DD_VALUE LIKE LINE OF DD_LIST.

DATA: BEGIN OF wa_plant,

werks TYPE WERKS,

END OF wa_plant.

DATA: plant_tab LIKE STANDARD TABLE OF wa_plant.

*PBO*

SELECT werks

FROM t001w

INTO TABLE plant_tab.

DD_NAME = 'S1000_PLANT'.

LOOP AT plant_tab INTO wa_plant.

DD_VALUE-KEY = sy-index.

DD_VALUE-TEXT = wa_plant-werks.

APPEND DD_VALUE TO DD_LIST.

ENDLOOP.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = DD_NAME

VALUES = DD_LIST.

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,229

Hm... if you want plant dropdown values when the user presses F4, all you need to do is to define your screen fields with reference to the proper DDIC data element. In case of plant, this would be WERKS_D.

So for instance, if you define your field as

DATA: I_PLANT TYPE WERKS_D.

and the screen field is also called I_PLANT, then this should be automatic.

The same could be done for the cost center too.

Am I missing something?

Read only

0 Likes
1,229

If I try to do that it doesnt let me assign the dictionary value to the field in the screen painter because the name has a "_" instead of a "-". If I define it as a dictionary field from the screen painter it automatically names the field with a "-" which doesn't work in the program as a field name. I feel like I am missing something too, the field name is named the same as in the program and is of the dictionary type, the field display value type is right, but it still displays nothing. I feel like theres something else that has to be done to make the vale come automatically from the dictionary.

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,229

Even though you marked this question as "answered", I just wanted to reiterate that with the method described above, you should be able to get the dropdowns as long as you refer to a program field that has the proper data element reference.

In Screen Painter, when editing the layout, just use Goto -> Secondary Window -> Dictionary/Program fields, and in the window click on 'Get from Program'. You'll get a list of all fields defined in the module pool, and you'll be able to copy those into the screen layout. Doesn't matter if the field has an '_' in the name or not.

If that doesn't work, then the program field definition doesn't refer to the correct data element in the DDIC.