Editable Alv: ERROR in er_data_changed- display_protocol

I have one fields "Emp_dept" in the record of the ALV Grid which can be edited, but when I edit this field  with  enter  event it will generate a error in display protocal, I want it to save in database , I debuged the program it reflect the in internal table but failed to reflect the in change in data base, as i Just started dveelopment in abap programing i searched the whole web for this problem but couldnot sucessfull please help me in this regarrd
Here is my code:
I am using module pool programing and I am following abap slandered program Bcalv_edit_03.
FUNCTION-POOL Z_EMPLOYEE.                   "MESSAGE-ID ..
* INCLUDE LZ_EMPLOYEED...                    " Local class definition
TABLES:ZEMPLOYEE, ZEMP_COMM.
DATA: zemploye TYPE TABLE OF zemployee  WITH HEADER LINE,
  WA TYPE zemployee .
DATA: ZEMP_COM TYPE TABLE OF ZEMP_COMM   WITH HEADER LINE.
  DATA : WACOMM TYPE ZEMP_COMM.
DATA: ZEMP_ADR TYPE TABLE OF ZEMP_ADRESS  WITH HEADER LINE,
WA_ADR TYPE ZEMP_ADRESS.
DATA: ZEMP_EDU TYPE TABLE OF ZEMP_EDUCATION1  WITH HEADER LINE,
WA_EDU1 TYPE ZEMP_EDUCATION1.
DATA EMPD TYPE ZEMP_ID.
*data empd LIKE zemployee-emp_id.
  data: O_DOCKING TYPE REF TO CL_GUI_DOCKING_CONTAINER,
O_GRID TYPE REF TO CL_GUI_ALV_GRID,"Grid
   i_selected_rows TYPE lvc_t_row,"Selected Rows
        w_selected_rows TYPE lvc_s_row,
   WA_LAYOUT TYPE LVC_S_LAYO,
class lcl_event_receiver definition deferred.
data: g_event_receiver type ref to lcl_event_receiver.
types:BEGIN OF i_zemployee ,
    emp_id type zemployee-emp_id,
   emp_name type zemployee-emp_name,
   D_O_BIRTH TYPE ZEMPLOYEE-D_O_BIRTH,
   D_o_jOIN TYPE ZEMPLOYEE-D_o_jOIN,
   EMP_DEPT TYPE ZEMPLOYEE-EMP_DEPT,
   EMP_NO type ZEMP_COMM-EMP_NO,
   eemp_id type zemp_comm-emp_id,
   EMP_ADRESS TYPE ZEMP_ADRESS-EMP_ADRESS,
   EMP_RES_ADDR TYPE ZEMP_ADRESS-EMP_RES_ADDR,
   EMP_EDU1 TYPE ZEMP_EDUCATION1-EMP_EDU1,
  END OF i_zemployee.
   Data:
     i_tb type i_zemployee,
     emp_itb like table of i_tb.
     data:t_fcat TYPE lvc_t_fcat,
     wa_fcat TYPE lvc_s_fcat.
DATA:
   screen  TYPE n LENGTH 4 VALUE 0100,
   screen1  TYPE n LENGTH 4 VALUE 0110,
   screen2  TYPE n LENGTH 4 VALUE 0120,
   screen3  TYPE n LENGTH 4 VALUE 0130,
    ok_code LIKE sy-ucomm.
   FORM FREE_OBJECTS .
   CALL METHOD O_GRID->FREE
     EXCEPTIONS
       CNTL_ERROR        = 1
       CNTL_SYSTEM_ERROR = 2
       OTHERS            = 3.
   IF SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.
   FREE O_GRID.
   CALL METHOD O_DOCKING->FREE
     EXCEPTIONS
       CNTL_ERROR        = 1
       CNTL_SYSTEM_ERROR = 2
       OTHERS            = 3.
   IF SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.
  FREE O_DOCKING.
ENDFORM.
  form sol using emp_idd .
    data l_num(5) type n.
    l_num = emp_idd.
* CALL FUNCTION 'NUMBER_GET_NEXT'
*         EXPORTING
*              nr_range_nr             = '01'
*              object                  = 'ZEMP_AUTO'
*         IMPORTING
*              number                  = l_num
*         EXCEPTIONS
*              interval_not_found      = 1
*              number_range_not_intern = 2
*              object_not_found        = 3
*              quantity_is_0           = 4
*              quantity_is_not_1       = 5
*              interval_overflow       = 6
*              buffer_overflow         = 7
*              OTHERS                  = 8.
    l_num = l_num + 1.
