on 05-19-2011 11:13 AM
Hi All,
I want to display table with drop down value, i tried with dropdown by index but i am getting assertion error.
I tried with drop down by key.. it is giving output but no drop down displaying only text veiw. here is the code..
DATA : node_info TYPE REF TO if_wd_context_node_info,
value TYPE wdy_key_value,
set TYPE wdy_key_value_table.
data : it_objid type STANDARD TABLE OF if_main=>element_portal,
wa_objid like line of it_objid.
SELECT OBJID FROM HRP5007
INTO TABLE it_objid
WHERE "PLVAR = '01' and
ENDDA = '99991231' and
TFORM = '0017'.
loop at it_objid into wa_objid.
value-key = wa_objid.
value-value = wa_objid.
APPEND value to set.
endloop.
node_info = wd_context->get_node_info( ).
node_info = node_info->get_child_node( 'PORTAL' ).
node_info->set_attribute_value_set( name = 'DEALER_CODE' value_set = set ).
Thanks,
Venkat.
Hi.,
If you are using Drop Down By Key , u have to maintain domain value range., then it will automatically populate values in drop down.
check this article for drop down in table UI ,. [Drop Down in Table UI in WDA|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c03227f9-e48f-2c10-4bad-8ebdec704f3d?quicklink=index&overridelayout=true]
hope this 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.
Hi,
This is the way to set the value set..Please try with the following code.
Also you need to populate both 'value' and 'text' to the value set..As of now, you are populating only texts.
node = WD_CONTEXT->get_child_node( 'PORTAL2' ).
node_info = node->get_node_info().
node_info->set_attribute_value_set( name = 'DEALER_CODE'
value_set = lt_value_set ).
Thanks,
Aditya.
Hi Tahnks all,
Now i am using drop down by index and i am getting drop down with values, but problem is i am getting first row only.
drop down is displaying first row only. i want to display drop down for all rows.
Ca any body check this code and tell me where i am doing wrong..
DATA:
it_objid TYPE TABLE OF hrobjid,
wa_objid like LINE OF it_objid,
ls_portal1 TYPE wd_this->element_portal1,
lt_portal1 TYPE wd_this->elements_portal1,
lt_dropdown TYPE wd_this->elements_dropdown,
ls_dropdown TYPE wd_this->element_dropdown,
wd_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element.
DATA lo_nd_portal1 TYPE REF TO if_wd_context_node.
DATA lo_el_portal1 TYPE REF TO if_wd_context_element.
* DATA ls_portal1 TYPE wd_this->Element_portal1.
* navigate from <CONTEXT> to <PORTAL1> via lead selection
lo_nd_portal1 = wd_context->get_child_node( name = wd_this->wdctx_portal1 ).
DATA lo_nd_dropdown TYPE REF TO if_wd_context_node.
DATA lo_el_dropdown TYPE REF TO if_wd_context_element.
* DATA ls_dropdown TYPE wd_this->Element_dropdown.
* navigate from <CONTEXT> to <DROPDOWN> via lead selection
lo_nd_dropdown = wd_context->path_get_node( path = `PORTAL1.DROPDOWN` ).
SELECT OBJID FROM HRP5007
INTO TABLE it_objid
WHERE TFORM = '0017'.
DO 5 TIMES.
APPEND ls_portal1 TO lt_portal1.
ENDDO.
lo_nd_portal1->bind_table( new_items = lt_portal1
set_initial_elements = abap_true ).
LOOP AT it_objid INTO ls_dropdown-dealer_code.
APPEND ls_dropdown TO lt_dropdown.
CLEAR ls_dropdown.
ENDLOOP.
lr_element = lo_nd_portal1->get_element( ).
* navigate from <CONTEXT> to <DROPDOWN> via lead selection
lo_nd_dropdown = wd_context->path_get_node( path = `PORTAL1.DROPDOWN` ).
lo_nd_dropdown->bind_table( new_items = lt_dropdown
set_initial_elements = abap_true ).
thanks,
Venkat.
Hi Aditya,
I am not getting what you saying. I have a node I have a node portal1 under this i created another node drop down it contains one element objid.
And you can check code above i am using. can you tell me which node contains one element only?? suppose i want to display drop down for all rows what should i do?
Thanks,
Venkat.
Hi ,
Make sure that your node "PORTAL1" has cardinality 0:n or 1:n and make sure that you fill more than one elements.Hence you will get more than 1 rows.
In the code you had posted before, you had filled the node 'PORTAL1.DROPDOWN' with elements, hence you get values in the dropdown.
Similarly, make sure that you fill elements in the node PORTAL1 also, so that you will get rows also.
Thanks,
Aditya.
Hi Aditya,
I am thinking may be binding problem.
I am giving cardinality for both nodes 0-n and 0-1.
Main node - PORTAL1 - it contains 5 fields, i created another node name DROPDOWN in that i have two fields 1 DEALER_CODE AND KEY.
i done binding PORTAL1 to main TABLE which i am using in veiw, and in the table one field i am using as drop down and it is binding to DROPDOWN nodes atrribute DEALER CODE .. Am i done correctly???
Thanks,
Venkat.
Yes,
Looks fine..Just make sure that you fill elements to node PORTAL1.
And don't get confused with attributes and elements.
PORTAL1 had 5 attributes ( This is what I get by reading your post).
DROPDOWN has 2 attributes and elements (You have added elements from the code you posted above).
Thanks,
Aditya.
Hi ,
I think, you are populating the 'DROPDOWN' only for single element of 'PORTAL1'.
Try somthing like this.Here I populate the 'DROPDOWN' for all elements of 'PORTAL1'.
data lt_elem type ref to WDR_CONTEXT_ELEMENT_SET.
data ls_elem like line of lt_elem.
LOOP AT it_objid INTO ls_dropdown-dealer_code.
APPEND ls_dropdown TO lt_dropdown.
CLEAR ls_dropdown.
ENDLOOP.
lt_elem = lo_nd_portal1->GET_ALL_ELEMENTS( ).
LOOP AT lt_elem into ls_elem.
lo_nd_dropdown = ls_elem->GET_CHILD_NODE( name = 'DROPDOWN').
lo_nd_dropdown->bind_table( new_items = lt_dropdown
set_initial_elements = abap_true ).
CLEAR ls_elem.
CLEAR lo_nd_dropdown.
ENDLOOP.
Sorry , I had missed the error earlier.
Write the above code after you populate 'PORTAL1'...i,e
DO 5 TIMES.
APPEND ls_portal1 TO lt_portal1.
ENDDO.
lo_nd_portal1->bind_table( new_items = lt_portal1
set_initial_elements = abap_true ).
Thanks,
aditya.
Hi Aditya,
Again i am getting some issue in this..
In Table i am adding one button, when i click this button i am adding 1 row. I written above code in on action of add button.
first time it is working fine, when i click on this button for second row adding second row also but in first row drop down values are repeating. ( Actaul drop contains 3 values first time when i click second time 6 records are coming in first row drop down and 3 records in second row drop down, if i click 3rd time 1st row drop down with 9 records 2nd with 6 and 3rd with 3... and so on...
I tried by clearing various places but i am not getting.. any idea in this..
thanks,
Venkat.
Hi,
Pleae check this code..
DATA: it_objid TYPE TABLE OF HROBJID,
wa_objid like LINE OF it_objid,
ls_portal1 TYPE wd_this->element_portal1,
lt_portal1 TYPE wd_this->elements_portal1,
lt_dropdown_bet TYPE wd_this->elements_DROPDOWN_BET,
ls_dropdown_bet TYPE wd_this->element_DROPDOWN_BET,
wd_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element.
DATA lo_nd_portal1 TYPE REF TO if_wd_context_node.
DATA lo_el_portal1 TYPE REF TO if_wd_context_element.
DATA lo_nd_dropdown_bet TYPE REF TO if_wd_context_node.
DATA lo_el_dropdown_bet TYPE REF TO if_wd_context_element.
ls_portal1-DEALER_CODE = sy-uname.
CLEAR it_objid.
SELECT objid FROM HRP5007
INTO TABLE it_objid
WHERE TFORM = '0017'.
DO 1 TIMES.
APPEND ls_portal1 TO lt_portal1.
ENDDO.
* navigate from <CONTEXT> to <PORTAL1> via lead selection
lo_nd_portal1 = wd_context->get_child_node( name =
wd_this->wdctx_portal1 ).
lo_nd_portal1->bind_structure( new_item = ls_portal1
set_initial_elements = abap_false ).
data : lt_elem type WDR_CONTEXT_ELEMENT_SET,
ls_elem like LINE OF lt_elem.
LOOP AT it_objid INTO ls_dropdown_bet-BET.
APPEND ls_dropdown_bet TO lt_dropdown_bet.
ENDLOOP.
lt_elem = lo_nd_portal1->GET_ELEMENTS( ).
LOOP AT lt_elem into ls_elem.
lo_nd_dropdown_bet = ls_elem->GET_CHILD_NODE( name = 'DROPDOWN_BET').
lo_nd_dropdown_bet->bind_table( new_items = lt_dropdown_bet
set_initial_elements = abap_false ).
CLEAR ls_elem.
CLEAR lo_nd_dropdown_bet.
* CLEAR lt_dropdown_bet.
ENDLOOP.
Thanks,
Venkat.
HI,
Instead of using get_elements,
Work on obtaining the element that you added recently by using index(maximum value).
DATA count type I.
count = lo_nd_portal1->get_element_count( ).
lo_el_portal1 = lo_nd_portal1->get_element( index = count ).
Once you get the element, use it and write the following kind of code..
lo_nd_dropdown_bet = lo_el_portal1->GET_CHILD_NODE( name = 'DROPDOWN_BET').
lo_nd_dropdown_bet->bind_table( new_items = lt_dropdown_bet
set_initial_elements = abap_false ).
Try with this kind of coding after you add a new element.
Thanks,
Aditya.
open
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes Venkat,
We can assign dynamic values to Dropdown by key using Value SET concept.
Please check did you the bind the DEALER_CODE attribute to Drop Down by key.
And In some part of coding , you did mistake, i wl get back to u soon with proper coding. And are you sure the declaration of Value and Set are correct types?
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 Srinivas,
Declarations are correct. i created node with 0-n and 0-1 cardinality. and binded properly.
I changed code now please check...
data: lt_value_set type table of wdr_context_attr_value,
ls_value_set type wdr_context_attr_value.
data: node type ref to if_wd_context_node,
node_info type ref to if_wd_context_node_info.
data : it_objid type STANDARD TABLE OF if_main=>element_portal,
wa_objid like line of it_objid.
SELECT OBJID FROM HRP5007
INTO TABLE it_objid
WHERE TFORM = '0017'.
loop at it_objid into wa_objid.
ls_value_set-text = wa_objid.
append ls_value_set to lt_value_set.
endloop.
node_info = wd_context->get_node_info( ).
node_info = node_info->get_child_node( 'PORTAL2' ).
node_info->set_attribute_value_set( name = 'DEALER_CODE'
value_set = lt_value_set ).
Still same problem..
thanks,
Venkat.
Aswin,
Try with the below declaration.
data: lt_value_set type wdr_context_attr_value_set,
ls_value_set type wdr_context_attr_value.
if you still the face the issue.. I wil get you later with proper coding.
I think problem will be in
node_info = wd_context->get_node_info( ).
node_info = node_info->get_child_node( 'PORTAL2' ).
or
data: lt_value_set type table of wdr_context_attr_value,
ls_value_set type wdr_context_attr_value.
Anyhow , i wl get back to you later.
Regards
Srinivas
aswin,
As I promised u,
i made a minor modification and use below code and let me know and this is for dropdown by key.
i have just changed the lt_value_set reference.
data: lt_value_set type if wdr_context_attr_value_list,
ls_value_set type wdr_context_attr_value.
data: node type ref to if_wd_context_node,
node_info type ref to if_wd_context_node_info.
node_info = wd_context->get_node_info( ).
node_info = node_info->get_child_node( 'PORTAL2' ).
data : it_objid type STANDARD TABLE OF if_main=>element_portal,
wa_objid like line of it_objid.
SELECT OBJID FROM HRP5007
INTO TABLE it_objid
WHERE TFORM = '0017'.
loop at it_objid into wa_objid.
ls_value_set-text = wa_objid.
append ls_value_set to lt_value_set.
endloop.
node_info->set_attribute_value_set( name = 'DEALER_CODE'
value_set = lt_value_set ).
Regards
Srinivas
Firstly,
node_info = wd_context->get_node_info( ).
node_info = node_info->get_child_node( 'PORTAL' ).
Ur using the same node info reference to first get the context and the child node. Instead directly refer through context, something like this:
node_info = wd_context->get_child_node( 'PORTAL' ).
Next: node_info->set_attribute_value_set( name = 'DEALER_CODE' value_set = set ). Try this by creating element first.
The other way to this is, populate an internal table and use the BIND_TABLE method as well to create the dropdown.
Use the Code Wizard to generate code.
Regards,
Santosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.