on 01-12-2009 11:28 AM
Hi,
I ahve a WDA application, with a view. This view has 4 fields, Order Type (AUART), Sales Org (VKORG), Distribution Channel and Division. On click of the button I would like to validate the data enetered by the user in these fields. I have created a node and the attributes in the view context.
In the onclick event of the button I have written the following code:
i_childnode = wd_context->get_child_node( 'SALES_INITIAL' ).
What code should I write further, to access the values entered by the user on the screen.
Any help would be greatly appreciated.
Thanks
MIck
Hi Mick,
this is the code to get values entered by user
data lo_el_context type ref to if_wd_context_element.
data ls_context type wd_this->element_context.
data lv_cb1 like ls_context-cb2.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
exporting
name = `CB2`
importing
value = lv_cb1 ).
you can get the same code by clicking on the button code wizard in your SAP..... (button with a yellow tourch like image).. just click on that button a screen will come in that screen select read context and using f4 help select your attribute and click on ok.... you will get the similar code with value in importing parameter.. here in my code value is in lv_cb1....
regards
Pranav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Pranav.
Using the wizard, the follwoing code was included in the method
data:
Node_Sales_Initial type ref to If_Wd_Context_Node,
Elem_Sales_Initial type ref to If_Wd_Context_Element,
Stru_Sales_Initial type Wd_This->Element_Sales_Initial ,
Item_AUART like Stru_Sales_Initial-AUART.
navigate from <CONTEXT> to <SALES_INITIAL> via lead selection
Node_Sales_Initial = wd_Context->get_Child_Node( Name = wd_This->wdctx_Sales_Initial ).
get element via lead selection
Elem_Sales_Initial = Node_Sales_Initial->get_Element( ).
get single attribute
Elem_Sales_Initial->get_Attribute(
exporting
Name = `AUART`
importing
Value = Item_Auart ).
In debug mode, the value in Item_Auart is 'TA', whereas the user input in the field on the screen was 'OR'.
What could be the reason for this? and how do we rectify this erroneous data?
Thanks
Mick
Hi Mick,
Yes you can get the whole data in an internal table of type that node and its fields are of type of attributes of that node
see the code below..
data lo_nd_cn_table type ref to if_wd_context_node.
data lo_el_cn_table type ref to if_wd_context_element.
data lt_table type wd_this->elements_cn_table.
data ls_table type wd_this->element_cn_table.
data index type i.
* navigate from <CONTEXT> to <CN_TABLE> via lead selection
lo_nd_cn_table = wd_context->get_child_node( name =
wd_this->wdctx_cn_table ).
* @TODO handle not set lead selection
if lo_nd_cn_table is initial.
endif.
* get element via lead selection
lo_el_cn_table = lo_nd_cn_table->get_element( ).
* @TODO handle not set lead selection
if lo_el_cn_table is initial.
endif.
* alternative access via index
* lo_el_cn_table = lo_nd_cn_table->get_element( index = 1 ).
* @TODO handle non existant child
* IF lo_el_cn_table IS INITIAL.
* ENDIF.
* get all declared attributes
lo_nd_cn_table->get_static_attributes_table(
importing
table = lt_table ).
now lt_table contains all the data in that node....
regards
Pranav
Hi Mick,
As far as I can understand, you have four input fields on your screen and you want to access the values entered by the user. Well to do that, you must have binded each input field with an attribute. Just read that context attribute with the help of code wizard and you will get the values entered by the user.
I hope it helps.
Regards
Arjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mike,
To Access value on entered in input box on view:
Click on web dynpro code wizard icon (Cntrl + F7)
Select Radio button Read Context
Select the context element / attribute you have binded to the text field
Automatic code will be generated to read the attribute
To Validate the field in the method:
Click on web dynpro code wizard icon (Cntrl + F7)
Select Radio Button: Generate Mesaage
Select Appropriate method as per your requirement eg REPORT_ERROR_MESSAGE
Also Exit from the code on error, to avoid further processing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.