‎2006 May 31 2:52 PM
Hi all,
My first post in the forum:-). i am an ABAP amateur and currently working on alvgrids.
My problem is that i need to validate an alvgrid from an external method i.e. using the cl_alv_changed_data_protocol because my handle_data_changed doesnt get triggered for certain changes in the grid(the grid is just made that way..complex requirement!).
i am posting the code of the validation method below:
METHOD validate_str_qualifs.
DATA:
ls_out TYPE /mrss/t_sqp_estr_out,
lt_str TYPE /mrss/t_sqp_estr_tab,
ls_prof_data LIKE LINE OF gt_prof_data,
lref_str_err TYPE REF TO cl_alv_changed_data_protocol,
ls_str TYPE /mrss/d_sqp_estr,
lv_count TYPE i,
lt_str_fcat TYPE lvc_t_fcat,
lt_roid_front TYPE lvc_t_roid,
ls_roid_front LIKE LINE OF lt_roid_front,
lv_rows TYPE i.
CREATE OBJECT lref_str_err
EXPORTING
i_calling_alv = gref_alv_str.
CALL METHOD me->get_str_fcat
IMPORTING
et_str_fcat = lt_str_fcat.
assign field catalog
lref_str_err->mt_fieldcatalog = lt_str_fcat.
Read structured quals from global employee data.
READ TABLE gt_prof_data INDEX 1 INTO ls_prof_data.
lt_str = ls_prof_data-str_qual-emp.
lv_count = 0.
DESCRIBE TABLE lt_str LINES lv_rows.
WHILE lv_count NE lv_rows.
lv_count = lv_count + 1.
ls_roid_front-row_id = lv_count.
append ls_roid_front to lt_roid_front.
ENDWHILE.
assign the rows table
lref_str_err->mt_roid_front = lt_roid_front.
lv_count = 0.
loop at the structured qualifications
LOOP AT lt_str INTO ls_str.
lv_count = lv_count + 1.
<b>* check if primary qualification is initial
IF ls_str-pri_qualif IS INITIAL.
ev_invalid = 'X'.
CALL METHOD lref_str_err->add_protocol_entry
EXPORTING
i_msgid = '/MRSS/SQU'
i_msgno = '008'
i_msgty = 'E'
i_fieldname = 'POSID_P_TEXT'
i_row_id = lv_count.
ENDIF.
check for ratings
IF ls_str-rating IS INITIAL.
ev_invalid = 'X'.
CALL METHOD lref_str_err->add_protocol_entry
EXPORTING
i_msgid = '/MRSS/SQU'
i_msgno = '009'
i_msgty = 'E'
i_fieldname = 'RATING_TEXT'
i_row_id = lv_count.
ENDIF.
ENDLOOP.
IF ev_invalid = 'X'.
show the protocol.
CALL METHOD lref_str_err->display_protocol.
ENDIF.</b>
CALL METHOD me->update_str_outtab.
CALL METHOD gref_alv_str->refresh_table_display.
My problem is the validations happen as i want them to and the protocol is also displayed, <b>but the erroneous cells in my grid dont get highlighted (red).</b>
Any words of wisdom from the ABAP gurus?
‎2006 May 31 3:03 PM
Hi manoj,
there are certain validation like date, time, currency, quantity , for those automatic error handling takes place. but for others you have to take care.anf for some fields they have check tables in that case you have to use this for that field in fieldcat
<b>ls_fcat-checktable = '!'.</b>
Regards
vijay
‎2006 May 31 3:31 PM
Hi Vijay,
thanks for your reply, but unfortunately that doesnt solve my problem:(. to further clarify the question, currently i am passing the fieldcatalog(mt_fieldcatalog) and also the rowid(mt_roid_front). do i need to pass anything else so that the cl_alv_changed_data_protocol class will highlight the cells from which dont have valid data.
‎2006 May 31 3:44 PM
‎2006 May 31 4:35 PM
Hi,
in the above example check this method..
method perform_semantic_checks.
data: ls_good type lvc_s_modi,
l_planetype type s_planetye,
l_seatsmax type s_seatsmax.
loop at pr_data_changed->mt_good_cells into ls_good.
case ls_good-fieldname.
when 'PLANETYPE'.
call method pr_data_changed->get_cell_value
exporting
i_row_id = ls_good-row_id
i_fieldname = ls_good-fieldname
importing
e_value = l_planetype.
select single seatsmax from saplane into l_seatsmax
where planetype = l_planetype.
if sy-subrc ne 0.
call method pr_data_changed->add_protocol_entry
exporting
i_msgid = '0K' i_msgno = '000' i_msgty = 'E'
i_msgv1 = text-m02
i_fieldname = ls_good-fieldname
i_row_id = ls_good-row_id.
error_in_data = 'X'.
else.
call method pr_data_changed->modify_cell
exporting i_row_id = ls_good-row_id
i_fieldname = 'SEATSMAX'
i_value = l_seatsmax.
endif.
endcase.
endloop.
endmethod.regards
vijay