EMP_IDD = L_NUM.
endform.
  class lcl_event_receiver definition.
  public section.
     methods:
       handle_data_changed
          for event data_changed of cl_gui_alv_grid
              importing er_data_changed.
  private section.
* This flag is set if any error occured in one of the
* following methods:
     data: error_in_data type c.
* Methods to modularize event handler method HANDLE_DATA_CHANGED:
     methods: check_planetype
      importing
         ps_good_planetype type lvc_s_modi
         pr_data_changed type ref to cl_alv_changed_data_protocol.
*    methods: ch_new_plane_v_new_seatsocc
*           importing
*              psg_plane type lvc_s_modi
*              psg_socc type lvc_s_modi
*              ps_saplane type saplane
*              pr_data_changed type ref to cl_alv_changed_data_protocol.
*    methods: ch_new_plane_v_old_seatsocc
*           importing
*              psg_plane type lvc_s_modi
*              ps_saplane type saplane
*              pr_data_changed type ref to cl_alv_changed_data_protocol.
*    methods: check_seatsocc
*           importing
*              ps_good type lvc_s_modi
*              pr_data_changed type ref to cl_alv_changed_data_protocol.
* This is a suggestion how you could comment your checks in each method:
* CHECK: fieldname(old/new value) !<comp> fieldname(old/new value)
* IF NOT: (What to tell the user is wrong about the input)
* Remarks:
*  fieldname:       fieldname of table for the corresponding column
*  (old/new value): ckeck with value of GT_OUTTAB or MT_GOOD_CELLS.
*  !<comp>        : the value is valid if the condition <comp> holds.
* Example:
*  CHECK seatsocc(new) !>= seatsmax(old)
*  IF NOT: There are not enough number of seats according to this
*          planetype.
endclass.
class lcl_event_receiver implementation.
   method handle_data_changed.
     data: ls_good type lvc_s_modi.
    error_in_data = space.
     loop at er_data_changed->mt_good_cells into ls_good.
       case ls_good-fieldname.
* check if column PLANETYPE of this row was changed
         when 'EMP_DEPT'.
           call method check_planetype
                  exporting
                     ps_good_planetype = ls_good
                     pr_data_changed   = er_data_changed.
      endcase.
     endloop.
*§7.Display application log if an error has occured.
     if error_in_data eq 'X'.
        call method er_data_changed->display_protocol.  ( Error line)        <-------------------------------
     endif.
   endmethod.
   method check_planetype.
     data: l_planetype type zemp_dept,
           ls_saplane type zemployee,
           ls_good_seatsocc type lvc_s_modi.
     call method pr_data_changed->get_cell_value
           exporting i_row_id =    ps_good_planetype-row_id
                     i_fieldname = ps_good_planetype-fieldname
           importing e_value     = l_planetype.
MODIFY ZEMPLOYEE FROM TABLE emp_itb.
     select single * from zemployee into ls_saplane where
                                      emp_dept = 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-m03           "Flugzeugtyp
           i_msgv2 = l_planetype
           i_msgv3 = text-m05           "exitstiert nicht
           i_fieldname = ps_good_planetype-fieldname
           i_row_id = ps_good_planetype-row_id.
       error_in_data = 'X'.
       exit. "plane does not exit, so we're finished here!
     endif.
endmethod.
endclass.
**********************************************Module output****************
MODULE STATUS_0120 OUTPUT.
  SET PF-STATUS 'START'.
  SET TITLEBAR 'STARTT'.
IF O_DOCKING IS INITIAL.
*   Creating Docking Container
    data: lt_exclude type ui_functions.
       CREATE OBJECT O_DOCKING
              EXPORTING
                RATIO                       = '95'.
       IF SY-SUBRC EQ 0.
*   Creating Grid
         CREATE OBJECT O_GRID
             EXPORTING
                I_PARENT          = O_DOCKING.
       ENDIF.
endif.
* Filling the fieldcatalog table
*    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
*      EXPORTING
*        I_STRUCTURE_NAME       = 'i_tb'
*      CHANGING
*        CT_FIELDCAT            = t_fcat
*      EXCEPTIONS
*        INCONSISTENT_INTERFACE = 1
*        PROGRAM_ERROR          = 2
*        OTHERS                 = 3.
   WA_LAYOUT-GRID_TITLE = 'EMPLOYEE TABLE DETAILS'.
   WA_LAYOUT-ZEBRA = 'X'.
   WA_LAYOUT-EDIT = 'X'.
IF T_FCAT is  initial.
*  wa_fcat-fieldname = 'EMP_ID'.
*  wa_fcat-ref_table = 'ZEMPLOYEE'.
*  wa_fcat-ref_field = 'EMP_ID'.
*  wa_fcat-col_pos = 2.
*  APPEND wa_fcat TO t_fcat.
*  CLEAR wa_fcat.
   wa_fcat-fieldname = 'EMP_NAME'.
   wa_fcat-ref_table = 'ZEMPLOYEE'.
   wa_fcat-ref_field = 'EMP_NAME'.
   wa_fcat-col_pos = 3.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
    wa_fcat-fieldname = 'EMP_DEPT'.
   wa_fcat-ref_table = 'ZEMPLOYEE'.
   wa_fcat-ref_field = 'EMP_DEPT'.
   wa_fcat-col_pos = 4.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
      wa_fcat-fieldname = 'D_O_BIRTH'.
   wa_fcat-ref_table = 'ZEMPLOYEE'.
   wa_fcat-ref_field = 'D_O_BIRTH'.
   wa_fcat-col_pos = 5.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
   wa_fcat-fieldname = 'D_O_JOIN'.
  wa_fcat-ref_table = 'ZEMPLOYEE'.
  wa_fcat-ref_field = 'D_O_JOIN'.
  wa_fcat-col_pos = 6.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
wa_fcat-fieldname = 'EMP_NO'.
  wa_fcat-ref_table = 'ZEMP_COMM'.
  wa_fcat-ref_field = 'EMP_NO'.
  wa_fcat-col_pos = 7.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
   wa_fcat-fieldname = 'EMP_ADRESS'.
   wa_fcat-ref_table = 'ZEMP_ADRESS'.
   wa_fcat-ref_field = 'EMP_ADRESS'.
   wa_fcat-col_pos = 7.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
   wa_fcat-fieldname = 'EMP_RES_ADDR'.
   wa_fcat-ref_table = 'ZEMP_ADRESS'.
   wa_fcat-ref_field = 'EMP_RES_ADDR'.
   wa_fcat-col_pos = 8.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
   wa_fcat-fieldname = 'EMP_EDU1'.
   wa_fcat-ref_table = 'ZEMP_EDUCATION1'.
   wa_fcat-ref_field = 'EMP_EDU1'.
   wa_fcat-col_pos = 9.
   APPEND wa_fcat TO t_fcat.
   CLEAR wa_fcat.
ENDIF.
* CALL METHOD o_grid->register_edit_event
*    EXPORTING  i_event_id = cl_gui_alv_grid=>mc_evt_modified.
*    W_VARIANT-REPORT = SY-REPID.
* Displaying the output
     CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING
*       IS_VARIANT                    = VARIANT
         I_SAVE                        = 'A'
        I_STRUCTURE_NAME       = 'i_tb'
         IS_LAYOUT                     = WA_LAYOUT
         it_toolbar_excluding  = lt_exclude
       CHANGING
       IT_OUTTAB                     =  emp_itb
         IT_FIELDCATALOG               = t_fcat
       EXCEPTIONS
         INVALID_PARAMETER_COMBINATION = 1
         PROGRAM_ERROR                 = 2
         TOO_MANY_LINES                = 3
         OTHERS                        = 4.
     IF SY-SUBRC <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
     ENDIF.
*call method cl_gui_control=>set_focus exporting control = O_GRID.
*      call method cl_gui_cfw=>flush.
       CALL METHOD o_grid->set_ready_for_input
      EXPORTING
        I_READY_FOR_INPUT = 1.
  CALL METHOD O_GRID->REGISTER_EDIT_EVENT
     EXPORTING
       I_EVENT_ID = CL_GUI_ALV_GRID=>mc_evt_enter.
*    EXCEPTIONS
*      ERROR      = 1
*      OTHERS     = 2.
**** UPDATE zemployee FROM TABLE emp_itb.
  create object g_event_receiver.
   set handler g_event_receiver->handle_data_changed for o_grid.
