ALV DATA_CHANGED

Hi everyone! I need to use event DATA_CHANGED on FM REUSE_ALV_HIERSEQ_LIST_DISPLAY. I used to do so on REUSE_ALV_GRID_DISPLAY passing parameter I_GRID_SETTINGS-EDT_CLL_CB = 'X', but this FM doesn't have it, so does anybody knows something like this but for hierarchical ALV??
I already added DATA_CHANGED event to the events table, but still wont activate.
thanx.
Jesus

Hi,
The DATA_CHANGED_FINISH event is triggerd after a change is committed.This is in contrast to the event DATA_CHANGED where the method is triggered after the change at an editable field is perceived.
Your code should look like this:
data: hnd_grid type ref to lcl_event_receiver.
*:--- Initialization of the objects and events
set handler hnd_event_grid->mth_data_changed_end
for hnd_grid.
*:--- Class definition and Implementation
methods: mth_data_changed_end
for event data_changed of cl_gui_alv_grid
inporting e_modified.
method: mth_data_changed_end.
if e_modified = 'X'.
*:--- do something ...
call method <hnd_grid->refresh_table_display
endif.
endmethod.
one more ex:
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS HANDLE_DATA_CHANGED
FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED E_ONF4 E_UCOMM.
ENDCLASS. "cl_event_receiver DEFINITION
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_DATA_CHANGED.
PERFORM DATA_CHANGED USING ER_DATA_CHANGED E_ONF4 E_UCOMM.
end method.
endclass.
Mark all helpful answers

