Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Like error msg in chain endchain, but in ALV

Former Member
0 Kudos

Hey experts,

I would like to do my own input check in ALV, I already made the input check, but I don't know how to highlight the current cell and block the alv while the wrong data is not changed to the correct one.

I want to achieve this

on the picture you can see the automatic input check because of the foreign key of that field. But I want to implement my own input check.

I already made data_change event handler, where I doing the input check, but I don't know to block the alv, while the user correct the input.

I already know how to add that Error Log and how to highlight the cell, but I still don't know how to block the alv to don't allow me save the data while I don't change the value of the cell.


if er_data_changed->mt_mod_cells is not INITIAL.

       loop at er_data_changed->mt_mod_cells into ls_cell.

         check ls_cell-fieldname eq 'ID_KNIZNICE'.

         check ls_cell-value is not initial.

         select SINGLE * from zbr_t_kniznice into wa_kniznica

           where id_kniznice eq ls_cell-value

           AND aktivne eq 'X'.

         if sy-subrc NE 0.


           " here somehow block it


       ENDLOOP.

endif.

Regards,

Robert

1 ACCEPTED SOLUTION

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

See program BCALV_EDIT_03 .

Regards.

Before the save

data: gui_alv_grid_1 TYPE REF TO cl_gui_alv_grid.

CALL METHOD gui_alv_grid_1->check_changed_data

     IMPORTING

      e_valid = l_valid.

Also I do a full check of the data (I create my own cl_alv_changed_data_protocol )    

data: ob_alv_changed_data_protocol TYPE REF TO cl_alv_changed_data_protocol .

* create protocol handler
* Based on Include LCKMLDUVACTF02
    IF ob_alv_changed_data_protocol IS INITIAL.
      CREATE OBJECT ob_alv_changed_data_protocol
         EXPORTING
           i_calling_alv = gui_alv_grid_1.
      APPEND LINES OF it_fieldcatalog TO ob_alv_changed_data_protocol->mt_fieldcatalog.
    ELSE.
      CALL METHOD ob_alv_changed_data_protocol->refresh_protocol.
      CALL METHOD ob_alv_changed_data_protocol->free.
      CLEAR ob_alv_changed_data_protocol.
      CREATE OBJECT ob_alv_changed_data_protocol
         EXPORTING
           i_calling_alv = gui_alv_grid_1.
      APPEND LINES OF it_fieldcatalog TO ob_alv_changed_data_protocol->mt_fieldcatalog.
    ENDIF.

Regards.

2 REPLIES 2

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

See program BCALV_EDIT_03 .

Regards.

Before the save

data: gui_alv_grid_1 TYPE REF TO cl_gui_alv_grid.

CALL METHOD gui_alv_grid_1->check_changed_data

     IMPORTING

      e_valid = l_valid.

Also I do a full check of the data (I create my own cl_alv_changed_data_protocol )    

data: ob_alv_changed_data_protocol TYPE REF TO cl_alv_changed_data_protocol .

* create protocol handler
* Based on Include LCKMLDUVACTF02
    IF ob_alv_changed_data_protocol IS INITIAL.
      CREATE OBJECT ob_alv_changed_data_protocol
         EXPORTING
           i_calling_alv = gui_alv_grid_1.
      APPEND LINES OF it_fieldcatalog TO ob_alv_changed_data_protocol->mt_fieldcatalog.
    ELSE.
      CALL METHOD ob_alv_changed_data_protocol->refresh_protocol.
      CALL METHOD ob_alv_changed_data_protocol->free.
      CLEAR ob_alv_changed_data_protocol.
      CREATE OBJECT ob_alv_changed_data_protocol
         EXPORTING
           i_calling_alv = gui_alv_grid_1.
      APPEND LINES OF it_fieldcatalog TO ob_alv_changed_data_protocol->mt_fieldcatalog.
    ENDIF.

Regards.

0 Kudos

Thank you very much, before you I was also using the add_protocol_entry, but I didn't fill the row id only the fieldname, and that's why it wasn't working as I wanted to. And it is also a great idea to trigger data_changed event before save. Thank you once again