*  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.
ENDMODULE.                 " STATUS_0120  OUTPUT
*&      Module  USER_COMMAND_0120  INPUT
*       text
MODULE USER_COMMAND_0120 INPUT.
DATA LV_UCOMM TYPE SY-UCOMM.
*  data: ok_code like sy-ucomm .
  LV_UCOMM = SY-UCOMM.
   CASE LV_UCOMM.
  WHEN 'CANCEL' OR 'EXIT'.
       PERFORM FREE_OBJECTS.
       LEAVE PROGRAM.
     WHEN 'BACK'.
        CALL METHOD o_grid->set_frontend_fieldcatalog
         EXPORTING
           it_fieldcatalog = t_fcat[].
        if o_grid is not initial.
    CALL METHOD o_grid->refresh_table_display
       EXCEPTIONS
         finished = 1
         OTHERS   = 2.
endif.
       PERFORM FREE_OBJECTS.
       CALL SCREEN 110.
*      SET SCREEN '0'.
*      LEAVE SCREEN.
   ENDCASE.
ENDMODULE.   
Please help me to solve this porblem..

Hi suhas,
my issue is not the lack of data .....
my issue is about the error handling in data_changed event in alv oops application....am able to display the error log using display_protocol method..,.. but after displaying the error log am still able to save the changes which should not happen....the thing is we should not be able to save the changes...... am having the same issue as the following thread
Re: CL_ALV_CHANGED_DATA_PROTOCOL - Protocol Popup is not modal
if u still require any clarifications...pls let me know ur mail-id ill post my code to u ..
thanks
suresh