Similar Messages

  • ALV: data_changed event

    Hi everyone!
    I have the following problem:
    I created a DYNPRO with one ALV grid and several "ordinary" fields. The ALV is editable.
    Now I try to sum up some fields of the ALV grid and put the sum into one of the ordinary DYNPRO fields. When the <i>data_changed</i> event is fired the sum is calculated correctly and put into the global field associated with the DYNPRO field. However, the value change is not shown on the DYNPRO.
    When I press <i>ENTER</i> while the cursor is in the "ordinary" DYNPRO area and not in the ALV Grid, the data change is shown correctly. Debugging shows that no PBO/PAI for the DYNPRO is executed when the data in the ALV is changed, so I assume there is no value transport between the global field and the DYNPRO.
    What am I doing wrong?
    Regards, Joerg

    Hi Joerg,
    Here is the other way how to achieve the processing of PAI/PBO of the main DYNPRO, which contains ALV. It works fine for me, so you could consider this possibility as well. Inside the event handling method you could do this call:
           CALL METHOD cl_gui_cfw=>set_new_ok_code
             EXPORTING
               new_code = 'ENTE'
             IMPORTING
               rc       = l_rc.
    You should deal rather carefully with it - put it better in a method like
    HANDLE_DATA_CHANGED_FINISHED
    Instead of 'ENTE' you should use the command code defined in your dynpro and better suited for such a "refresh" functionality, but I'm afraid it can not be empty code string.
    Hope this helps, regards, Sergei

  • Get data in editable ALV back to internal table without data_changed ev?

    Hi,
       I have an editable ALV using classes to whch I have users the option to edit directly on the screen or upload data from an excel. The event data_changed gets triggered when users edit the table on the screen.
    However when EXCEL is uploaded, I refresh the table display. So, I need a way to get the data from the ALV into a internal table to check which rows were update using the excel and save them into the db table.
    Prakash

    Hi!
    For more information, inspect programs suiting the mask "BCALVEDIT*" and the thread with header "How to make a row of ALV editable " (I know this is some more steps further from your demand but it may be useful) at URL " How to make a row of ALV editable " .
    If you want to study more BC412 "EnjoySAP Controls" may help you.
    *--Serdar

  • ALV cell attributes CHANGE during DATA_CHANGED event

    Hi,
    I am working with CL_GUI_ALV_GRID in a splitter control. I am trying to make separate cells (non)editable depending on user input in the ALV. In event DATA_CHANGED (refefined) I change the cellstyle-table and then use method REFRESH_TABLE_DISPLAY.
    My problem is: I can change contents of fields perfectly, but when I change a cell's editability, the cell is being showns as editable, but when I press F4 f.i. and look in debug, the cellstyles-table hasn't been updated and still reflects the old values.
    Could anybody help me out?
    Kind regards,
    Roy
    P.S. Obviously I will reward points to useful answers.

    Hi Nithya,
    I am not making the field edit or no-edit using fieldcatalog-edit. This makes an emtire column editable. I only want to make individual cells editable.
    I do this using a table that I have attached to the ALV's structure and linked using layout-stylefname. You gave me an idea though: I might have to use SET_SELECTED_CELLS or an equivalent.
    Any other ideas that might be helpful?
    Kind regards,
    Roy

  • OO ALV validation check without event DATA_CHANGED and results via popup

    Hi Gurus,
    I'm working on SAP ECC 6.0 and I'm facing a problem during the ALV validation check. My requirement is to show an ALV with one editable field. In addition I have to pre-initialize this field in order to give a reference value to the user, but this is not always correct, or better, this field represent the maximum amount available, but, because of other validation checks, this field is not always correct (and it's ok, it's not a problem), and if it is greater than another amount I have to display an error.
    I was thinking about catching the event DATA_CHANGED and do the checks inside of it. It works but not completely, because if the user do not change anything the event is not raised and I cannot do my checks.
    My solution is to do the checks without catching the DATA_CHANGED event and display the errors in a separate popup window.
    The checks are ok, but I have problems during the displaying of the results: I would like to use the class CL_ALV_CHANGED_DATA_PROTOCOL in order to display the errors, I tried creating the Object:
      Data: go_Error Type Ref To CL_ALV_CHANGED_DATA_PROTOCOL.
      Create Object go_Error
        Exporting
    *      i_container =
          i_calling_alv = go_0200_Alv
    giving it a reference to the ALV (the go_0200_Alv is my CL_GUI_ALV_GRID object).
    Then I did many Call Methods to the Add_Protocol_Entry to add the message in the protocol and then display them calling the Display_Protocol Method of my "go_Error".
    The Popup is shown and the "links" to the ALV are correct (if I double click a message it selects the corresponding row of the ALV, but (and it's my problem) I cannot see the Description of the Column with the error: the popup window is an ALV grid itself with 3 columns ("Message Type", "Name of the Column" and "Message Text") where I can see correctly the Message Type and the Message Text but not the name of the column.
    Debugging the code I found that If I catch the event, the parameter er_Data_Changed (the class CL_ALV_CHANGED_DATA_PROTOCOL) is filled with some other informations like Modified Rows and other attributes like FieldCatalog, Row-ID, so I thought the problem was related to that, and that's why I replicated the whole case in my processing, filling every table I would see if I use the "standard way" for validation. Bu it didn't correct the error. I still don't see the name of the Column.
    This is my code, it's only the part interested, If you need other informations, please ask me and I will copy them.
    form CHECK_ALV_0200_0110 Changing pc_Error Type Char01.
      Data: lt_MatchK1 Type tp_Matches1_Key_t,
            l_Message  Type Char100,
            l_MessX    Type String,
            l_QtaRes   Type ZDM_AMT_ASSIGNED,
            l_QtaAcc   Type ZDM_AMT_ACCRUED,
            l_QtaStep  Type ZDM_AMT_ASSIGNED.
      Field-Symbols: <fs_Table>    Type Standard Table,
                     <fs_Master>   Type Standard Table,
                     <fs_Mod_Cell> Type LVC_S_MODI,
                     <fs_Line>     Type Any,
                     <fs_Field>    Type Any,
                     <fs_Any>      Type Any.
      Data lt_Matches_Alv_Mod Type tp_Matches1_Alv_t.
      Data ls_Modi Type LVC_S_MODI.
      Data: l_Row_ID Type I,
            l_Tabix  Type I.
      Field-Symbols: <fs_Match_ALV> Type tp_Matches1_Alv_s.
      Free go_Error.
      CREATE OBJECT go_Error
        EXPORTING
    *      i_container =
          i_calling_alv = go_0200_Alv
    * Validation Checks
      Clear pc_Error.
      Clear ls_Modi.
      Loop At gt_Matches1_Alv Assigning <fs_Match_ALV>.
        l_Tabix = Sy-Tabix.
        Check <fs_Match_ALV>-Status Eq con_Status_Temp.
    *   Set the Modified Row for the CL_ALV_CHANGED_DATA_PROTOCOL object
          Append <fs_Match_ALV> To lt_Matches_Alv_Mod.
          Add 1 To ls_Modi-Row_Id.
          ls_Modi-FieldName = 'AMT_DEDUCTED'.
          Write <fs_Match_ALV>-Amt_Deducted To ls_Modi-Value Currency <fs_Match_ALV>-Waers.
          Condense ls_Modi-Value No-Gaps.
          ls_Modi-Tabix = l_Tabix.
          Append ls_Modi To: go_Error->mt_Mod_Cells,
                             go_Error->mt_Good_Cells.
          l_Row_ID = ls_Modi-Row_Id.
        Clear l_Message.
        If <fs_Match_ALV>-Amt_Deducted Eq 0.
          pc_Error = con_X.
          CALL METHOD go_Error->Add_Protocol_Entry
            EXPORTING
              i_msgid     = 'ZDMV'
              i_msgty     = 'E'
              i_msgno     = '005'
    *          i_msgv1     =
    *          i_msgv2     =
    *          i_msgv3     =
    *          i_msgv4     =
              i_fieldname = 'AMT_DEDUCTED'
              i_row_id    = l_Row_ID
    *          i_tabix     =
          Continue.
        EndIf.
        Case g_Dynnr.
          When '0110'.
            Perform Get_ResQtaDispute1 Using lt_MatchK1
                                             <fs_Match_ALV>
                                       Changing l_QtaRes.
            Perform Get_ResQtaAccrued1 Using <fs_Match_ALV>
                                       Changing l_QtaAcc.
    *      When '0111'.
    *        Perform Get_ResQtaDispute2 Using lt_MatchK2
    *                                         <fs_Match_ALV>
    *                                   Changing l_QtaRes.
    *        Perform Get_ResQtaAccrued2 Using <fs_Match_ALV>
    *                                   Changing l_QtaAcc.
        EndCase.
        Add <fs_Match_ALV>-Amt_Deducted To l_QtaStep.
        If l_QtaStep > l_QtaRes.
    *     Store the Error
          pc_Error = con_X.
          Write l_QtaRes To l_Message Currency <fs_Match_ALV>-Waers.
          Condense l_Message No-Gaps.
          CALL METHOD go_Error->Add_Protocol_Entry
            EXPORTING
              i_msgid     = 'ZDMV'
              i_msgty     = 'E'
              i_msgno     = '002'
              i_msgv1     = l_Message
    *          i_msgv2     =
    *          i_msgv3     =
    *          i_msgv4     =
              i_fieldname = 'AMT_DEDUCTED'
              i_row_id    = l_Row_ID
    *          i_tabix     =
        EndIf.
        If l_QtaStep > l_QtaAcc.
    *     Store the Error
          pc_Error = con_X.
          Write l_QtaAcc To l_Message Currency <fs_Match_ALV>-Waers.
          Condense l_Message No-Gaps.
          CALL METHOD go_Error->Add_Protocol_Entry
            EXPORTING
              i_msgid     = 'ZDMV'
              i_msgty     = 'E'
              i_msgno     = '002'
              i_msgv1     = l_Message
    *          i_msgv2     =
    *          i_msgv3     =
    *          i_msgv4     =
              i_fieldname = 'AMT_DEDUCTED'
              i_row_id    = l_Row_ID
    *          i_tabix     =
        EndIf.
      EndLoop.
      If pc_Error Eq con_X.
    *   If there was at least one error, Display the Popup
        go_Error->mt_FieldCatalog[]   = gt_0200_FCat[].
        go_Error->ms_Layout-Zebra     = con_X.
        Get Reference Of lt_Matches_Alv_Mod[] Into go_Error->Mp_Mod_Rows.
        CALL METHOD go_error->display_protocol
    *      EXPORTING
    *        i_container        =
    *        i_display_toolbar  =
    *        i_optimize_columns =
      EndIf.
    EndForm.
    Do you know if there is a particular issue about that? Or, maybe, I'm doing something wrong...
    Please help me
    Regards,
    Claudio
    Edited by: Claudio Distrutti on Oct 31, 2008 12:38 PM

    Hello Claudio
    Nobody prevents you from calling your event handler method go_grid->HANDLE_DATA_CHANGED directly!
    What do I mean with that?
    I assume you are calling method go_grid->CHECK_CHANGED_DATA at the beginning of the PAI module to catch any changes from the editable ALV grid. Within the event handler method you do your validation and send the error popup if necessary.
    Now when the user closes the error popup and pushes e.g. the SAVE button then I can happen that method HANDLE_DATA_CHANGED does not trigger event DATA_CHANGED because nothing was indeed changed on the ALV grid. Yet the invalid value is still there.
    However within the FORM routine for saving the data you can just call your event handler method directly:
    FORM save_data.
    CALL METHOD go_grid->handle_data_changed
        EXPORTING
    *      er_data_changed =
          e_ucomm = 'SAVE'.
    ENDFORM.
    Now within your event handler method you always know when the method was called because if method CHECK_CHANGED_DATA triggers event DATA_CHANGED the IMPORTING parameter ER_DATA_CHANGED is bound whereas it is empty when the method is called from your SAVE routine.
    METHOD handle_data_changed.
      DATA: lo_log   TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
        IF ( er_data_changed IS BOUND ).
          lo_log = er_data_changed.
        ELSE.
          CREATE OBJECT lo_log.
        ENDIF.
    " Do the validations and send error log if necessary
      lo_log->DISPLAY_PROTOCOL( ).
    ENDMETHOD.
    Regards
      Uwe

  • DATA_CHANGED event handler is not triggered after input.(OO ALV)

    Dear Experts,
    What I did:
    I register Enter as the trigger event for data_changed event, and I put my checking logic in data_changed_handler which is a method of a local class. When the checking fails, I put messages using er_data_changed->add_protocal_entry to show messages.
    My checking is simple, if the cell is empty, error messages pops up tells that this cell can not be blank for this row.
    My problem:
    When there is no entry in the alv list(Only this situation), I insert a new entry, the cell which is required is empty, I press Enter, data_changed event is triggered, the message pops up saying that the cell is required. Then close the pop up message window, I input something in the cell, and press enter. The data_changed event is not triggered.
    Is there any1 has any ideas on this problem?
    Vicnent
    Edited by: Changjiu Tan on Sep 7, 2009 1:33 PM

      METHOD HANDLE_DATA_CHANGED.                               "#EC NEEDED
    *<<<  BEGIN MODIFY EXAMPLE CODE
    *   u4FDDu5B58u30C7u30FCu30BFu3092u7DE8u96C6u3059u308Bu3000START
        DATA: LW_INS      TYPE LVC_S_MOCE,
              LV_FNAME    TYPE LVC_FNAME,
              LW_MOD      TYPE LVC_S_MODI,
              LV_MAX      TYPE I,
              LV_RES(12)  TYPE C,
              LW_LIST     TYPE ZTSRE012,
              LV_ROWID    TYPE LVC_S_ROID,
              LT_MOD      TYPE LVC_T_MODI,
              LV_COLID    TYPE LVC_S_COL,
              LV_ROW_ID    TYPE LVC_S_ROW,
              LV_COL_ID    TYPE LVC_S_COL.
    *   u73FEu5728u306Eu30D5u30A9u30FCu30ABu30B9u4F4Du7F6Eu3092u53D6u5F97
        CALL METHOD GO_ALV_GRID7->GET_CURRENT_CELL
          IMPORTING
            ES_ROW_ID = LV_ROW_ID
            ES_COL_ID = LV_COL_ID.
        LOOP AT GT_LIST INTO LW_LIST.
          IF LW_LIST-ID > LV_MAX.
            LV_MAX = LW_LIST-ID.
          ENDIF.
        ENDLOOP.
    *   u30B0u30EBu30FCu30D7ID
        LV_FNAME = CNS_ID.
        LOOP AT ER_DATA_CHANGED->MT_INSERTED_ROWS INTO LW_INS.
          LV_MAX = LV_MAX + 1.
          CALL METHOD ER_DATA_CHANGED->MODIFY_CELL
            EXPORTING
              I_ROW_ID    = LW_INS-ROW_ID
              I_FIELDNAME = LV_FNAME
              I_VALUE     = LV_MAX.
        ENDLOOP.
        CLEAR: LV_FNAME.
        LT_MOD[] = ER_DATA_CHANGED->MT_GOOD_CELLS[].
    *   u30C7u30FCu30BFu30C1u30A7u30C3u30AF
        LOOP AT LT_MOD INTO LW_MOD.
          IF LW_MOD-FIELDNAME = CNS_ZZTTSN.
            LV_COLID-FIELDNAME = LW_MOD-FIELDNAME.
            LV_ROWID-ROW_ID    = LW_MOD-ROW_ID.
            CALL METHOD GO_ALV_GRID7->SET_CURRENT_CELL_VIA_ID
              EXPORTING
                IS_COLUMN_ID = LV_COLID
                IS_ROW_NO    = LV_ROWID.
            CALL METHOD GO_ALV_GRID7->GET_CURRENT_CELL
              IMPORTING
                E_VALUE = LV_RES.
            IF LV_RES IS INITIAL.
              CALL METHOD ER_DATA_CHANGED->ADD_PROTOCOL_ENTRY
                EXPORTING
                  I_MSGID     = CNS_MSGID
                  I_MSGTY     = CNS_MSGTY
                  I_MSGNO     = CNS_MSGNO
                  I_FIELDNAME = LW_MOD-FIELDNAME
                  I_ROW_ID    = LW_MOD-ROW_ID.
            ENDIF.
            CALL METHOD ER_DATA_CHANGED->MODIFY_CELL
              EXPORTING
                I_ROW_ID    = LW_MOD-ROW_ID
                I_FIELDNAME = LW_MOD-FIELDNAME
                I_VALUE     = LV_RES.
           ENDIF.
          CLEAR:  LV_RES,
                  LV_COLID,
                  LV_ROWID.
        ENDLOOP.
        CALL METHOD GO_ALV_GRID7->SET_CURRENT_CELL_VIA_ID
          EXPORTING
            IS_ROW_ID    = LV_ROW_ID
            IS_COLUMN_ID = LV_COL_ID.
      ENDMETHOD.                    "handle_data_changed
    Edited by: Changjiu Tan on Sep 7, 2009 1:31 PM
    Edited by: Changjiu Tan on Sep 7, 2009 1:32 PM

  • Problem handling data_changed event in OO ALV

    I'm displaying my internal table with an OO ALV and I'm trying to handle the data_changed event in order to do some checking before actually modify my internal table.
    this is the code of how I was planing to do that:
    handle_data_changed
            FOR EVENT data_changed OF cl_gui_alv_grid
                IMPORTING er_data_changed
                          e_onf4
                          e_onf4_before
                          e_onf4_after
                          e_ucomm.
    METHOD handle_data_changed.
    *    IF er_data_changed->mt_mod_cells-fieldname = 'COD_M'.
    *         do something
    *    else if er_data_changed->mt_mod_cells-fieldname = 'QUANTIDADE'.
    *         do something else
    *    endif.
    *  alv->refresh_table_display.
      ENDMETHOD.                           "handle_data_changed
    but it gives me this error:
    "MT_MOD_CELLS" is a table without a header line and therefore has no component called "FIELDNAME".
    My question is, how can access the cell that is being modified, and the new data?

    Dont know if this is the most clever way to do it but i solved it like this
    DATA: wa_data_changed TYPE lvc_s_modi,
              wa_tabi TYPE zsl_mat_c.
        READ TABLE er_data_changed->mt_mod_cells INDEX 1
                                                 INTO wa_data_changed.
        IF wa_data_changed-fieldname = 'COD_M'.
    *     do something
        ELSEIF wa_data_changed-fieldname = 'QUANTIDADE'.
    *     do something else
        ENDIF.
    thanks for your help

  • Trigger DATA_CHANGED event from triggered DATA_CHANGED event in second ALV

    Hello,
    I do have 2 ALVs (class CL_GUI_ALV_GRID) in a Splitter-Control.
    Both ALVs do have registered the event DATA_CHANGED in seperate handler methods.
    If there is a change in first ALV(line insertion with values), there will be inserted a new line with values in the second ALV.  After handling the event at first ALV, I call CHECK_CHANGED_DATA of the second ALV and REFRESH_TABLE_DISPLAY of the second ALV. I would expect that the call of CHECK_CHANGED_DATA would trigger the event DATA_CHANGED, but it does not trigger the event DATA_CHANGED of the second ALV.
    The problem is maybe that the input at the data is not made by the user(UI).
    What could I do to trigger this event and check the new data at second ALV?
    Yours Joerg

    Hello ,
    yeah thats correct , but in your case what you can do is
    g_grid1(first alv) >CHECK_CHANGED_DATA( Importing E_VALID =  l_Valid )>in the implementation method of this ..update global variable g_second = 'X' in order to refresh ALV2.
    g_grid1(first alv) -->Refresh_table_display( ).
    if g_second = 'X'.
    g_grid2-->SET_TABLE_FOR_FIRST_DISPLAY. so it will refresh the second alv contents.
    endif.
    regards
    Prabhu

  • ALV events for data_change  executing multiple times

    Hello Experts,
    I am using the event "data_changed" of cl_gui_alv_grid and its getting triggred multiple times based on
    no. of rows in my ALV grid output.
    For ex: if i have 5 rows and if i input a field in any cell in a new row, in data_changed event is triggered 2 times.
    The  LOOP AT er_data_changed->mt_mod_cells INTO ls_modified is executing 6 times as in above example
    even though is having only 1 entry.
    Can some one pls help me with this?
    Also i see the  toolbar event is often getting excuted multiples no of times making the application slow.
    Please suggest.
    Thanks
    Dan

    Dan,
    Maybe you've placed or doing something wrong, take this report as a pattern "BCALV_EDIT_03".
    Best regards,
    Alexandre

  • Problem in raising the event DATA_CHANGED in OOP ALV

    Hi experts,
    I am currently having trouble in raising the event 'data_changed' in my OOP ALV . The event is triggered everytime I make changes to my editable cells but when it comes to clicking on the save button, it only calls 'data_changed_finished' and bypasses 'data_changed'.
    I need to call 'data_changed' before the data is saved to do some verification.
    My code is shown below.
    CALL METHOD gr_alvgrid->register_edit_event
         EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    *--functions
        CALL METHOD gr_alvgrid->set_table_for_first_display
        EXPORTING
        is_variant           = s_variant
        i_save               = 'A'
        i_default            = gc_true
        is_layout            = gs_layout
        it_toolbar_excluding = gt_exclude
        CHANGING
        it_outtab            = gt_list
        it_fieldcatalog      = gt_fieldcat
        EXCEPTIONS
        invalid_parameter_combination = 1
        program_error = 2
        too_many_lines = 3
        OTHERS = 4 .
        IF sy-subrc <> 0.
    "raise message
        ENDIF.
    CREATE OBJECT gr_event.
    SET HANDLER gr_event->handle_data_changed FOR gr_alvgrid.
    SET HANDLER gr_event->handle_data_changed_finished FOR gr_alvgrid.
    CALL METHOD gr_alvgrid->set_toolbar_interactive.
    CALL METHOD gr_alvgrid->set_ready_for_input
                  EXPORTING i_ready_for_input = 1.
    In my PAI
    CASE ok_code.
        WHEN 'SAVE'.
    *--->this calls the event 'data_changed_finished' and bypasses  'data_changed'.*                                                     
    *Check if there's data changed.
          CALL METHOD gr_alvgrid->check_changed_data
            IMPORTING
              e_valid = l_valid.
      ENDCASE.
    I checked the sap sample program BCALV_EDIT_04 and I don't see any difference except for register_edit_event but I don't think that I can leave this out in my code . Is there any points i'm missing here?
    Thanks,
    Patrick

    Hi, Spin
    do like below,
    DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,
          cc_alv TYPE REF TO cl_gui_custom_container.
    IF cc_alv IS INITIAL. " USE This Condition
      CREATE OBJECT cc_alv
        EXPORTING
          container_name = 'CC_ALV'.
      CREATE OBJECT gr_alvgrid
        EXPORTING
          i_parent = cc_alv.
      CALL METHOD gr_alvgrid->set_table_for_first_display
        EXPORTING
          is_variant                    = s_variant
          i_save                        = 'A'
          i_default                     = gc_true
          is_layout                     = gs_layout
          it_toolbar_excluding          = gt_exclude
        CHANGING
          it_outtab                     = gt_list
          it_fieldcatalog               = gt_fieldcat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc = 0.
        "raise message
      ENDIF.
    ENDIF.
    Please reply if any Issue,
    Thanks and Regard,
    Faisal

  • ALV, event DATA_CHANGED, avoid insert of duplicate key

    Hello,
    I would like to implement edit functionality of an internal table with ALV based on class CL_GUI_ALV_GRID. Some fields of internal table are key fields and the combination of them should be unique. The user has a possibility to add a new record (all fields in new record are editable) or change values in an existing record (only non-key fields are editable). So far so good, it works.
    I'm doing a validation of entered data in the event DATA_CHANGED. In this event I'm checking if the new record is a duplicate combination of existing key fields. If yes, then all fields of the new record are reported as error with ADD_PROTOCOL_ENTRY method. This removes all entries related to this row from MT_GOOD_CELLS table and this is ok for me.
    My problem: after validation ALV inserts such empty row in my internal table and next time, when the user makes a correction, this record is an update and not a new record (there is no entry in MT_INSERTED_ROWS).
    Question: Is there a possibility to avoid ALV inserting a new record when all its cells are bad?
    Regards,
    Annie

    Hi,
    As far as i have understood your problem,you can try the following to avoid the insertion of an empty row:
    When you must be creating an empty row,just set a flag say flag_create = 'X'.
    Then when you are performing the validation then if there is an error then check for this flag that is :
    if flag_create = 'X'.
    then delete from the internal table based on sy-tabix.
    endif.
    This way the new row that got appended with wrong values will get deleted and the code will not consider this as an updated row.
    Kindly <<deleted> if useful.:)
    Follow the rules of engagement
    Edited by: Vijay Babu Dudla on Jan 9, 2012 7:07 AM

  • Set ALV cell, use of event DATA_CHANGED

    Hi experts,
    I want to set some ALV input fields using abap.
    That's easy, I can modify the table as I need and call the refresh of the ALV table ( refresh_table_display).
    But how can I "fill" the fields that the event DATA_CHANGED is called?
    When I fill manually in ALV, this event is raised...I need the event also when filling with ABAP...
    Thanks in advance
    Michael

    Hello Michael,
    This link shows you the right way to do:
    Get Changed Value In ALV Grid Dynamically - ABAP Development - SCN Wiki
    Inside HANDLE_DATA_CHANGED method, you can change the value of a cell in this way:
    CALL METHOD PR_DATA_CHANGED->MODIFY_CELL
        EXPORTING
          I_ROW_ID    = IT_TABLE-ROW_ID
          I_FIELDNAME = 'FIELD'
          I_VALUE     = IT_FLIGHT-FIELD.
    I hope you help.

  • ALV-Event data_changed after searchhelp with userdefined searchhelpexit

    Hi there ...
    I'm using an OO alv grid with an elementary searchhelp at defined fields.
    the search help uses an searchhelpexit, that simply filters data, to show the right stuff
    everything works fine!
    dependent on the returned value of the searchhelp, I need to trigger a recalculation of values.
    the alv-event "data_changed" looks interesting for that issue ... especially the flag "e_onf4_after" ...
    BUT: I don't know, when the flag is set :$
    the event is raised (with marked flags "e_onf4" and "e_onf4_before") before the Searchhelplist is displayed .... but I need to react AFTER the searchhelp is closed and the selected value is returned ...
    all I want to do is:
    trigger the recalculation after the user selected a value at the searchhelp
    can anybody help me in that case?!
    thanks a lot  & enjoy your weekend
    Markus

    Hi,
    You can call elementary search help like any popup screen
    with function F4IF_FIELD_VALUE_REQUEST.
    - Call f4 help manually in the event DATA_CHANGED
    - Process your recalculation
    - set values on cells..
    I hope it helps.

  • ALV event  data_changed error

    Hello everybody,
    I have a one  editable field in ALV. After 'ENTER'  I want do some actions ( check input , save data into DB table...).
    CLASS lcl_gui DEFINITION CREATE PROTECTED.
      PUBLIC SECTION.
        DATA: mor_alv    TYPE REF TO cl_gui_alv_grid,
    METHODS:   alv_init,
                        alv_changed FOR EVENT data_changed
                                             OF cl_gui_alv_grid
                                             IMPORTING er_data_changed,
                        register_events,
    METHOD register_events .
       CALL METHOD mor_alv->register_edit_event
         EXPORTING
         i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        SET HANDLER me->alv_changed FOR mor_alv.
      ENDMETHOD.
    After  I change field and pres 'ENTER' I get popup with message "Programs error" and program exits.
    (On the screen in other container I  also have  ALV Tree-CL_GUI_ALV_TREE , maybe it is impotrant to mention...)
    Please help.

    Hi Sandeep,
    as I said I just get popup wit error message "Program errors" with just "Exit" button, when I press the button program exits.
    I get no runtime error, just this popup.
    Regards
    Jan.

  • ALV Grid editable - How to raise the data_changed event from outside object

    Hi,
    i'd like to like to raise the data_changed event from outside the ALV-Grid object in order to display errors to the user.
    For example a new row was inserted within the program. The user has only to complete the missing informations. Before saving the transactions the program has to execute some semantic checks. The errors of this check process should be shown to the user by creating an instance of the cl_alv_changed_data_portocol object.
    Thanks.
    Regards

    You don't need to raise the data_changed event to perform the edits or to issue messages using cl_alv_changed_data_protocol.
    The following assumes you have an ALV grid object g_alv based on the CL_GUI_ALV_GRID class.
    You can mark the inserted records upon insertion as selected using the set_selected_rows method, and then retrieve these rows later using get_selected_rows and perform necessary edits.
    Save the row number of each inserted row into a table of the appropriate type (see the method definition for this):
    DATA: t_index_rows    TYPE  lvc_t_row.
    DATA: s_row_no        TYPE  lvc_s_roid.
    DATA: t_row_no        TYPE  lvc_t_roid.
    Load entries into t_row_no after each insert.  Capture the row number and save in the table t_row_no.
    e.g.
    PERFORM insert_row USING s_row_no-row_id.
    APPEND s_row_no TO t_row_no.
    FORM insert_row would have whatever code you are using to insert the row.  Save the row id into s_row_no-row_id (which is an INT4).
    When done with all inserts do the following
      IF t_row_no[] IS NOT INITIAL.
        CALL METHOD g_alv->set_selected_rows
          EXPORTING
            it_index_rows            = t_index_rows
            it_row_no                = t_row_no
            is_keep_other_selections = 'X'.
      ENDIF.
    Then, if SAVE is pressed without the data_changed event having been raised (such as if the user just pressed SAVE without changing anything), use method get_selected_rows to retrieve the rows that were inserted and perform the necessary edits.
      DATA: l_t_rows    TYPE lvc_t_row.              " ALV control: Table rows
      CALL METHOD g_alv->get_selected_rows
        IMPORTING
          et_index_rows = l_t_rows.
    Loop through l_t_rows and use the row as an index into the grid, perform the necessary edits, just as you would if the data_changed event had been raised.
    If any edits fail, then send messages to the user, abort the save, and re-display the grid.
    Remember to refresh the t_row_no and t_index_rows tables if you load a new data set.
    You can also use a similar technique with the data_changed event to mark each changed row as selected by saving the row ids, and then you only have to update the changed rows on SAVE, which can minimize database I/O.
    Good luck.
    Brian

Maybe you are looking for