OO ALV: How to realize red box positioning of field error

On the ALV page, some custom fields need to report errors during verification, and the red box is located to the error field. For the error reported in the red box, class CL_ GUI_ ALV_ Set in Grid_ ERROR_ The cells method can be implemented, however, this method is protected, so the implementation needs to be rewritten in the program.

Specific implementation:

1. Rewrite set_ERROR_Cells method

Definition.

1 CLASS lcl_gui_alv_grid DEFINITION INHERITING FROM cl_gui_alv_grid.
2 
3     PUBLIC SECTION.
4         METHODS:
5             m_set_error_cells IMPORTING it_err TYPE lvc_t_err.
6 ENDCLASS.

Implement

1 CLASS lcl_gui_alv_grid IMPLEMENTION.
2     METHOD m_set_error_cells.
3         CALL_METHOD me->set_error_cells
4             EXPORTING
5                 cell_table     = it_err.
6     ENDMETHOD.
7 ENDCLASS.

2. Save the row and column IDs of the fields that need to report errors to the internal table.

1 DATA:gt_err TYPE lvc_t_err,
2          gs_err TYPE lvc_s_err.
3 
4 gs_err-row_id = &1.
5 gs_err-row_id = &2.
6 APPEND gs_err TO gt_err.
7 CLEAR:gs_err.

3. When the PbO is refreshed, the method is called

1 IF gt_err IS NOT INITIAL.
2     CALL METHOD go_alv_grid->m_set_error_cells
3         EXPORTING
4             it_err = gt_err.
5 ENDIF.

Similar Posts: