Dropdown list box holds predefined set of input values from which the user need to choose. It is not possible to type a entry into a dropdown box, instead, the user must use one of the values from the list.
In this tutorial, I will tackle dropdown list in a dialog screen: how to create/display a dropdown list, how to dynamically fill its dropdown values and how to set its default value.
A. How to set/create a dropdown list in a dialog screen?
1. Open your screen where you will your objects. Add a textbox just like this one below.
2. Double click the textbox so that the attribute screen will appear. On the dropdown list as seen below, select “listbox”. You can also select “listbox with key”. The only difference is that the value key will also appear in the dropdown list once executed.
3.Once set, look at your textbox in your screen and it should like this: a dropdown list now.
B. How to dynamically fill its dropdown values?
First declare an internal table which has reference to the structure VRM_VALUE. In this example I call it i_values. This structure contains two fields which are key and text.
DATA: i_values type standard table vrm_value,
wa_values type vrm_value.
Then fill up this internal table accordingly. As seen in my sample, the value comes from another internal table i_categories. Be sure to pass a key and a text. The key is used to set the default value while the text is the actual text to be displayed in the dropdown list.
Once the internal table i_values is filled, passed it to the function module ‘VRM_SET_VALUES’.
Run your program and it should look something like this one below. A dropdown list with values.
C. How to set the default value of a dropdown list?
Setting a default value is only applicable when you edit/modify an entry. In short, it is not valid when you are creating a new entry. Cause what we want to show is the value stored in a table. So if that is a list, it must display only the value previously selected. I hope I make myself clear in this matter.
The key here to set the default value of a dropdown list is setting the key field just like below. That is the secret.
Then on the PBO just pass the actual key to the name of the dropdown list. Run the program and try to edit something. You will see that a default value will be set to the drop down list. So in my example, the field MNMID has a value which is previously saved in the table. So what I did was, I just pass this value to the name of the drop down list.
As a result, when the screen is shown, the dropdown list has a value selected from the list.
Again, a million thanks for reading my posts. I hope to hear from you. Keep on reading.. :)
Good morning people around the world. Its me again doing some blogs. Sharing to you some tips and tricks in the SAP world. Well, before I s...
Hello everyone. Its another topic I want to discuss with you today. Pause for a moment and take a look with this simple ALV grid below. Do y...
Hello dearest ABAPers all over the world. It's Saturday today and its my rest day. Its me again sharing to you what I learned over the...
While developing a program, I need to show a pop screen. Normally, I do this way. CALL SCREEN 200 STARTING AT 2 2. However, I have a p...