on 08-14-2007 12:59 PM
I have a table input field.which is populataed though a node input_table which has a sub node DROPDOWN the drop down is populated by supplyfunction. I am biniding 4 empty work_area to the main node so that it allows me 4 rows for input.
Now, my problem is that i have to set a attribute in main node when user selects some thing from dropdown.For first row i am able to set. But for rest of the rows the value is not set.
I found that, if i manually selects the lead selection for the table before selesting dropdown for each row it works fine.
Do u have any idea how to over come from this ?Points will be rewarded.
Thanks,
Prosun
Hi.
in the onselect action of the dropdown get the elemnt thru the input parameter wdevent:
lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
this is the current row of the table the dropdown is in.
Cheers,
Sascha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sascha ,
thanks for your reply.Can you explain a little more ? I have a node called input_table ,under which the subnode dropdown. When anything selected from dropdown i have to set a value in the input_table node. I tried your code it is giving me"Access via 'NULL' object reference not possible" please help me , i need it very urgently.
Thanks
Prosun
You cannot and should not delete it. Anzy has said that if it is NOT there, then it will not work.
Check if you have defined an action for the onSelect event of the drop down. In that event handler, use the code
lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
This will return you the selected element. Then you need to do a get_static_attributes to get the values in that particular row. Then look for your attribute that is bound to the drop down.
Where are you getting the null pointer exception? Which object is initial that is triggering the error? Can you debug and check this?
Regards
Nithya
I have node
Input_table(Node)
-
Dropdpwn(node)
-
Lgart(att)
-
Lgtxt
-
Lgart
and so on.
Now i have to read lgart from dropdown node and to set it in lgart of input_table node.
When i dedug with lr_element = wdevent->get_context_element( 'Lgart') lr_element is initial.Please tell where i am wrong. Can u write the code for me.
METHOD ONACTIONSHOWDESC .
DATA:
NODE_PAYDEDUCT318CTXT TYPE REF TO IF_WD_CONTEXT_NODE,
NODE_INPUT_TABLE TYPE REF TO IF_WD_CONTEXT_NODE,
NODE_DROPDOWN TYPE REF TO IF_WD_CONTEXT_NODE,
ELEM_DROPDOWN TYPE REF TO IF_WD_CONTEXT_ELEMENT,
STRU_DROPDOWN TYPE WD_THIS->ELEMENT_DROPDOWN ,
lr_element TYPE REF TO IF_WD_CONTEXT_ELEMENT,
ITEM_LGTXT LIKE STRU_DROPDOWN-LGTXT,
ITEM_LGART LIKE STRU_DROPDOWN-LGART.
navigate from <CONTEXT> to <PAYDEDUCT318CTXT> via lead selection
NODE_PAYDEDUCT318CTXT = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_PAYDEDUCT318CTXT ).
navigate from <PAYDEDUCT318CTXT> to <INPUT_TABLE> via lead selection
NODE_INPUT_TABLE = NODE_PAYDEDUCT318CTXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_INPUT_TABLE ).
@TODO handle not set lead selection
IF ( NODE_INPUT_TABLE IS INITIAL ).
ENDIF.
navigate from <INPUT_TABLE> to <DROPDOWN> via lead selection
NODE_DROPDOWN = NODE_INPUT_TABLE->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_DROPDOWN ).
get element via lead selection
ELEM_DROPDOWN = NODE_DROPDOWN->GET_ELEMENT( ).
get single attribute
ELEM_DROPDOWN->GET_ATTRIBUTE(
EXPORTING
NAME = `LGART`
IMPORTING
VALUE = ITEM_LGART ).
get single attribute
ELEM_DROPDOWN->GET_ATTRIBUTE(
EXPORTING
NAME = `LGTXT`
IMPORTING
VALUE = ITEM_LGTXT ).
******Set back in node***********************************
lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
CALL METHOD LR_ELEMENT->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_LGART
NAME = `LGART`.
CALL METHOD LR_ELEMENT->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_LGTXT
NAME = `TEXT`.
*************************************************************************************************
ENDMETHOD.
Please help me. I am populating drop down by supply function.Please give me the code, if u have any.I am using dropdown by index.
Message was edited by:
Prosun Bondopadhyay
Where are you having this code? Is it in the onSelect event of your drop down?
After the get_context_element and before the set_attribute, insert the following code:
lr_element->get_static_attributes(
importing
static_attributes = stru_dropdown ).
ITEM_LGTXT = STRU_DROPDOWN-LGTXT.
ITEM_LGART = STRU_DROPDOWN-LGART.
Then do set_attribute and you will get the values from the selected row.
Regards
Nithya
hehehe I know the problem.
You used the wizard to navigate to the lead selection of the drop down, but the lead selection of the table may be set to another row and you get the wrong row with different drop down.
use lr_elemnt->get_child_node( 'DROPDOWN' ). to get the subnode and then use this node to get the lead selection:
lr_node = lr_element->get_child_node( 'DROPDOWN' ).
lr_node->get_element( ) = the selected element in the dropdown.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
thanks for your kind reply.
Now my code looks like---
lr_node = lr_element->get_child_node( 'DROPDOWN' ).
CALL METHOD LR_NODE->GET_ELEMENT
EXPORTING
INDEX = USE_LEAD_SELECTION
RECEIVING
NODE_ELEMENT =
.
But how to get the value of ''LGART" ?Please help as u know the problem. plzzzz.........zzz.............
data:
lr_dropdown_node type ref to if_wd_context_node,
lr_dropdown_element type ref to if wd_context_element,
lr_element type ref to if_wd_context_element.
data: STRU_DROPDOWN TYPE WD_THIS->ELEMENT_DROPDOWN.
lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
lr_dropdown_node = lr_element->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_DROPDOWN ).
lr_dropdown_element = lr_dropdown_node->get_element( ).
lr_dropdown_element->get_static_attributes(
importing
static_attributes = stru_dropdown
).
lr_element->set_attribute(
name = 'LGART'
value = stru_dropdown-lgart
).
...
Hope this helps,
Sascha
Message was edited by:
Sascha Dingeldey
Thank u very very much. I written
DATA:
lr_element TYPE REF TO IF_WD_CONTEXT_ELEMENT,
lr_node TYPE REF TO IF_WD_CONTEXT_NODE,
STRU_DROPDOWN TYPE WD_THIS->ELEMENT_DROPDOWN ,
ITEM_LGART LIKE STRU_DROPDOWN-LGART,
ITEM_LGTXT LIKE STRU_DROPDOWN-LGTXT.
************************************************Testing today***********************************
lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
lr_node = lr_element->get_child_node( 'DROPDOWN' ).
CALL METHOD LR_NODE->GET_ATTRIBUTE
EXPORTING
INDEX = USE_LEAD_SELECTION
NAME = 'LGART'
IMPORTING
VALUE = ITEM_LGART
.
CALL METHOD LR_NODE->GET_ATTRIBUTE
EXPORTING
INDEX = USE_LEAD_SELECTION
NAME = 'LGTXT'
IMPORTING
VALUE = ITEM_LGTXT.
CALL METHOD LR_ELEMENT->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_LGART
NAME = `LGART`.
CALL METHOD LR_ELEMENT->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_LGTXT
NAME = `TEXT`.
It is working fine.
Now , one thing..
I HAVE TO GIVE U POINTS but IT IS not showing me that , though i posted it. Please tell me the way so that i can give you point.
One more thing--- Do u have any idea if i want to show some particular value in dropdow when loading (ininitially selected value, suppose from values 1,2,3,..I want the first selected value will be 2) what is the way to do that.
Hi Prosun.
You are not able to give points because you did not mark this thread as question.
To preselect an entry in the dropdown you can use set_lead_selection or set_lead_selection_index on the node containing the elements for the dropdown.
You can do it in the supply method. I guess you want to select the correct entry regarding to an already existing row in the table?
So you can use parent_element in the supply method to retrieve the attributes from the row. Then after adding all selection values to the dropdown node set the lead selection according to lgart.
Hope this helps,
Sascha
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
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.