Skip to Content
avatar image
Former Member

how to validate editable field in ALV

Hi All,

I have a alv program using OOPS concept where two fields(columns) are editable in the alv output. These two columns contain table names and field names which can be edited.

I just want to validate these table and field names when we press the save button. If the edited entry is valid,i.e., the tablename is existing in the database, then it must update the entered value oftbl name to the db. else it shud give a error msg.

Please help with this code.

Thanks in Advance.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 22, 2009 at 07:08 AM

    hi

    check this program

    BCALV_GRID_EDIT

    Regard

    nawa

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 22, 2009 at 07:07 AM

    Hey!!!

    Try using this...

    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS : handle_data_changed FOR EVENT data_changed
                                      OF  cl_gui_alv_grid
                                      IMPORTING er_data_changed.
    ENDCLASS.
    
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
        PERFORM data_changed USING er_data_changed.
      ENDMETHOD.    
    ENDCLASS.
    
    form DATA_CHANGED  using p_er_data_changed
                             TYPE REF TO cl_alv_changed_data_protocol.
      DATA : ls_mod_cells TYPE lvc_s_modi,
                   declare a variable for your table or field name.
    
      LOOP AT p_er_data_changed->mt_good_cells INTO ls_mod_cells.
          CASE ls_mod_cells-fieldname.
          WHEN 'LIFNR'.
              CALL METHOD p_er_data_changed->get_cell_value
              EXPORTING
                i_row_id    = ls_mod_cells-row_id
                i_fieldname = 'LIFNR'
              IMPORTING
                e_value     = The variable you have defined.
    
    put ur condition according to variable here, if the condition is not satisfied, then throw a message like this.
    
            CALL METHOD p_er_data_changed->add_protocol_entry
                EXPORTING
                  i_msgid     = 'ZFI'
                  i_msgno     = '999'
                  i_msgty     = 'E'
                  i_msgv1     = 'Employee Number Doesn''t Exist'
                  i_fieldname = ls_mod_cells-fieldname
                  i_row_id    = ls_mod_cells-row_id.
              EXIT.
            ENDIF.
    

    .

    Hope this helps.

    Regrds,

    Abhinab Mishra

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 22, 2009 at 07:07 AM

    Hi Aishwarya ,

    You can use the below code at the starting of SAVE button press, to get the latest changes made on ALV into your internal table,

    *  Logic to get the latest output of the grid into internal table
      DATA: ref_grid TYPE REF TO cl_gui_alv_grid.
    
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
      IF NOT ref_grid IS INITIAL.
    
        CALL METHOD ref_grid->check_changed_data .
      ENDIF.
    

    going further you can validate the column fields values !!

    Edited by: Salil Jha on Oct 22, 2009 9:07 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 23, 2009 at 11:58 AM

    Thanks a lot for your reply Abinav.

    The problem is solved

    Add comment
    10|10000 characters needed characters exceeded