‎2008 Aug 21 8:48 AM
I am working with module pool program and am using function module VRM_SET_VALUES to populate a list box.
I am writing the logic in the PAI of the screen flow logic.
Eg:
process on value-request.
field list_field MODULE populate_list.
This populates the list.
Now if I have to select an item from the list and press 'Enter', the selected item value dissappears as the module 'populate_list' fires again.
Is there a way to avoid this?
Kindly help.
‎2008 Aug 21 10:35 AM
Hi,
In PBO code this way :
MODULE f4_scr OUTPUT.
REFRESH g_list1.
g_name1 = c_status.
g_value_1-key = c_to_be_sub.
g_value_1-text = c_to_be_sub.
APPEND g_value_1 TO g_list1.
g_value_1-key = c_sub.
g_value_1-text = c_sub.
APPEND g_value_1 TO g_list1.
g_value_1-key = c_chg_needed.
g_value_1-text = c_chg_needed.
APPEND g_value_1 TO g_list1.
g_value_1-key = c_app.
g_value_1-text = c_app.
APPEND g_value_1 TO g_list1.
IF NOT g_list1 IS INITIAL.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = g_name1
values = g_list1.
ENDIF.
ENDMODULE. " F4_SCR OUTPUTAnd in PAI :
MODULE user_command_9000 INPUT.
* function module to get the list box values.
g_name1 = c_status.
CALL FUNCTION 'VRM_GET_VALUES'
EXPORTING
id = g_name1
IMPORTING
values = g_list1
EXCEPTIONS
id_not_found = 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.
READ TABLE g_list1 INTO g_wa_list WITH KEY key = g_status.
IF sy-subrc EQ 0.
g_status = g_wa_list-text.
ENDIF.
ENDMODULE. " USER_COMMAND_9000 INPUTHope this helps.
thanx,
dhanashri.
Edited by: Dhanashri Pawar on Aug 21, 2008 11:36 AM
‎2008 Aug 21 8:54 AM
Check this Demo
DEMO_DYNPRO_DROPDOWN_LISTBOX
Did you set the function code For the list box screen field.
why are you populating the values at this POV. instead populate them at PBO and handle them using the User command in PAI by setting the function code to the list box field.
‎2008 Aug 21 10:02 AM
Hi Vijay,
I am not using a dictionary object. Rather I am using hard coded values in the program. In PBO too if I call VRM_SET_VALUES, the list box is reset everytime PBO gets fired.
Is there any way out in this scenario?
Thanks.
‎2008 Aug 21 10:07 AM
You have to append the values in list in PBO only.Let me know the detailes logic.
‎2008 Aug 21 10:10 AM
Code is as below.
*********************************************
PROCESS BEFORE OUTPUT.
MODULE status_1001.
MODULE populate_list.
PROCESS AFTER INPUT.
MODULE user_command_1001.
*********************************************
module populate_list output.
clear values.
value-key = 'FOC'.
value-text = 'FOC'.
append value to values.
value-key = 'INSTALLMENT'.
value-text = 'INSTALLMENT'.
append value to values.
value-key = 'INSTALLMENT1'.
value-text = 'INSTALLMENT1'.
append value to values.
field_id = 'list'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = field_id
VALUES = VALUES.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endmodule. " populate_list OUTPUT
‎2008 Aug 21 10:22 AM
The Value list attribute is set to A, and it has the function code.
‎2008 Aug 21 10:23 AM
>
> Hi Vijay,
>
> I am not using a dictionary object. Rather I am using hard coded values in the program. In PBO too if I call VRM_SET_VALUES, the list box is reset everytime PBO gets fired.
>
> Is there any way out in this scenario?
>
> Thanks.
Certain things that you do in the PBO eg doing the initial population of a table control from a database table, should only be done once, and this is one of them. Run VRM_SET_VALUES on the first run of the PBO when your screen is first called. Then set a flag which you will check on every subsequent PBO call to prevent the FM from running again.
‎2008 Aug 21 10:15 AM
Hi,
Check the following link:
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm
Regards,
Bhaskar
‎2008 Aug 21 10:35 AM
Hi,
In PBO code this way :
MODULE f4_scr OUTPUT.
REFRESH g_list1.
g_name1 = c_status.
g_value_1-key = c_to_be_sub.
g_value_1-text = c_to_be_sub.
APPEND g_value_1 TO g_list1.
g_value_1-key = c_sub.
g_value_1-text = c_sub.
APPEND g_value_1 TO g_list1.
g_value_1-key = c_chg_needed.
g_value_1-text = c_chg_needed.
APPEND g_value_1 TO g_list1.
g_value_1-key = c_app.
g_value_1-text = c_app.
APPEND g_value_1 TO g_list1.
IF NOT g_list1 IS INITIAL.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = g_name1
values = g_list1.
ENDIF.
ENDMODULE. " F4_SCR OUTPUTAnd in PAI :
MODULE user_command_9000 INPUT.
* function module to get the list box values.
g_name1 = c_status.
CALL FUNCTION 'VRM_GET_VALUES'
EXPORTING
id = g_name1
IMPORTING
values = g_list1
EXCEPTIONS
id_not_found = 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.
READ TABLE g_list1 INTO g_wa_list WITH KEY key = g_status.
IF sy-subrc EQ 0.
g_status = g_wa_list-text.
ENDIF.
ENDMODULE. " USER_COMMAND_9000 INPUTHope this helps.
thanx,
dhanashri.
Edited by: Dhanashri Pawar on Aug 21, 2008 11:36 AM
‎2008 Aug 21 10:41 AM
hi Check out this code.
PROCESS BEFORE OUTPUT.
MODULE status_0100.
**Moduel to create the drop down for the field TYPE
MODULE type_dropdown.
MODULE type_dropdown OUTPUT.
CLEAR : value,
list.
value-key = c_txt01.
APPEND value TO list.
value-key = c_txt02.
APPEND value TO list.
value-key = c_txt03.
APPEND value TO list.
value-key = c_txt04.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'D_TYPE'
values = list.
ENDMODULE. " TYPE_DROPDOWN OUTPUT