‎2012 Oct 10 10:07 AM
Hi,
I want to build a selection screen with a simple Dropdown box, the values of which I have already. Seems simple enough - but it seems to be more complicated than that.
I found something in the SAP online help with a piece of sample code which I adopted, merely changing the names of tables and fields (because my Dropdown list will not display airlines, but document types). I guess, though, that the example builds on some earlier created internal tables or something. I'm somewhat irritated by 'scarr' (in the FROM line of the corresp. module call) and I don't know what fields are in the table sdyn-conn - the field carrid is surely the one created in earlier 'lessons', so I don't have it.
Can anybody lend me a hand here?
Thanks a lot!
Best regards,
Sapperdapper
‎2012 Oct 10 10:11 AM
You have to populate the values into an internal table that is to be passed to function VRM_SET_VALUES. If you are confused with the SAP sample code , just search it here in SCN.
Please try to avoid the impression of "not searching the SCN content".
Kesav
‎2012 Oct 10 10:29 AM
Hi Friedrich,
Hope this will help you.
REPORT zmtest07 .
TYPE-POOLS : vrm. "Value Request Manager
PARAMETERS: p_test AS LISTBOX VISIBLE LENGTH 12 OBLIGATORY.
INITIALIZATION.
PERFORM f4_value_request.
START-OF-SELECTION.
WRITE p_test.
FORM f4_value_request.
DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
l_value-key = '1'.
l_value-text = 'January'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '2'.
l_value-text = 'February'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '3'.
l_value-text = 'March'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '4'.
l_value-text = 'April'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '5'.
l_value-text = 'May'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '6'.
l_value-text = 'June'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '7'.
l_value-text = 'July'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '8'.
l_value-text = 'August'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '9'.
l_value-text = 'September'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '10'.
l_value-text = 'October'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '11'.
l_value-text = 'November'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '12'.
l_value-text = 'December'.
APPEND l_value TO li_list.
CLEAR l_value.
l_name = 'P_TEST'.
p_test = '1'. "this is to set the default value of the list box.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
- Regards,
Manish Shankar.
‎2012 Oct 11 2:34 PM
Hi all,
thanks for the help! I think I'll make it now.
@ Manish
Thanks for the elaborate code sample 😉 More detail than necessary, but I get the concept now.
@ Kesavadas
You're right - the contents to be found here on SCN are mostly better and more precise than those found elsewhere on the net. There is a specific search_plugin for searching SCN and I already have it. I just went by asking a lot because I'm still a newbie to ABAP programming, but now I guess I can find my way around and I can and will switch to searching first and asking only when I can't find anything.
Thanks a lot!
Best regards,
Sapperdapper
‎2012 Oct 11 2:51 PM
Hi Manish,
I m.o.l. copied your code - slightly modified, and I have no FORM routine, it's all in one piece - and the syntax-check says it's ok and it runs - only, the listbox appears empty and, although I have saved two values in li_list, I cannot select any. My code looks like this, almost the same as what you proposed:
TYPE-POOLS: VRM. "Value request manager
PARAMETERS Wrzlbrmp AS LISTBOX VISIBLE LENGTH 12 OBLIGATORY.
DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
l_value-key = '1'.
l_value-text = 'Accounting'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '2'.
l_value-text = 'Personnel'.
APPEND l_value TO li_list.
CLEAR l_value.
l_name = 'Wrzlbrmp'.
Wrzlbrmp = '1'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
I read your sample several times to find if I missed something, but I cannot see where the error lies?
Best regards,
Sapperdapper
‎2012 Oct 11 3:40 PM
The code you have written must run before the selection screen is displayed. As your code is not running you are not getting the desired result. Add the "INITIALIZATION." statement before your data declaration as shown below:
TYPE-POOLS: vrm. "Value request manager
PARAMETERS wrzlbrmp AS LISTBOX VISIBLE LENGTH 12 OBLIGATORY.
INITIALIZATION.
DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
l_value-key = '1'.
l_value-text = 'Accounting'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '2'.
l_value-text = 'Personnel'.
APPEND l_value TO li_list.
CLEAR l_value.
l_name = 'Wrzlbrmp'.
wrzlbrmp = '1'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Che
‎2012 Oct 11 4:19 PM
Thanks!
For some reason those pointy-thingys I could award have disappeared.
I had modified the PARAMETERS part a bit and built an entire SELECTION SCREEN...AS WINDOW around it to make it look nice - a Dropdown-list in the upper left corner of an otherwise blue screen (inside the usual SAP window) is not very attractive - giving it the dynnr 1111, so I had a CALL SELECTION-SCREEN command, but there must have been something wrong with that.
Now I have abandoned the concept of a new SELECTION SCREEN and just positioned the Dropdown_list somewhat more to the middle of the screen and it works fine.
So this is solved.
Many thanks!
P.S.: Hmm, is something broken here? I cannot mark this as "Assumed answered", either...