2007 Apr 25 9:14 PM
I am working on my first screen painter application and have the following problem:
I created a dropdown list that gets populated from an internal table. How can I now read out the value (the text, not the key) of the selected entry?
One part that I am not sure of is whether I need new variables for the return (values, wa_values) or whether I can/must use the ones that created the dropdown list (list, value).
Here is the related code fragment:
REPORT zus_mk_csv_restore.
----
Global data declarations
----
TYPE-POOLS vrm.
DATA: foldername(14) TYPE c,
ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm,
BEGIN OF itab OCCURS 0,
line(200),
END OF itab.
DATA: name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
DATA: values TYPE vrm_values,
wa_values LIKE LINE OF values.
CALL SCREEN 100.
----
MODULE init_listbox OUTPUT
----
*
----
MODULE init_listbox OUTPUT.
LOOP AT itab.
value-key = sy-tabix.
value-text = itab-line.
APPEND value TO list.
ENDLOOP.
name = 'FOLDERS'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDMODULE.
----
MODULE status_0100 OUTPUT
----
*
----
MODULE status_0100 OUTPUT.
*setup gui
SET PF-STATUS 'SCREEN_100'.
[...] itab gets populated with a text list
ENDMODULE.
----
MODULE user_command_0100 INPUT
----
->> this part is not working <<--
----
MODULE user_command_0100 INPUT.
IF sy-ucomm = 'BACK' OR
sy-ucomm = 'EXIT' OR
sy-ucomm = 'CANCEL'.
LEAVE PROGRAM.
ENDIF.
IF sy-ucomm = 'PRESS'.
CALL FUNCTION 'VRM_GET_VALUES'
EXPORTING
id = name
IMPORTING
values = values.
READ TABLE values WITH KEY name INTO wa_values.
foldername = wa_values-text.
[...] do something with the return value
ENDMODULE.
Thanks for your help,
Dennis
2007 Apr 27 6:22 AM
Hi Dennis ,
I got the point creating problem .
You have mentioned only the fild name in your code , like name = 'FOLDERS'.
Insted of that write the complete screen-filed name ... like , name = 'TABLENAME-FIELDNAME ' . I am sure your problem will be solved by doing this .
If your code is not having any problem with the current one then no need to use separate variables ..
Do not forget to reward for helpful answers .
Regards ,
Ranjita
I am working on my first screen painter application and have the following problem:
I created a dropdown list that gets populated from an internal table. How can I now read out the value (the text, not the key) of the selected entry?
One part that I am not sure of is whether I need new variables for the return (values, wa_values) or whether I can/must use the ones that created the dropdown list (list, value).
Here is the related code fragment:
REPORT zus_mk_csv_restore.
----
Global data declarations
----
TYPE-POOLS vrm.
DATA: foldername(14) TYPE c,
ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm,
BEGIN OF itab OCCURS 0,
line(200),
END OF itab.
DATA: name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
DATA: values TYPE vrm_values,
wa_values LIKE LINE OF values.
CALL SCREEN 100.
----
MODULE init_listbox OUTPUT
----
*
----
MODULE init_listbox OUTPUT.
LOOP AT itab.
value-key = sy-tabix.
value-text = itab-line.
APPEND value TO list.
ENDLOOP.
name = 'FOLDERS'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDMODULE.
----
MODULE status_0100 OUTPUT
----
*
----
MODULE status_0100 OUTPUT.
*setup gui
SET PF-STATUS 'SCREEN_100'.
[...] itab gets populated with a text list
ENDMODULE.
----
MODULE user_command_0100 INPUT
----
->> this part is not working <<--
----
MODULE user_command_0100 INPUT.
IF sy-ucomm = 'BACK' OR
sy-ucomm = 'EXIT' OR
sy-ucomm = 'CANCEL'.
LEAVE PROGRAM.
ENDIF.
IF sy-ucomm = 'PRESS'.
CALL FUNCTION 'VRM_GET_VALUES'
EXPORTING
id = name
IMPORTING
values = values.
READ TABLE values WITH KEY name INTO wa_values.
foldername = wa_values-text.
[...] do something with the return value
ENDMODULE.
Thanks for your help,
Dennis
2007 Apr 26 4:11 AM
Hi,
Dennis, you can see this <a href="https://wiki.sdn.sap.com/wiki/display/Snippets/Abap-Create+Listbox">sample program.</a>
Hopefully it help you.
Regards,
2007 Apr 26 4:23 AM
Hi Dennis,
If you want to read the text of the entry selected. append the value of <b>text</b> to the key instead of the <b>sy-tabix</b>.
which means
LOOP AT itab.
value-key = itab-line.
APPEND value TO list.
ENDLOOP
Regards
Gopi
2007 Apr 26 6:35 AM
Go through the folowing programs,
DEMO_DROPDOWN_LISTBOX,
DEMO_DYNPRO_DROPDOWN_LISTBOX
Hope this will solve u r problem.
Sudheer
2007 Apr 26 7:12 AM
Hi,
Delcare one varialbe for that text field in program.
Sothat once the user selected from the dropdown list, the selected value will be assigned to that variable. And u can use that value in ur program.
Use this text field name as ID in the function module which ur using for fill the dropdown list.
If helpful reward.
By,
Amal
Message was edited by:
Amal
2007 Apr 27 6:22 AM
Hi Dennis ,
I got the point creating problem .
You have mentioned only the fild name in your code , like name = 'FOLDERS'.
Insted of that write the complete screen-filed name ... like , name = 'TABLENAME-FIELDNAME ' . I am sure your problem will be solved by doing this .
If your code is not having any problem with the current one then no need to use separate variables ..
Do not forget to reward for helpful answers .
Regards ,
Ranjita
2007 Apr 27 4:49 PM
Thanks everyone for your suggestions. I was still not able to get the return value. My problem is that I am still not used to the ABAP syntax and therefore have problems following your directions.
@ Jatra: your code example provides great insight, but I cannot apply this to my problem because I use a different method to populate the dropdown menu.
@ Gopi: I do not quite understand. I am populating the key and the value. When I look at the dropdown table in the debugger, everything looks fine.
@ Sudheer: Your examples got me up to the point where I am at right now
@ Amal and Ranjita: can you please give me the code fragments? I am not sure what you mean. Ranjita, I changed my "name" variable to 'VALUE-FOLDERS', but then the dropdown list remains empty. Therefore I assume using 'FOLDERS' was correct (the list populates fine).
What looks confusing to me is the fact that after calling 'VRM_GET_VALUES', the table VALUES contains 3 rows (I expected only one) with the key colum being completely empty and the text colum containing all possible choices of the dropdown menu. I begin to think that VRM_GET_VALUES is not the right method to call in order to get the return value. Can anyone confirm this?
I am honestly a little bit surprised that it seems to be so difficult to read the value of a simple dropdown menu. Is there no easy way to "fix" my code fragment posted above? Do you recommend a different approach (if so, please provide details)?
Thanks everyone for your valuable contribution.
Dennis
2007 Apr 30 8:07 AM
Here is the sample code.
create a module in PBO event of the screen.
inside that module paste this code and debug it.
in field give name MODU, u will get the selected value.
in the screen add two I/O box in that, one is dropdown(MODU) and the other is text box(SEL_MODU).
select the value and press enter u will get the selected value in the Text box.
type-pools vrm.
data: name type vrm_id,
list type vrm_values,
value like line of list.
data: modu type string,
sel_modu type string.
clear: list.
name = 'MODU'.
value-key = 'SD'.
value-text = 'Sales and Destribution'.
append value to list.
value-key = 'MM'.
value-text = 'Material Master'.
append value to list.
value-key = 'PP'.
value-text = 'Production and Planning'.
append value to list.
call function 'VRM_SET_VALUES'
exporting
id = name
values = 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.
sel_modu = modu.
2007 Apr 30 5:43 PM
data : NAME type VRM_ID,
LIST type VRM_VALUES,
VALUE like line of LIST.
NAME = <Screen Field Name>.
VALUE-KEY = 'RFQ'.
<b>VALUE-TEXT = 'Req For Quotation'</b>.
append VALUE to LIST.
VALUE-KEY = 'PO'.
<b>VALUE-TEXT = 'Pur Order'</b>.
append VALUE to LIST.
VALUE-KEY = 'INV'.
<b>VALUE-TEXT = 'Invoice'</b>.
append VALUE to LIST.
call function 'VRM_SET_VALUES'
exporting
ID = NAME
VALUES = LIST.
clear LIST.
Just write this sample code and u will see the output and if this not what u wanted, as far as ur query is concerned, what i understood is you do not want the key field to hold the value,instead u want the the key field to hold the text.
in that case just reverse the text and key values.
data : NAME type VRM_ID,
LIST type VRM_VALUES,
VALUE like line of LIST.
NAME = <Screen Field Name>.
<b>VALUE-KEY = 'Req For Quotation'</b>.
VALUE-TEXT = 'RFQ'.
append VALUE to LIST.
<b>VALUE-KEY = 'Pur Order'</b>.
VALUE-TEXT = 'PO'.
append VALUE to LIST.
<b>VALUE-KEY = 'Invoice'</b>.
VALUE-TEXT = 'INV'.
append VALUE to LIST.
call function 'VRM_SET_VALUES'
exporting
ID = NAME
VALUES = LIST.
clear LIST.
If this is not what u wanted, please tell clearly of wht u wnted..
Regards
Gopi
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |