on 10-29-2008 8:46 AM
Hi all,
I've implemented an editable ALV and also the ON_DATA_CHECK event to check the values, entered in the ALV. So this works fine and I can check the values.
But now, I want to throw an error message corresponding to the field in the ALV, where the error occured.
How can I throw this error message corresponding to a specific line/field in the ALV?
I was using REPORT_ATTRIBUTE_ERROR_MESSAGE and REPORT_ELEMENT_ERROR_MESSAGE but without success.
I'm also using a loop over the "CHANGES" in the ALV and within this loop, I use
elem_alv = node_alv->get_element( index = <change>-element_index )
to get the element for the message.
CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'my message'
ELEMENT = elem_alv
* ATTRIBUTES =
* PARAMS =
* MSG_USER_DATA =
* IS_PERMANENT = ABAP_FALSE
* SCOPE_PERMANENT_MSG = CO_MSG_SCOPE_CTXT_ELEMENT
* MSG_INDEX =
* CANCEL_NAVIGATION =
* IS_VALIDATION_INDEPENDENT = ABAP_FALSE.
.
2.) is it right, that for an editable ALV, I can't use the WDDOBEFOREACTION to do the checks?
If I try to use this, I can't get the values of my ALV table to check it.
Thanks,
Andreas
it's not an error in the application!
I want to do the same as described in this thread
But this does not work. No message is displayed in my message area.
I used REPORT_ATTRIBUTE_ERROR_MESSAGE in the ON_DATA_CHECK, but I've got no error message.
(...)
node_time_table = wd_context->get_child_node( name = wd_this->wdctx_time_table ).
loop at r_param->t_modified_cells into ls_modified_cells.
elem_time_table = node_time_table->get_element( index = ls_modified_cells-index ).
if ls_modified_cells-attribute = '/BIC/KFCHOUWO'.
*TODO if-statement for field check
* report message
CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'my message'
ELEMENT = elem_time_table
ATTRIBUTE_NAME = ls_modified_cells-attribute
.
l_has_errors = abap_true.
endif.
endloop.
check l_has_errors is initial.
Could maybe someone give me a code example.
Many thanks in advance.
Andreas
Edited by: Andreas Leis on Nov 12, 2008 11:11 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andreas,
I have tried to replicate your problem and I am getting the desired output. I have a row by name TEMP_NEW in my ALV and I want to throw an error message whenever the user enters a value of 4 for that particular field. Please find my coding as below. The important thing is where we perform the actual comparison between the r_value and 4. r_value is defined in SALV_WD_S_TABLE_MOD_CELL as reference to type DATA. So suppose the user enters a value of say 3 in the TEMP_NEW field of the ALV then r_value would contain 3 but if you observe its type in debugging mode it would be as TYPE REF TO I and not TYPE I. So you cannot directly say something like:
"if ls_modified_cells-r_value = 3" as this would lead to a syntax error. Define a field-symbol say <temp> and then use it to get the actual value into it by saying like:
ASSIGN ls_modified_cells-r_value->* TO <temp>.
Then you can use this <temp> for comparison in your IF statement like:
IF <temp> = 3.
Find the entire coding as below:
METHOD check_data.
DATA: lr_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
ls_modified_cells TYPE salv_wd_s_table_mod_cell.
FIELD-SYMBOLS <temp> TYPE data.
" get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
lr_node = wd_context->get_child_node( name = 'NODE' ).
LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
lr_element = lr_node->get_element( index = ls_modified_cells-index ).
IF ls_modified_cells-attribute = 'TEMP_NEW'.
" Get the value extracted into the field symbol from the reference variable
ASSIGN ls_modified_cells-r_value->* TO <temp>.
" Use the value present in this field-symbol for your comparison
IF <temp> = 4.
" report message
CALL METHOD lo_message_manager->report_attribute_error_message
EXPORTING
message_text = 'Sample message text'
element = lr_element
attribute_name = ls_modified_cells-attribute.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
Hope this helps resolve your problem.
Regards,
Uday
I've found the problem!
If I'm using a sort for a column in the WDDOINIT method, the output of the message will not work.
data: lr_field type ref to cl_salv_wd_field.
lr_field = lo_value->if_salv_wd_field_settings~get_field( '/BIC/MFCTIMEFR' ).
lr_field->if_salv_wd_sort~create_sort_rule( sort_order =
if_salv_wd_c_sort=>sort_order_ascending ).
Similar problem I've got if I'm using an aggregate function on the column.
lr_field = lo_value->if_salv_wd_field_settings~get_field( '/BIC/KFCHOUWO' ).
lr_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =
if_salv_wd_c_aggregation=>aggrtype_total ).
This will lead to an runtime exception.
Regards,
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
the data type is DEC5 with 2 decimals (Domain DB2DEC5_2)
I tried the check also with an other column with data type CHAR1 (X or blank) and got no message.
So it seems not to be the data type.
Meantime, I finished my other alv example in here it works!
So now I will check my other application and try to find my error...
Thanks again!!!
Regards,
Andreas
Edited by: Andreas Leis on Nov 13, 2008 1:23 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
ok, thanks!
I'm using the same event method ON_DATA_CHECK and within the debugger I can see, that this method is processed and the message is called... So at the moment, I don't know what my problem is.
I will start from the scratch with a new ALV example and try to found out what the different is to my existing solution. If I found my problem, I will let you know it...
Regards,
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
many thanks for your coding and the tips!
I'm still trying to implement it in my ALV and I still get no error message.
I have some further questions to your method "check_data".
When is this method called in your ALV?
Is this method bound to the event "ON_DATA_CHECK" or to a button?
Have you used something in the init method like
data lo_value type ref to cl_salv_wd_config_table.
lo_value->if_salv_wd_table_settings~set_data_check( '01' ).
Thanks again!
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andreas,
I am not using any coding of the sort you had used in your WDDOINIT method.
I have created the method CHECK_DATA as an event handler method for the event ON_DATA_CHECK. So this method gets called automatically whenever the event ON_DATA_CHECK is triggered. But this event is triggered by the system only when it finds that some data has changed within the ALV.
Within the WDDOAFTERACTION method am just calling the standard DATA_CHECK method of iwci_salv_wd_table which checks if the data has changed within the ALV. If yes then it does trigger the ON_DATA_CHECK event which in return does call our eventhandler method CHECK_DATA. (Sorry just realized that the naming convention I have used for my eventhandler method has made it sound a bit too confusing!)
method WDDOAFTERACTION .
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_interfacecontroller->data_check( ).
endmethod.
Hope this would help address your problem.
Regards,
Uday
Thanks, Ricky!
I hope someone can give me an answer how to throw an error message to a specific field in an alv table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
You can't use WDDOBEFOREACTION to do the checks...for the same.
You can use the same code after that one...
Regards
Ricky
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
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.