on 04-13-2009 10:27 AM
Hi All,
I am new to this ABAP webdynpro programming. I have a small question. I am using a table control in one of my iview. I need to check some validations on some columns of this table. Let's say I have a table with 3 columns A,B and C.
Case 1 : Whenever any user enters values in C which is greater than A i want to raise an error message saying "The Value is greater than A". The user shouldn't be allowed to enter anyother inputs before correcting the same.
OR
Case 2: If the user enters 10 rows in the table and the 5th row contains the error. How can i highlight that row or field which contains the error.
Your inputs will be valuable to me.
Regards,
Pravesh.
tthanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Get the elements of the node for which you table is bound.
Loop through the context element set.
get the record for that context attribute and check the column A and column B value and throw
the error using the report_error_element_message when there is error.
Check this sample code -
DATA:
lt_attr_list type STRING_TABLE,
ls_attr_list type string.
ls_attr_list = column name.
append ls_attr_list to lt_attr_list.
clear ls_attr_list.
ls_attr_list = column name.
append ls_attr_list to lt_attr_list.
clear ls_attr_list.
DATA: lit_elementset type WDR_CONTEXT_ELEMENT_SET,
lis_element type ref to IF_WD_CONTEXT_ELEMENT,
ls_data type <<strucure type>>.
CALL METHOD <<nodename>>->GET_ELEMENTS
RECEIVING
SET = lit_elementset.
LOOP AT lit_elementsetINTO lis_element.
lis_element->get_static_atributes->
importing = ls_data.
if ls_data-columnC GT ls-data-columnA.
lr_msg_manager->report_element_error_message->
message_text = 'Column C canot be gretaer than column A'
element = lis_element
attributes = lt_attr_list <<Populate the attributes table for which errors are to be shown>>
endif.
clear: ls_data, lis_element.
ENDLOOP.
Regards,
Lekha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lekha,
I understood what you are trying to say. But I am not sure where to write this peice of code. I need to create one event for the same where i should write this code or any other standard event that checks automatically whenver the user enters input values to these fields.
My requirement is to check these validations on screen itself whenever the user enters values in field C.
How can I acheive the same ?
Or if you help me in how I can highlight the row which has this error, it would be great.
Regards,
Pravesh.
Hi Pravesh,
You must be using Input field in the table where the user the enter the values. Input field has an event i.e ONENTER event, you can use the code code provided by Lekha in the code. So now whenever user hits enter after inserting the value in the column, that event will be called and it'll validate the value entered by the user.
I hope it helps.
Regards
Arjun
Hi,
Report_element_error_message will highlight the error for that cell.
As you are using the table control, you can write the code in these table events or any button of your choice.
onColSelect
onDrop
onFilter
onLeadSelect
onScroll
onSelect
onSort
Or in the table column event ONACTION.
I think there is no OnENTER event for the table control. Please check out it once
Regards,
Lekha.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
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.