on 07-14-2011 1:48 PM
Hi Guys,
I need to provide drop down in an ALV based on data in other calumn in same row.
if i have two calumns country and region in my alv then drop down values for region should come depending upon country value.
i went through lot of blogs and forum threads but none seems to solve my problem.
I'm able to achieve this in Table but not in ALV. I'm using DropdownbyIndex Ui element.
Thanks for inputs but I found the Solution myself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello zjason,
could you share the information about when are you populating the context node for DDBI ( Drop Down by Index )? Is it done after entering the country and hitting enter? and also if possible post your context node structure.
BR, Saravanan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jason,
First column can be dropdown key and take second column dropdown by key
First give some dropdown values to 1st dropdown key by hardcoding in below way
DATA: NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO.
NODE_INFO = WD_CONTEXT->GET_NODE_INFO( ).
NODE_INFO = NODE_INFO->GET_CHILD_NODE('COUNTRYNODE).
DATA: LT_VALUESET TYPE WDR_CONTEXT_ATTR_VALUE_LIST,
L_VALUE TYPE WDR_CONTEXT_ATTR_VALUE.
L_VALUE-VALUE = 'IN'.
L_VALUE-TEXT = ' INIDA'.
INSERT L_VALUE INTO TABLE LT_VALUESET.
L_VALUE-VALUE = 'US'.
L_VALUE-TEXT = 'UNITED STATES OF AMERICA'.
INSERT L_VALUE INTO TABLE LT_VALUESET.
NODE_INFO->SET_ATTRIBUTE_VALUE_SET( NAME = 'COUNTRY ATTRIBUTE' VALUE_SET = LT_VALUESET ).
Now in onselect action of 1st dropdown,
write the code to fetch the region values in second dropdown.
in that action first get the slected country value
LO_EL_ncoountrynode->GET_ATTRIBUTE(
EXPORTING
NAME = `AVISIBLE`
importing
VALUE = var1' ).
NOW FETCH THE REGION VALUES FROM STANDARD TABLE USING SELECT QUERY USING WHERE CONDITION COUNTRY = VAR1.
now bind those result values to second dropdown by key. if you have problem in binding values to second dropdown , let me know
Regards
srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi let me clearify things once more.my alv data is coming form node alv having two attributes country and region, i need to provide dropdown only on region field, there is no dropdown for country field. in eah row region drop down should give values
based on the value held by country field in that row.
i am able to achieve that using a table ui element, but i need the same funtionality in an ALV.
To achieve this requirment via Table UI i went through this demo DEMO_VARIABLE_DROPDOWN available in our system.
Hello Zjason,
the concept of DDBI in ALV is bit different than the standard table. you need to create an attribute in the context node of type WDR_CONTEXT_ATTR_VALUE_LIST and same attribute needs to be bound to the DDBI in ALV as valueset. Have a look at the following example.
[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0cbdde3-fe58-2c10-fcbc-8db18e693877?quicklink=index&overridelayout=true]
so for your usecase, whenever the user enters Country you need to populate this attribute dynamically in the DATA_CHECK event handler.
Hope this solves your problem.
BR, Saravanan
I had alredy folloed that article, i am able to get the dropdown in my ALV but all the values in Drop Down are coming blank.
you can take a look at this thread , my requirement and the problem i am facing is very same. i have alredy creted my node in component controller and mapped it in my view. Still i get blank values in my Dropdown.
Hi Guys finally i am able to get my dropdown data visible.
I am posting the code here so that others can make use of it.
In your context node add an attribute type WDR_CONTEXT_ATTR_VALUE_LIST
after getting data into your context node table fill the above attribute as shown in the below code
LOOP AT lt_mara INTO ls_mara.
clear: lv_indx.
lv_indx = sy-tabix.
clear ls_valueset.
*refresh: lt_valueset.
ls_valueset-value = ls_mara-mtart.
ls_valueset-text = ls_mara-mtart.
APPEND ls_valueset to ls_mara-valueset.
clear ls_valueset.
*ls_valueset-text = ls_mara-matnr.
APPEND ls_valueset to ls_mara-valueset.
*lr_element = lo_nd_mara->get_element( lv_indx ).
*lr_child_node = lr_element->get_child_node( 'DDVALUE' ).
*lr_child_node->bind_table( lt_valueset ).
MODIFY lt_mara FROM ls_mara INDEX lv_indx.
CLEAR ls_mara.
ENDLOOP. lo_nd_mara->bind_table( lt_mara ).
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
*---set data
lo_interfacecontroller->set_data( r_node_data = lo_nd_mara ).
DATA lv_value TYPE REF TO cl_salv_wd_config_table.
lv_value = lo_interfacecontroller->get_model(
).
*----dropdown logic
data: lr_col type ref to CL_SALV_WD_COLUMN,
lr_ddn type ref to cl_salv_wd_uie_dropdown_by_idx.
CALL METHOD lv_value->if_salv_wd_column_settings~get_column
EXPORTING
id = 'MTART'
receiving
value = lr_col
.
*lr_ddn ?= lr_col->get_cell_editor( ).
CREATE OBJECT lr_ddn
EXPORTING
selected_key_fieldname = 'MTART'
.
CALL METHOD lr_ddn->set_valueset_fieldname
EXPORTING
value = 'VALUESET'
.
lr_ddn->set_selected_key_fieldname( value = 'MTART' ).
CALL METHOD lr_ddn->set_type
EXPORTING
value = IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>type_key_value
.
CALL METHOD lr_col->set_cell_editor
EXPORTING
value = lr_ddn
.
lv_value->if_salv_wd_table_settings~set_read_only( abap_false ).
Just follow the above code you will be able to achieve dropdown by index in your alv.
HI,
For one column use Dropdownbykey and for the other column use drop down by index.
Below link explains on how to use Dropdown by index in a detailed manner.
[Dropdown by index in ALV|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d0cbdde3-fe58-2c10-fcbc-8db18e693877]
Regards,
madhu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I Followed this Article posted in SDN http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/50d4f5b6-fd1b-2e10-3190-823bcaff92d7 , now drop down is coming but as blant i can't see the values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.