Similar Messages

  • Editable ALV Error

    I am displaying a ALV table and have editable field for Quantity ( 13 char; 3 decimal).
    If the user enters quantity which is more than 13 chars; I am getting a error
    "The entered value has too many digits in the integer part".
    I have a event handler method for ON_DATA_CHECK was expecting to catch this cell in the t_error_cells table; however this method is not called...
    I am looking for some pointers in resolving the issue.

    Hi,
    you get this error rightly. If you want this to work you may have to consider changing the data element type to quan or P or C or simply string .
    You may have to have the conversion routine to match the database type.

  • Mark fields (columns) in editable ALV Grid as mandatory

    Hi,
    could you please help me to set up a column in an editable alv grid as mandatory? I had a look in several references and also did not find anything in the fieldcatalog structure.
    Best regards,
    Fabian

    Hello Fabian
    Here is some coding to explain what I meant.
    *& Report  ZUS_SDN_ALV_ERROR_LOG
    REPORT  zus_sdn_alv_error_log.
    DATA:
      er_data_changed    TYPE REF TO cl_alv_changed_data_protocol.
    START-OF-SELECTION.
    * Dynpro is empty (contains no elements)
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  PBO_0100  OUTPUT
    *       text
    MODULE pbo_0100 OUTPUT.
    * Event DATA_CHANGED was fired due to changes in the editable ALV grid
      IF ( er_data_changed IS BOUND ).
    * User did not change any values
      ELSE.
        CREATE OBJECT er_data_changed
    *      EXPORTING
    *        I_CONTAINER =
    *        I_CALLING_ALV = <your ALV grid instance>
      ENDIF.
    * That is how your code probably looks like
    *  LOOP AT gt_outtab INTO gs_outtab.
    *    IF ( gs_outtab-obligatory IS INITIAL ).
    *      CALL METHOD go_alvlog->add_protocol_entry
    *        EXPORTING
    *          i_msgid     = '00'
    *          i_msgty     = 'E'
    *          i_msgno     = '398'
    *          I_MSGV1     = 'Field OBLIGATORY must not be empty'
    **          I_MSGV2     =
    **          I_MSGV3     =
    **          I_MSGV4     =
    *          i_fieldname = 'OBLIGATORY'
    **          I_ROW_ID    =
    *          I_TABIX     = syst-tabix
    *    ENDIF.
    *  ENDLOOP.
    * Generate a protocol for testing purposes
      DO 5 TIMES.
        CALL METHOD er_data_changed->add_protocol_entry
          EXPORTING
            i_msgid     = '00'
            i_msgty     = 'E'
            i_msgno     = '398'
            i_msgv1     = 'Field OBLIGATORY must not be empty'
    *          I_MSGV2     =
    *          I_MSGV3     =
    *          I_MSGV4     =
            i_fieldname = 'OBLIGATORY'
            i_row_id    = syst-index
            i_tabix     = syst-index
      ENDDO.
      CALL METHOD er_data_changed->display_protocol
    *    EXPORTING
    *      I_CONTAINER =
    ENDMODULE.                 " PBO_0100  OUTPUT
    Please note that this report dumps as soon as you close the log popup. However, this will not happen within your event handler method.
    Regards
      Uwe

  • Editable alv: add custom validation and display "errors" in protocol list

    Hi,
    What I want to do:
    PAI validation of editable alv with displaying error's in the protocol list by adding custom entries to the existing protocol object.
    What is my problem:
    After registering "data_changed event", the protocol list don't appear.
    My understanding is, that the object "er_data_changed" is passed by the event "data_changed"
    an so I thought I can add some more entries to the protocol list.
    After "de-registering" the "data_changed" event, the protocol appears with the standard errros messages (e.g. "input to numeric" by enter charachters)
    One more hint:
    By creating a new object "er_data_changed" in the handler method the protocol list works, but I would like to append entries to the object that was passed with the event.
    Probably I've misunderstand something, please help !
    My coding:
    PAI:
    trigger event "data_changed" -> calls handler method
      CALL METHOD r_myalv->check_changed_data
        IMPORTING
          e_valid = is_valid.
    stop processing
      IF is_valid NE 'X'.
        MESSAGE 'invalid input' TYPE 'E' .
      ENDIF.
    handler method:
    handle_data_changed FOR EVENT data_changed  OF cl_gui_alv_grid  IMPORTING e_ucomm
                                                                                    er_data_changed.
    METHOD handle_data_changed.
        data: ls_mod_cell type lvc_s_modi.
         CALL METHOD er_data_changed->add_protocol_entry
                    EXPORTING
                           i_msgid     = 'SU'
                           i_msgty     = 'E'
                           i_msgno     = '000'
                           i_msgv1     = 'This is a test !'
                           i_fieldname = ls_mod_cell-fieldname.
         er_data_changed->refresh_protocol( ).
         er_data_changed->DISPLAY_PROTOCOL( ).
    ENDMETHOD.                    "handle_data_changed

    Dear Olaf,
        If understood correctly, you want to Edit an ALV and do some data validations when some data is changed in an ALV.   To do this follow the following steps:
    1.   Before displaying ALV, Register the edit event.
    * Set cell modified to trigger data_changed
    CALL METHOD go_alv_grid->register_edit_event
    EXPORTING
    i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    2.  Register the event DATA_CHANGED of class CL_GUI_ALV_GRID & handle the event.
    SET HANDLER lo_event_receiver->handle_data_changed FOR go_alv_grid.
    The event DATA_CHANGED of class CL_GUI_ALV_GRID has a parameter ER_DATA_CHANGED which is of type CL_ALV_CHANGED_DATA_PROTOCOL.
    This er_data_changed has internal table MT_MOD_CELLS(contains index of records changed ) & MP_MOD_ROWS(contains the changed row), using these update your internal table accordingly.
    DATA : wa_mod_cell TYPE lvc_s_modi.
    FIELD-SYMBOLS: <fs> TYPE table.
    LOOP AT er_data_changed->mt_mod_cells INTO wa_mod_cell.
    ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
    READ TABLE <fs> INTO wa_output INDEX wa_mod_cell-tabix.
    MODIFY lt_output FROM wa_output INDEX wa_mod_cell-row_id.
    ENDLOOP.
    3.   Here it self you can do the required data validations(No need of any PAI modules) as below.
    IF wa_orders-zfstfirmtyp = c_9.
    MESSAGE s288(zcsp).
    DELETE er_data_changed->mt_mod_cells.
    EXIT.
    ENDIF.
    Regards
    Kesava

  • I get error message DB745 with EDIT ALV on a field type DEC?

    Hi,
    I have an ALV which has a field type DEC.
    The ALV is open for edit.
    Once I put negative number in, I get the error message DB745.
    This error is retrieved from SAP code and I do not see any reason why.
    I checked the field cat and it looks fine (ref to a field type DEC).
    I am using lcl_grid_event_receiver with method: handle_data_changed FOR
    EVENT data_changed OF cl_gui_alv_grid.
    In that method I get the error in er_data_changed->mt_protocol.
    There is no problem to show negative data if it is saved in the database
    as negative.
    Can anyone throw ideas how to fix that?
    Thanks,
    Itay

    If you simply check the domain WERT7, you'll see that the checkbox for "Sign" is <b>not</b> checked. Therefore negative numbers are <b>not</b> allowed.
    Just because a field is decimal or currency does <b>not</b> mean that negatives are allowed.
    Many times, the sign is handled by a separate debit/credit indicator field such as a field with a domain of SHKZG.
    Rob
    Message was edited by:
            Rob Burbank

  • Editable ALV - how to throw an error message for a specific line & field

    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

    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

  • Error Messages popup in editable ALV

    Hello All,
    Iam working on Editable ALV  as a table maintainance for a Ztable and usng OOPs for that.
    Lets say i have material and plant fields for editing in ALV.
    If the user enters some junk value in the material field, its automatically getting validated and giving an error message with a popup.
    my question is, is there any way we can restrict this popup messages with error and have our own messages insted ?
    Appriciate your help in this.
    Thanks.

    check out this thread, where the poster wanted to append custom messages to the standard SAP messages... check otu the refresh_protocol method to see if you can clear out pre-existing SAP messages...
    Re: editable alv: add custom validation and display "errors" in protocol li

  • Runtime Error - TABLE_FREE_IN_LOOP in editable ALV GRID

    While modifying editable ALV Grid, (CL_GUI_ALV_GRID) I am getting an unexpected dump as follows -
    "Runtime Error          TABLE_FREE_IN_LOOP".
       In a Editable ALV grid whenever new row is added using standard append row button, And while saving, i check for any initial values, in that case iam displaying a warning message. So after that when i try to modify the row, and press enter key, Iam getting this dump "TABLE_FREE_IN_LOOP".
    Can you please help on this regard.
    Thanks in advance..
    Best regards,
    Prasad.

    Hello Krishna
    take a additional internal table which is exactly of same type of the internal table which you want to modify . try modifying the second internal table. and then proceed for db update(if required).
    Regards,
    Suvendu

  • Error message when running editable alv

    Hi all,
    I hava a problem with an editable ALV. I created it with the following method wddoinit:
    METHOD wddoinit .
    initialize ALV Component
      DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
      l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
      ENDIF.
    Get model data
      DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
      l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
      DATA:
      l_value TYPE REF TO cl_salv_wd_config_table.
      l_value = l_ref_interfacecontroller->get_model( ).
    set read only mode to false (and display edit toolbar)
      DATA: lr_table_settings TYPE REF TO
      if_salv_wd_table_settings.
      lr_table_settings ?= l_value.
      lr_table_settings->set_read_only( abap_false ).
    set cell editor for input fields (~make colum editable)
      DATA: lr_column TYPE REF TO cl_salv_wd_column.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
      lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
      lr_column_settings ?= l_value.
      lr_column = lr_column_settings->get_column( 'SAMPLE' ).
      CREATE OBJECT lr_input_field
        EXPORTING
          value_fieldname = 'SAMPLE'.
    lr_column->set_cell_editor( lr_input_field ).
    ENDMETHOD.
    But when I run the Web Dynpro Application I get an error message with the note:
    "Access over "Null" Object Reference not possible" ( I translated it from german to english )
    The error occures in the line:
    lr_column->set_cell_editor( lr_input_field ).
    But what is wrong?
    Thanks for your help!!
    Regards
    Ingmar

    Sorry. I'm stupid. I didn't the "Sample" for column and field!!!
    But:
    How can I reach that not only one cell is editable, but the whole table? And how can I save the data that I put in, when I add a new line?
    Thanks!!

  • Skipping domain errors in editable ALV

    Hi Gurus,
    Have a concern wrt an editable ALV.
    I have an editable ALV in which a field's(Chain ID is the name of the field) domain has
    fixed intervals. The fixed interval is defined as:
    T000000000     TZZZZZZZZZ
    S000000000     SZZZZZZZZZ
    Which means that the values for this field can start only with T or S. In the ALV, for this
    field I may have blank values getting displayed. If I enter a valid value in the ALV then
    its ok but when I delete the same value the ALV protocol shows an error 'Enter a valid
    value'. The system is interpreting the value to be 'entered' in the ALV as 'space' as its
    not valid as per the fixed intervals. BUt this actually should not happen because I am just
    undoing my change. Can anyone suggest a way so that this validation is skipped and the ALV thus can accept initial value?
    Thanks and Regards,
    Sravan.
    Edited by: sravan sriram on May 19, 2010 6:54 AM

    Skipping processing of the chain block will not stop the message from coming as the message is raised from the domain level. If you mean that among other things I need to delete that message from the protocol then in that case the changed value strangely does not get deleted. It comes back to the value which has been put before deleting it...

  • Supress error log display in editable ALV

    Hi,
    I am using an editable ALV to get input. Some of the fields in the grid are assigned a check table. So when a entry which does not exist in the check table is made for these fields ALV by default displays a error log.
    Is there any way to supress the display of this error log and collect the errors in this log to some internal table? I want to do this because apart from the standard validations done by the ALV i am performing some validations in the program and displaying a log. So i want to capture the error log of the ALV and display them in my log so that 2 error logs wont be displayed.
    Thanks in advance,
    Tongston Immanuel.

    I'm building a kind of feature, where you can go different ways in a tree, based on a condition. The values for this condition are entered in an ALV-grid, which is a table with fields of type C(30). However to have a F4 help, I fill in ref_field and ref_table in the fieldcatalog. Most of the time, this works fine, but for fields of type NUMC, even if no F4 help is available, this doesn't work since internally it wants to convert this NUMC field to my CHAR field and it fails.
    I refreshed my log table in the DATA_CHANGED event. Thanks for your suggestion!

  • Validation of data in editable ALV report output for particular field

    Hi Experts,
    I have one input enabled field in ALV output. How to validate the data once user enters  in that field and press enter? Is it possible to capture the value, hit the enter after user enters the data?
    Thanks,
    Surya Prakash

    Halo Prakash,
    1 First you should registeer the ENTER Event.
    call method g_grid->register_edit_event
                   exporting
                      i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    2 Declare event handler method for Event data_changed of cl_gui_alv_grid.
    handle_data_changed
             for event data_changed of cl_gui_alv_grid
                 importing er_data_changed.
    3 Inside the Event handler method , you get the event parameter er_data_changed type ref to CL_ALV_CHANGED_DATA_PROTOCOL.
    loop at er_data_changed->mt_good_cells into ls_good.
          case ls_good-fieldname.
            when 'FIELD1'.
              call method check_FIELD1.
            when 'FIELD2 '.
              call method check_FIELD2
          endcase.
        endloop.
    4 Inside the Method check_FIELD1 and check_FIELD2 you can do the validation check .
    call method er_data_changed->get_cell_value( Passing the row no and field name).
    if the check  fails you can use add_protocol_entry to write the error.
    5 Finally call
    er_data_changed->display_protocol.
    Regards
    Arshad

  • Editable ALV, how to capture changed data

    Hi All,
    I have created an editable ALV. User can make some changes in the displayed record and press "Submit" button (custom button on application toolbar), the program should validate the data and write the file on application server if validations are successful otherwise controls stay on the same screen.
    I am handling this validation and writing file part in PAI of the screen.
    Problem: The program is capturing the data when user changes it for the first, but program is failing to capture the subsequent changes (user makes after the validation fails). Program processes always the first time changed data only. Please help me in getting this problem resolved.
    Step1 : Program shows output.
    Step2: User changes Company Code.
    Step3: User clicks on Submit Button.
    Step3.1: Program reads the new data and performs validation.
    Step3.2: New Company code is not valid, error displayed.
    Step4: User changes the company code again, presses submit button.
    Goto step 3.1 -> Here program does not read the new data, rather first time changes company code is again read and validated, and program shows the same error again, which is not a desired result

    Hi Ashish,
    you need a method HANDLE_DATA_CHANGED as handler for grid event DATA_CHANGED.
    Use
    LOOP AT er_data_changed->mt_mod_cells ASSIGNING <mod>.
    to check all changed data. In this event, add the error messages to ER_DATA_CHANGED object.
    set all required handlers, i.e.
    SET HANDLER:
          handle_data_changed          FOR ro_grid,
          handle_data_changed_finished FOR ro_grid,
          handle_toolbar_set           FOR ro_grid,
          handle_user_command          FOR ro_grid,
          handle_hotspot_click         FOR ro_grid,
          handle_f4                    FOR ro_grid,
          handle_f1                    FOR ro_grid.
       ro_grid->set_toolbar_interactive( ).
    Register ENTER and MODIFIED events.
        ro_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_enter ).
        ro_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_modified ).
    Regards,
    Clemens

  • Row id in editable ALV while using MP_MOD_ROWS

    Hi Experts
    I have an editable alv with 13 fields editable in it.     Inside the DATA_CHANGED event i am making use of the attribute MP_MOD_ROWS for doing some specific validations. But I am not able to pass the row_id to the the mehod add_protocal_entry while multiple rows are in MP_MOD_ROWS ,since its not available MP_MOD_ROWS .
    Can anyone tell me how i can get the row_id for  each row in MP_MOD_ROWS.
    Since I need the full row for validations , i cant use MT_MOD_CELLS.
    Regards,
    Suniljith.SS

    Hi,
    this is an excerpt of what we dir:
    METHOD handle_data_changed.
      FIELD-SYMBOLS:
        <dat> TYPE ANY,
        <mod> TYPE LINE OF lvc_t_modi,
      LOOP AT er_data_changed->mt_mod_cells ASSIGNING <mod>.
    * error case, sy-subrc <> 0 returned by MESSAGE ... RAISING
          symsg2alv_changed_data_prot( ir_cl_alv_changed_data_prot  = er_data_changed
                                       is_modi                      = <mod> ).
          DELETE er_data_changed->mt_mod_cells.
    using the method
    METHOD symsg2alv_changed_data_prot.
      MESSAGE
        ID sy-msgid
        TYPE sy-msgty
        NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
        INTO mv_msg. "for debug transparancy
      ir_cl_alv_changed_data_prot->add_protocol_entry(
        i_msgid     = sy-msgid
        i_msgty     = sy-msgty
        i_msgno     = sy-msgno
        i_msgv1     = sy-msgv1
        i_msgv2     = sy-msgv2
        i_msgv3     = sy-msgv3
        i_msgv4     = sy-msgv4
        i_fieldname = is_modi-fieldname
        i_row_id    = is_modi-row_id
    *      i_tabix     = i_tabix
    ENDMETHOD.
    I do not understand your question about row_id as this is a component  lvc_t_modi table. I don't know MP_MOD_ROWS as there is only attribute  MT_MOD_ROWS of parameter ER_DATA_CHANGED of event DATA_CHANGED of CL_GUI_ALV_GRID.
    Regards,
    Clemens

  • Check_changed_data method on editable ALV Grid ( class cl_gui_alv_grid)

    Hi guys,
    I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
    call method alv_grid->register_edit_event
                            exporting
                               i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
    Any advice or tips or sample code is greatly appreciated.
    Thanks,
    Shareen

    Hi Shareen,
    Handle the data_changed event in the grid.
    Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
        METHODS handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed.
    Implementation:
      METHOD handle_data_changed.
        PERFORM validations USING er_data_changed.
      ENDMETHOD.
    FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
      DATA: ls_good TYPE lvc_s_modi.
      DATA  wa LIKE LINE OF lt_good_cells.
      CALL METHOD g_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      LOOP AT er_data_changed->mt_good_cells INTO ls_good.
        CASE ls_good-fieldname.
        WHEN 'FIELDNAME'. "Your fieldname
            CALL METHOD er_data_changed->get_cell_value "Get the changed value
              EXPORTING
                i_row_id    = ls_good-row_id
                i_fieldname = ls_good-fieldname
              IMPORTING
                e_value     = temp. "Your temp variable
            "Make your validations here.
        ENDCASE.
    Ps: Reward points if helpful.
    Regards,
    Wenceslaus.

Maybe you are looking for

  • Fox news app downloads but won't open

    Continue to have trouble getting some apps to work. The Fox News app downloads ok but when I try to use it it won't open. Have had the same problem with other apps (Popular Science) and just gave up. Any help would be appreciated.

  • How do I scan with HP iPrint 3.0 on my HP photosmart premium c309g-m with my ipad2?

    The scan option remains grey but I can scan wireless with my Microsoft Windows software, why not with my Ipad2 with HP iPrint 3.0?

  • Switch branching in integration process

    Hi, I want to use a switch branching in integration process. The condition of the switch is to compare the source field value with a constant like If /p1:MT_Pntmaster/field1 = "n/a"  goto branch1  else                                                 

  • Moving location of photos

    Is there a way to get iPhoto to reconcile its library and search for photos that have been moved? I have reorganised a handful of photo folders and now iPhoto shows the thumbnail but no full size image. As I dont let iPhoto organise the photos for me

  • FDM mail app - having trouble compiling 1.6 anyone have 1.6 package??

    Hi... sorry to be writing about fdm again. http://aur.archlinux.org/packages.php?ID=7806 I'm having trouble getting 1.6 installed. I'm still hoping that the bug fixes in the recently release update for tdb might spark an ARCH version of fdm 1.6. I ne