2009 Jul 11 12:46 AM
Hi,
I have two listboxes on the screen. Based on value chosen in first dropdown, I want to populate the values to be selected in second dropdown. How can i achieve this? I would be glad if anyone can help me out with this requirement.
Thanks,
Ameet
Hi,
I have two listboxes on the screen. Based on value chosen in first dropdown, I want to populate the values to be selected in second dropdown. How can i achieve this? I would be glad if anyone can help me out with this requirement.
Thanks,
Ameet
2009 Jul 11 1:03 AM
You need to hit an enter after u choose the value.. on p_name..
and its just a sample code... u need to verify if you already have an entry and all...
REPORT zj_test.
TYPE-POOLS : vrm.
DATA: param TYPE vrm_id,
values TYPE vrm_values,
value LIKE LINE OF values.
PARAMETERS: p_name(10) AS LISTBOX VISIBLE LENGTH 10.
PARAMETERS: p_last(10) AS LISTBOX VISIBLE LENGTH 10.
*AT SELECTION-SCREEN OUTPUT.
INITIALIZATION.
param = 'P_NAME'.
value-key = '1'.
value-text = 'JOHN'.
APPEND value TO values.
value-key = '2'.
value-text = 'PETER'.
APPEND value TO values.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = param
values = values.
CLEAR: param, values.
AT SELECTION-SCREEN.
param = 'P_LAST'.
IF p_name EQ '1'.
value-key = '1'.
value-text = 'JANARDAN'.
APPEND value TO values.
ENDIF.
IF p_name EQ '2'.
value-key = '2'.
value-text = 'PRABHAKAR'.
APPEND value TO values.
ENDIF.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = param
values = values.
2009 Jul 11 1:16 AM
Hi Jay,
I am required to do it in a module-pool on a screen where i have these two dropdowns.
Does the same logic works. Please guide me.
Thanks,
Ameet
2009 Jul 11 4:46 AM
Coding is same as Jay Given , only with little change.
In module pool , assign a okcode for the first listbox ,
In PAI .
if okcode = listbox.
populate the second listbox based on value in fist.
try and reply
2009 Jul 13 8:50 AM
Hi,
Check program DEMO_DYNPRO_DROPDOWN_LISTBOX . This is what you need.
Regards
Marcin
2009 Jul 11 6:07 AM
Hi,
I have Provided the Example Which i have done in module pool Programming just check this you will get a clear idea.
MODULE fill_customer INPUT.----
MODULE fill_project INPUT.------------------------------>Second list box based on first list box
*Filling the Project Details Based on the Customer
DATA : v1_pspnr TYPE prps-pspnr.
* Refreshing the t_project to get the project details based on the customer
REFRESH : t_project.
IF t_project[] IS INITIAL.
SELECT SINGLE pspnr FROM proj
INTO v1_pspnr WHERE pspid = wa_customer.
IF sy-subrc = 0.
SELECT psphi FROM prps
INTO t_prps-psphi
WHERE psphi = v1_pspnr.
APPEND t_prps.
ENDSELECT.
ENDIF.
SELECT posid FROM prps INTO
t_project-posid
WHERE psphi = t_prps-psphi.
APPEND t_project.
ENDSELECT.
*Inserting all to the project listbox
t_project-posid = 'ALL'.
INSERT t_project INTO t_project INDEX 1.
* Function module for appending the project in the project listbox
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'WA_PROJECT'
value_org = 'S'
TABLES
value_tab = t_project
return_tab = return3.
IF sy-subrc = 0.
t_project-posid = return3-fieldval.
ENDIF.
* to get the WBS element
IF NOT wa_project IS INITIAL.
SELECT SINGLE pspnr FROM prps INTO prps-pspnr
WHERE posid = wa_project.
IF sy-subrc = 0.
* wa_project = prps-pspnr.
v_pro = prps-pspnr.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE. " FILL_PROJECT INPUT
ENDIF.
ENDMODULE. " FILL_CUSTOMER INPUT
you have to declare these two in process on value request.
2009 Jul 20 3:22 AM
<font color=blue>Hi,
<li> Place 2 input fields on screen.
<li>Set Listbox property as it is shown in the below link.
<a href="http://2.bp.blogspot.com/_O5f8iAlgdNQ/SmPSPnRa0tI/AAAAAAAAFCQ/wW_URP-ld6o/s1600-h/drop_down-770536.JPG" target="_new">link to dropdown setting</a>
<li>Set function code to first dropdown box to trigger event when you select value from first dropdown box. So that second one is changed.
<li>Declare variable like below in TOP include of the module pool program.
<pre>DATA: g_drop_1 TYPE char10,
g_drop_2 TYPE char10,
ucomm TYPE sy-ucomm.
TYPE-POOLS vrm.
DATA: name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.</pre>
<li> Use screen flow logic of the screen like below
<pre>"PROCESS BEFORE OUTPUT.
PROCESS BEFORE OUTPUT.
field g_drop_1 MODULE drop_down_1.
field g_drop_2 MODULE drop_down_2.
"PROCESS AFTER INPUT.
PROCESS AFTER INPUT.
field g_drop_1.
field g_drop_2.</pre>
<li>Corresponding code for two drop down boxes.
<pre>&----
*& Module DROP_DOWN_1 OUTPUT
&----
MODULE drop_down_1 OUTPUT.
CLEAR: list[],g_drop_2.
name = 'G_DROP_1'.
value-key = '1'.
value-text = 'value_1'.
APPEND value TO list.
CLEAR value.
value-key = '2'.
value-text = 'value_2'.
APPEND value TO list.
CLEAR value.
value-key = '3'.
value-text = 'value_3'.
APPEND value TO list.
CLEAR value.
value-key = '4'.
value-text = 'value_4'.
APPEND value TO list.
CLEAR value.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDMODULE. " DROP_DOWN_1 OUTPUT
&----
*& Module DROP_DOWN_2 OUTPUT
&----
MODULE drop_down_2 OUTPUT.
CLEAR list[].
name = 'G_DROP_2'.
CASE g_drop_1.
WHEN 1 OR 2.
value-key = '1'.
value-text = 'text1'.
APPEND value TO list.
CLEAR value.
value-key = '2'.
value-text = 'text2'.
APPEND value TO list.
CLEAR value.
WHEN 3 OR 4.
value-key = '3'.
value-text = 'text3'.
APPEND value TO list.
CLEAR value.
value-key = '4'.
value-text = 'text4'.
APPEND value TO list.
CLEAR value.
ENDCASE.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDMODULE. " DROP_DOWN_2 OUTPUT</pre>
Thanks
Venkat.O</font>
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |