on 05-25-2011 7:18 PM
Hi all,
I have a alv table with 2 fields. the 1st column is non editable and the 2nd column is a drop down. The value for the 1st column is already being displayed at the time of execution itself. I want a drop down in the 2 nd column which should hold values matching its corresponding row. I used a ONCLICK event and wrote the below code. But my drop down is still empty. When i debugged i found my ONCLICK event is not called.Can any one guide me what correct event i should use or if any changes i need to do in my code to solve this issue please.
DATA: LR_NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO,
LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_ND_ASSESSTMENT TYPE REF TO IF_WD_CONTEXT_NODE.
DATA: LT1_VALUESET TYPE TABLE OF WDR_CONTEXT_ATTR_VALUE,
LS1_VALUESET TYPE WDR_CONTEXT_ATTR_VALUE.
data : lt_weight type STANDARD TABLE OF zest_weight,
ls_weight like LINE OF lt_weight.
Data: context_node type ref to if_wd_context_node.
data: ld_element type ref to if_wd_context_element.
context_node = wd_context->get_child_node( name = 'ASSESSTMENT').
ld_element = context_node->get_lead_selection( ).
if not ld_element is INITIAL.
ld_element->get_static_attributes( IMPORTING
static_attributes = ls_weight ).
endif.
select * from zest_weight into table lt_weight where levels = ls_weight-activity.
LOOP AT LT_WEIGHT INTO LS_WEIGHT.
LS1_VALUESET-VALUE = LS_WEIGHT-ACTIVITY.
LS1_VALUESET-TEXT = LS_WEIGHT-ACTIVITY.
APPEND LS1_VALUESET TO LT1_VALUESET.
ENDLOOP.
LR_NODE = WD_CONTEXT->GET_CHILD_NODE( 'ASSESSTMENT' ).
LR_NODE_INFO = LR_NODE->GET_NODE_INFO( ).
LR_NODE_INFO->SET_ATTRIBUTE_VALUE_SET(
EXPORTING
NAME = 'ASSESSMENT'
VALUE_SET = LT1_VALUESET ).
Thanks in advance,
vadivu.
It is not clear what you are trying to do.
what you do to trigger onCLICK event ?. Do you have any Linkto Action/URL like that in any of the columns . If not you may have to explain your design how you want to trigger the round trip. You can consider on lead select or on enter of an input field etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi thanks for ur reply. I will tell you very simply. After executing my alv table the column for which i have set the drop down is empty. Once i click on the drop down can i make some action to tigger and generate the values for the drop down dynamically or suggest me some idea how to generate values for the drop down in a alv table dynamically. If so kindly suggest me how to do please.
HI vadiv_maha,
ON CLICK event will trigger when you perform any button action or when you click on url link..
In your case, you said you want to generate values in second column( drop down ) based on first column value...so better to use ONDATACHECK event. so based on first column value you can generate values in second column by writing the code in datacheck event.
Regards
Srinivas
Hi.,
In OnSelect event of Drop Down You set the values for the selected Key.
Check this Article [Drop Down in Table in WDA|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c03227f9-e48f-2c10-4bad-8ebdec704f3d?quicklink=index&overridelayout=true]
try like this for ALV too..
hope this helps u.,
Thanks & Regards,
Kiran
Hi Srinivas, i have one more doubt kindly clarify please. i wrote the code to generate the values for the drop down in the ondatacheck event. But how to call the ondatacheck event after i click on the alv column that have the drop down. I trie with some of the event handelrs its not working. Kindly suggest please.
Hi ...
Please go through the below link...
http://wiki.sdn.sap.com/wiki/display/Snippets/WebDynproABAP-ALVControllingStandard+Buttons
And.. if you dont mind, i stil have a confusion in your requirement...
please let me know clearly how exactly you want to display the values in alv... So that i can assist you in better way.
Regards
Srinivas
oh thank you srinivas. I will tell you clearly. I have an alv table 2 columns of which one column should be a drop down. While initializing the alv i am setting the values for the first column. Then my 2nd column which is a drop down is initially empty, I should generate values when i click on that drop down based on some condition. Is that made possible.
or can i generate values for the drop down with differnt values for each row, when the alv is initialized. Have you got wat i said.
Hi,
Create a Context attribute VALUESET in the node to which the ALV is bound.
Now when you read this node, FILL the VALUESET agianst each antry for the 1st time.
In the Column Settings, for that drop down column, create a dropdown by index and use the method to set the Valueset context attribute. there is a method SET_VALUESET_FIELDNAME in CL_SALV_WD_UIE_DROPDOWN_BY_IDX.
Regards,
Lekha.
Well, I don't know your application but here's how I'd do it if it was my application:
- Make a node A.
- Make an attribute A below node A.
- Make a node B below node A.
- Make several Attributes for drop-down-list below node B.
Make a component usage of ALV and externally map the entire node A to its DATA node.
Initialize ALV
Manipulate your context node which serves as table input for alv according to your conditions.
All this before the default plug is fired of course.
Maybe this is all rubbish for you because you built your application differently, but this way it'd be working I think..
regards, Lukas
Hi...
First get the number of elements in ALV by using get_element_Count into one variable say" totalcount"
then do "totalcount" time.
then write your code here, like...
if column1value = ....
do some... for column2 value.
end if.
enddo.
If you want to generate the second column values conditionally based on first row column.. then what is the purpose of going for dropdown.
Regards
Srinivas
Hi,
Value in the drop down cannot be filled by it's own event. I Guess MOdifyview gets triggered here, Have you checked DATACHECK or ONCELLACTION events of ALV when you try to click on the drop down.
As you are trying to popupate the dropdown rowwise, for ex As per the data in 1st col, if you are trying to fill dropdown. to some extent we can fill the dropdown.
Try to enable the CONTEXT CHANGE LOG for that dropdown context attribute or Entire node.
So that when there is a change, you can fill a dropdown. Check for MODIFYVIEW/ONDATACHECK/ONCELLACTION for these changes.
Regards,
Lekha.
Hi leka,
I tried with on_lead_select event of the alv. I am able to generate the drop down for the row which i select with its appropiate values.But the problem is the drop down for the rest of the rows are with the same values. what can i do to restrict the selection for a row. Please suggest. get back if u r not clear with the query. Kindly help.
Hi,
I got to know why the drop down has the same value for the entire column. That is i am referencing as a entire column(ASSESSTMENT) in my code. Is there any possiblity of getting the particular cell i am clicking on and set the value to that cell. If so my problem will be solved. Please kindly suggest
DATA: LR_NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO,
LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_ND_ASSESSTMENT TYPE REF TO IF_WD_CONTEXT_NODE.
DATA: LT1_VALUESET TYPE TABLE OF WDR_CONTEXT_ATTR_VALUE,
LS1_VALUESET TYPE WDR_CONTEXT_ATTR_VALUE.
DATA LR_DROPDOWN_KEY TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.
data : lt_weight type STANDARD TABLE OF zest_weight,
ls_weight like LINE OF lt_weight.
Data: context_node type ref to if_wd_context_node,
str type string.
*data: ld_element type ref to if_wd_context_element.
*
context_node = wd_context->get_child_node( name = 'ASSESSTMENT').
ld_element = context_node->get_lead_selection( ).
DATA lo_nd_assesstment TYPE REF TO if_wd_context_node.
DATA lo_el_assesstment TYPE REF TO if_wd_context_element.
DATA ls_assesstment TYPE wd_this->element_assesstment.
DATA lt_assesstment TYPE wd_this->elements_assesstment.
lo_nd_assesstment = wd_context->get_child_node( name = wd_this->wdctx_assesstment ).
lo_el_assesstment = lo_nd_assesstment->get_element( ).
lo_nd_assesstment->get_static_attributes(
EXPORTING
INDEX = R_PARAM->INDEX
IMPORTING
STATIC_ATTRIBUTES = ls_assesstment ).
*LOOP AT lt_assesstment into ls_assesstment.
select * from zest_weight into table lt_weight where levels = ls_assesstment-activity.
*ENDLOOP.
LOOP AT LT_WEIGHT INTO LS_WEIGHT.
LS1_VALUESET-VALUE = LS_WEIGHT-ACTIVITY.
LS1_VALUESET-TEXT = LS_WEIGHT-ACTIVITY.
APPEND LS1_VALUESET TO LT1_VALUESET.
ENDLOOP.
str = ls_assesstment-activity.
LR_NODE = WD_CONTEXT->GET_CHILD_NODE( 'ASSESSTMENT' ).
LR_NODE_INFO = LR_NODE->GET_NODE_INFO( ).
*LR_NODE->bind_table( LT1_VALUESET ).
LR_NODE_INFO->SET_ATTRIBUTE_VALUE_SET(
EXPORTING
NAME = 'ASSESSTMENT'
VALUE_SET = LT1_VALUESET ).
DATA : LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE ,
LR_COLUMN TYPE REF TO CL_SALV_WD_COLUMN,
L_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ASSESSTMENT_ALV( ).
LO_INTERFACECONTROLLER->SET_DATA(
R_NODE_DATA = LO_ND_ASSESSTMENT " ref to if_wd_context_node
).
L_VALUE = LO_INTERFACECONTROLLER->GET_MODEL( ).
CALL METHOD L_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN
EXPORTING
ID = 'ASSESSMENT'
RECEIVING
VALUE = LR_COLUMN.
CREATE OBJECT LR_DROPDOWN_KEY
EXPORTING
SELECTED_KEY_FIELDNAME = 'ASSESSMENT' .
CALL METHOD LR_COLUMN->SET_CELL_EDITOR
EXPORTING
VALUE = LR_DROPDOWN_KEY.
CALL METHOD L_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY
EXPORTING
VALUE = ABAP_FALSE.
Hi
For creating a dropdown having different entries for each row.
you need to create one extra attribute in you node with type "WDR_CONTEXT_ATTR_VALUE_LIST"
and then in the init method itself where you are filling the node for the first column.
there it self fill this attribute with the valueset having values specific to that particular element/row.
here is a sample code for the same.
which is having this functionality
DATA lo_nd_dealer TYPE REF TO if_wd_context_node.
DATA lo_el_dealer TYPE REF TO if_wd_context_element.
DATA ls_dealer TYPE wd_this->element_Zdealer.
DATA lv_name LIKE ls_dealer-name.
* navigate from <CONTEXT> to <DEALER> via lead selection
lo_nd_dealer = wd_context->get_child_node( name = wd_this->wdctx_Zdealer ).
DATA LS_DT TYPE WD_THIS->ELEMENT_ZDEALER.
DATA LT_DT TYPE WD_THIS->ELEMENTS_ZDEALER.
data ls_value_set TYPE wdr_context_attr_value.
data lt_value_set type wdr_context_attr_value_list.
" here you fill the table with required values
SELECT * FROM ZDEALER INTO CORRESPONDING FIELDS OF TABLE LT_DT.
DATA INDX TYPE I.
"now loop on the filled values and check the condition and fill the valueset for each row.
LOOP AT LT_DT INTO LS_DT.
INDX = SY-TABIX.
CLEAR LS_DT-LOCATION.
LV_NAME = LS_DT-NAME.
if( "have your condition here ).
CONDENSE lv_name.
ls_value_set-value = lv_name.
ls_value_set-text = lv_name.
append ls_value_set to LS_DT-VALUESET.
concatenate lv_name '- ' ' 1 ' into lv_name.
CONDENSE lv_name.
ls_value_set-value = lv_name.
ls_value_set-text = lv_name.
append ls_value_set to LS_DT-VALUESET.
"" like this fill the enteries
endif.
MODIFY LT_DT FROM LS_DT INDEX INDX TRANSPORTING LOCATION VALUESET.
" pass the valueset to table
endLOOP.
"bind the table to the node
lo_nd_dealer->BIND_TABLE( LT_DT ).
data lo_cmp_usage type ref to if_wd_component_usage.
"then the logic for making the field cell editor
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
lo_INTERFACECONTROLLER = wd_this->wd_cpifc_alv( ).
*lo_interfacecontroller->SET_DATA( lo_nd_dealer ).
DATA lo_value TYPE ref to cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model(
).
data col type ref to CL_SALV_WD_COLUMN.
col = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'LOCATION' ).
DATA DDB TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_IDX.
CREATE OBJECT DDB
EXPORTING SELECTED_KEY_FIELDNAME = 'LOCATION'.
DDB->SET_VALUESET_FIELDNAME( 'VALUESET' ).
DDB->SET_TYPE( IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>TYPE_KEY_CONVERT_TO_VALUE ) .
DATA CELEDI TYPE REF TO IF_SALV_WD_TABLE_CELL_EDITOR.
CELEDI ?= DDB.
*
COL->SET_CELL_EDITOR( CELEDI ).
LO_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( ABAP_FALSE ).
thanks
sarbjeet singh
Hi.,
Instead of
>
> LR_NODE_INFO->SET_ATTRIBUTE_VALUE_SET(
> EXPORTING
> NAME = 'ASSESSMENT'
> VALUE_SET = LT1_VALUESET ).
> .
try using bind_table.
LR_NODE->bind_table( LT1_VALUESET ).
hope this may helps u.,
Thanks & Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.