ALV Grid update

Hi All,
I have a requirement.
In the ALV grid, I have to select a row. When I click the change ICON, the data in the rows should be populated in the customized screen.
I had already done this part.
Now I had changed the values in the customized screen. When I click the 'SAVE' button in the customized screen, the data in the screen should be passed to the GRID.
Here, I had updated the table which is used in the GRID. But, how to refresh the GRID, so that I can see the changed values in the GRID.
I had used refresh_table_display method.. But it prompts me an error.. and the program is exited.
If anyone had done this.. kindly send me the code.... or help me out how to proceed.
Thanks in advance.
Jaffer Ali.S

From what you say, since you are using an Information Message, irrespective of whether the user wants it or not, the ALV Grid has to be updated with the calculations that you do. He cannot choose to cancel the operation. Am I correct?
If yes, then all you need to do is to update the ALV output table with the calculations that you have done and call the method refresh_table_display.
see this example program
believe that the after the info message you are updating the ALV grid value. Then try these out,
to update the ALV grid,
call method addressbook_grid->set_ready_for_input
exporting
i_ready_for_input = 1. " Sets to edit mode
data : w_intab1 like table of zc1address with header line .
Here update is performed using a work area
you can also specify the partcular column and update it.
update zc1address from table t_intab1.
if sy-subrc = 0.
message i000. " success message
else.
message i001. " unsuccess message
endif.
refreshing the grid to display the modified values
call method addressbook_grid->refresh_table_display.
sets ALV grid to display mode.
call method addressbook_grid->set_ready_for_input
exporting
i_ready_for_input = 0.

Similar Messages

  • ALV GRID update internal table

    Hi all,
    I have an internal table display in a ALV GRID. Only one column is editable. When I change the field value, ALV GRID display the change, but when I click on refresh return the old value.
    I've checked in DEBUG mode and when I click on refresh (in the PAI module), the internal table haven't data modified.
    For example: the field qta have value 15. I change it in 18 and then press Refresh. In debug, the field qta still have the value 15.
    What I have to do?

    Hi
    The Example prg is using Classes, then you need to use the same approach in the way i mentioned below...
    You need to Update the ITAB with the Modifeid values.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Handler to Check the Data Change
        HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                             OF CL_GUI_ALV_GRID
                             IMPORTING ER_DATA_CHANGED
                                       E_ONF4
                                       E_ONF4_BEFORE
                                       E_ONF4_AFTER.
    ENDCLASS.                    "lcl_event_handler
    DEFINITION
    **Handle Data Change
      METHOD HANDLE_DATA_CHANGED.
        DATA: X_CHANGE TYPE LVC_S_MODI,
              X_FINAL TYPE T_FINAL,
              X_OCRC TYPE ZSD_OC_HOLD,
              L_FLAG.
        LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
          IF X_CHANGE-FIELDNAME = 'ZZOCHOLDRC'.
            READ TABLE IT_FINAL INTO X_FINAL INDEX X_CHANGE-ROW_ID.
            IF SY-SUBRC = 0.
              READ TABLE IT_OCRC INTO X_OCRC WITH KEY
                                             ZZOCHOLDRC = X_CHANGE-VALUE
                                            TRANSPORTING ZZRCDESC.
              IF SY-SUBRC = 0.
                X_FINAL-ZZRCDESC = X_OCRC-ZZRCDESC.
                MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID
                                             TRANSPORTING ZZRCDESC.
                L_FLAG = 'X'.
              ENDIF.
            ENDIF.
          ENDIF.
          IF X_CHANGE-FIELDNAME = 'ZZPROMDT'.
            READ TABLE IT_FINAL INTO X_FINAL INDEX X_CHANGE-ROW_ID.
            IF SY-SUBRC = 0.
              X_FINAL-ZZPROMDT = X_CHANGE-VALUE.
              MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID
                                           TRANSPORTING ZZPROMDT.
              L_FLAG = 'X'.
            ENDIF.
          ENDIF.
        ENDLOOP.
        IF L_FLAG = 'X'.
          CLEAR V_DATA_CHANGE.
          V_DATA_CHANGE = 'X'.
        ENDIF.
      ENDMETHOD.                    "data_changed
    **you need to SET the HANDLER after the method first display.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.
    try this
    vijay

  • How to update data in the database through ALV grid

    Hi All,
    I diplayed an ALV grid with five fields in a classical report. I have already set the fieldcat for one field as wa_fcat_edit = 'X'. I am able to edit(modify) the data in that field. But I want to update the data into the database which is modified by me in that field. Can I update the data using BDC or any other procedure?
    This is an urgent require ment for me. Please help me ASAP.
    Thanks & Regards,
    Ramesh.

    Hi
    Please go through the link.
    Link: [http://www.****************/Tutorials/ALV/Edit/demo.htm]
    regards
    ravisankar

  • Update values in AlV grid display after entering value

    Hi,
         I have an issue in ALV grid display.
        Let me explain.
        i have 8 fields to display in which one is editiable.
       Fields are: date
                       material,
                       material Description,
                       Opening Stock,
                       Closing stock-  (  this field is editiable)
                       Closing stock,
                       Received Stock,
                       Actual production.
    Actual production = Closing stock + removal stock
                                 - receipt stock - opening stock.
    when i change the value of closing stock and press enter, actual production should get update, the new values should display.
    Thany you in advance.

    Hi,
    Please refer the code below:
    REPORT z_demo_alv_jg.*******************************************************************
    * TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    * INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    * FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    * SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    * START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    * entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    * Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.*&-----------------------------------------------------------------*
    *&      Form  SET_PF_STATUS
    *       Setting custom PF-Status
    *      -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS*&----------------------------------------------------------------*
    *&      Form  user_command
    *       Handling custom function codes
    *      -->R_UCOMM      Function code value
    *      -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
    *         and populate it in an internal table for future
    *         action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
    *       and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command
    Thanks,
    Sriram Ponna.

  • Checkbox cant be updated in ALV Grid

    Hi in my requirement, ALV Grid contains checkbox, when I check that, the internal table for checkbox is not updated.
    In code I am writting:
    Final Internal Tbale:
    Data:   BEGIN OF T_FINAL occurs 0,
            CHK_BOX,
            END OF T_FINAL.
      LS_FIELDCAT-TABNAME = t_final.
      LS_FIELDCAT-COL_POS = 1.
      LS_FIELDCAT-FIELDNAME = 'CHK_BOX'.
      LS_FIELDCAT-SELTEXT_S = ‘check box’.
      LS_FIELDCAT-INPUT = 'X'.
      LS_FIELDCAT-OUTPUTLEN = 1.
      LS_FIELDCAT-CHECKBOX = 'X'.
      LS_FIELDCAT-EDIT = 'X'.
      APPEND LS_FIELDCAT TO LT_FIELDCAT.
      CLEAR LS_FIELDCAT.
    DATA: I_CHECK TYPE TABLE OF T_FINAL,
             WA_CHECK TYPE T_FINAL.
      LOOP AT I_FINAL INTO WA_FINAL.
        IF WA_FINAL-CHK_BOX = 'X'.
          APPEND WA_FINAL TO I_CHECK.
    { APPEND WA_FINAL TO I_CHECK[]      also I try}
        ENDIF.
      ENDLOOP.
    In layout:
    LS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LS_LAYOUT-BOX_FIELDNAME = 'CHK_BOX'.

    try this its working for me......
    *& Report  ZHR_REPT_EMP_NOT_PBOOKED
    *& Program title:    List of employees who have not done Pre-Booking and
                        Provision to send E mail to such employees
    *& Description:      To display a list of emloyees in report and then sending mails to them
    *& Business analyst: Vinay Kale/Abhijeet More
    *& Developed by:     Vivek Jain
    REPORT  ZHR_REPT_EMP_NOT_PBOOKED.
    TYPE-POOLS slis.
    tables
    TABLES: pernr,
            pa0001,
            hrp1001,
            hrp1000,
            zodtab,
            zcstab,
            zsbutab.
    Infotypes
    INFOTYPES :0001,  "org assignment,
               1001,
               1000,
               0105.
    TYPES : BEGIN OF i_conf,
              checkbox ,
              pernr TYPE pa0001-pernr,                  "personnel Number.
              ename TYPE pa0001-ename,                  "Name of Employee.
              zzbtc TYPE pa0001-zzbtc,                  "Band.
              btrtl  TYPE pa0001-btrtl,                 "Grade
              Location type string,
              persk type string,
              ptext type string,
              werks TYPE p0001-werks,
              zzod_txt type string,                         "OD name
              zzod type pa0001-zzod,
              zzcs type string,                         "cluster/sector
              vertical type string,
              sbu LIKE pa0001-zzsbu,                    "SBU
              sbutxt LIKE zsbutab-zsbutxt,              "SBUTXT
              orgeh LIKE pa0001-orgeh,                  "Vertical
              org_text type string,
              zzbloc LIKE pa0001-zzbloc,                "base location
              dept_loc type string,                     "dept loc
              ename_s LIKE pa0001-ename,                "Department
              zztc LIKE pa0001-zztc,
              endda type p0001-endda,
             celltab type lvc_t_styl,
            tc_name type string,
           tc_num type string,
            END OF i_conf.
    DATA : it_conf TYPE STANDARD TABLE OF i_conf WITH HEADER LINE,
           wa_conf TYPE i_conf.
    *data: begin of gs_outtab.
    *data: checkbox type c.                "field for checkbox
    §B1.Extend your output table by a field to dis- or enable
        cells for input.
    *data: celltab type lvc_t_styl.        "field to switch editability
           include structure i_conf.
    *data: end of gs_outtab.
    *data: gt_outtab type gs_outtab occurs 0 with header line.
    *& DATA DECLARATION FOR EMAIL
    DATA: docdata    TYPE sodocchgi1,
          objpack    TYPE STANDARD TABLE OF sopcklsti1 WITH HEADER LINE,
          objhead    TYPE STANDARD TABLE OF solisti1   WITH HEADER LINE,
          objtxt     TYPE STANDARD TABLE OF solisti1   WITH HEADER LINE,
          objbin     TYPE STANDARD TABLE OF solisti1   WITH HEADER LINE,
          reclist    TYPE STANDARD TABLE OF somlreci1  WITH HEADER LINE.
    DATA: tab_lines  TYPE sy-tabix.
    DATA : p_1001 TYPE TABLE OF p1001 WITH HEADER LINE.
    DATA : p_0001 TYPE TABLE OF p0001 WITH HEADER LINE.
    DATA : p_0105 TYPE TABLE OF p0105 WITH HEADER LINE.
    DATA : od TYPE p0001-zzod.
    DATA : new_pernr type p0001-pernr.
    DATA : pernr_s type p0001-pernr.
    DATA : email_s type p0105-USRID_LONG.
    DATA : email type p0105-USRID_LONG.
    DATA : tc_name type string.
    DATA : tc_num type string.
    DATA : emails type string.
    DATA : sel_all type string.
    DATA: REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA : flag type i.
    DATA : title TYPE string.
    DATA : pernr_temp tYPE p0001-pernr.
    DATA : rel type string.
    DATA : stat type string.
    DATA : count type i.
    DATA :   v_dynnr type sy-dynnr.
    DATA : g_grid  type ref to cl_gui_alv_grid.
    DATA : g_custom_container type ref to cl_gui_custom_container,
          g_container type scrfname value 'CC'.
    ************field cat*******************************
    DATA:  fieldcat TYPE  lvc_t_fcat,
           wa_fieldcat LIKE LINE OF fieldcat.
    DATA:  gd_layout TYPE lvc_s_layo,
          gd_repid TYPE sy-repid.
    DATA:gt_events TYPE slis_t_event,
          gt_list_top_of_page TYPE slis_t_listheader.
    DATA rec_fetched TYPE sy-tabix.
    CONSTANTS g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
    SELECTION-SCREEN BEGIN OF  BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:   s_zzod    FOR   zsbutab-zod       NO INTERVALS ,
                      s_btrtl  FOR   pa0001-btrtl     NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK b1.
    start-of-selection.
      if pn-begda is initial.
        pn-begda = '18000101'.
      endif.
      if pn-endda is initial.
        pn-begda = '99991230'.
      endif.
      clear : it_conf,it_conf[].
    get pernr.
      clear new_pernr.
      move pernr-pernr to new_pernr.
    *************checking whether employee has booked or prebooked for any event***************
      clear: p_1001,p_1001[].
      perform read_info tables p_1001 using  new_pernr '1' 'B027' .
      IF SY-SUBRC <> 0.
        clear: p_1001,p_1001[].
        perform read_info tables p_1001 using  new_pernr '1' 'B023' .
        IF SY-SUBRC <> 0.
          clear: p_1001,p_1001[].
          perform read_info tables p_1001 using  new_pernr '2' 'B027' .
          IF SY-SUBRC <> 0.
            clear: p_1001,p_1001[].
            perform read_info tables p_1001 using  new_pernr '2' 'B023' .
            IF SY-SUBRC <> 0.
              clear : p_0001,p_0001[].
              CALL FUNCTION 'HR_READ_INFOTYPE'
                EXPORTING
                  pernr           = new_pernr
                  infty           = '0001'
                  BEGDA           = pn-begda
                  ENDDA           = pn-endda
                TABLES
                  infty_tab       = p_0001
                EXCEPTIONS
                  infty_not_found = 1
                  OTHERS          = 2.
              sort p_0001 descending by begda.
              read table p_0001 index 1.
              move p_0001-pernr to wa_conf-pernr.
              move p_0001-ename to wa_conf-ename.
              move p_0001-zzbtc to wa_conf-zzbtc.
              move p_0001-btrtl to wa_conf-btrtl.
              move p_0001-werks to wa_conf-werks.
              move p_0001-zzsbu to wa_conf-sbu.
              move p_0001-orgeh to wa_conf-orgeh.
              move p_0001-zzbloc to wa_conf-zzbloc.
              move p_0001-zztc to wa_conf-zztc.
              move p_0001-zzod to wa_conf-zzod.
              move p_0001-endda to wa_conf-endda.
              move p_0001-btrtl to wa_conf-btrtl.
    ***************************sending mail to employee and his/her superior***********************************
             select single  sachn  telnr  into (wa_conf-tc_name , wa_conf-tc_num) from t526
            where SACHX = it_conf-zztc
            and werks = it_conf-werks .
    **************clustor txt*********************
              select single zcstxt into wa_conf-zzcs from zcstab
                                                    where  zcs = p_0001-zzcs
                                                    and zod = p_0001-zzod.
    **********operating division******************************
              select single ZODLTXT into  wa_conf-zzod_txt from zodtab
                                                 where zod = wa_conf-zzod.
    **********sbu txt**************************************************************
              select single zsbutxt into wa_conf-sbutxt from zsbutab
                                            where zsbu = wa_conf-sbu.
    **********location*************************************
              select single btext into wa_conf-location from t001p
                                                 where  btrtl = wa_conf-btrtl
                                                 and werks = wa_conf-werks.
    **********Dept********************************************
              select single orgtx into wa_conf-org_text from t527x
                                                  where sprsl = 'EN'
                                                  and orgeh = wa_conf-orgeh
                                                  and  begda <= p_0001-begda
                                                  and endda >= p_0001-begda.
    **************grade*****************************************
              SELECT SINGLE ptext FROM t503t INTO  wa_conf-persk
                                              WHERE sprsl = 'EN'
                                              AND persk = p_0001-persk .
    *******************vertical****************************
    select single zverttxt into wa_conf-vertical from zvtab
                                 where zvert = p_0001-zzvert.
    *******deputation location*****************
      if p_0001-ZZDEPFLG = 'X'.
         select single zdltxt into wa_conf-dept_loc from zdltab where zdl = p_0001-zzdploc.
    endif.
    ***get imm superior
              CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
               EXPORTING
                 pernr     =  new_pernr
             begda     = '18000101'
             endda     = '99991231'
               IMPORTING
                 v_pernr   = pernr_s
               EXCEPTIONS
                 not_found = 1
                 OTHERS    = 2.
              if sy-subrc = 0.
    find the email of the immed. superiors personal number..
                clear : p_0001,p_0001[].
                CALL FUNCTION 'HR_READ_INFOTYPE'
                  EXPORTING
                    pernr           = pernr_s
                    infty           = '0001'
                    BEGDA           = pn-begda
                    ENDDA           = pn-endda
                  TABLES
                    infty_tab       = p_0001
                  EXCEPTIONS
                    infty_not_found = 1
                    OTHERS          = 2.
                read table p_0001 index 1.
                move p_0001-ename to wa_conf-ename_s.
              endif.
              if wa_conf-btrtl in s_btrtl and wa_conf-zzod in s_zzod .
                append wa_conf to it_conf.
              endif.
            endif.
          endif.
        endif.
      endif.
      clear wa_conf.
    end-of-selection.
       if it_conf[] is initial.
          MESSAGE i501(zmod).
          exit.
          endif.
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'USER'.
    SET TITLEBAR 'xxx'.
      if g_custom_container is  initial.
        data: lt_exclude type ui_functions.
        create object g_custom_container
          EXPORTING
            container_name = g_container.
        create object g_grid
          EXPORTING
            i_parent = g_custom_container.
        perform fieldcat_build .
    Exclude all edit functions in this example since we do not need them:
        perform exclude_tb_functions changing lt_exclude.
    perform build_data.
    *§ B3.Use the layout structure to aquaint additional field to ALV.
        gd_layout-stylefname = 'CELLTAB'.
        PERFORM build_layout.
        if it_conf[] is initial.
         MESSAGE i501(zmod).                    "No data exists
        else.
          call method g_grid->set_table_for_first_display
            EXPORTING
              is_layout            = gd_layout
              it_toolbar_excluding = lt_exclude
            CHANGING
              it_fieldcatalog      = fieldcat
              it_outtab            = it_conf[].
    create object g_event_receiver.
    set handler g_event_receiver->catch_doubleclick for g_grid.
    Set editable cells to ready for input initially
          call method g_grid->set_ready_for_input
            EXPORTING
              i_ready_for_input = 1.
        endif.
      endif.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *call screen 100.
    *&      Form  build_layout
    FORM build_layout.
      CLEAR gd_layout.
      v_dynnr = 100.
      gd_layout-cwidth_opt = 'X'.
    gd_layout-zebra      = 'X'.
    gd_layout-grid_title = text-002.
    ENDFORM.                    "build_layout
    *&      Form  exclude_tb_functions
          text
         -->PT_EXCLUDE text
    form exclude_tb_functions changing pt_exclude type ui_functions.
      data ls_exclude type ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      append ls_exclude to pt_exclude.
    endform.                    "exclude_tb_functions
    *&      Form  field_cat
          text
    FORM fieldcat_build .
      wa_fieldcat-fieldname  = 'CHECKBOX'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      wa_fieldcat-checkbox   = 'X'.
      wa_fieldcat-edit   = 'X'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'PERNR'.
      wa_fieldcat-coltext = 'P.S. No'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'ENAME'.
      wa_fieldcat-coltext = 'Employee Name'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'ZZBTC'.
      wa_fieldcat-coltext = 'Band'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'PERSK'.
      wa_fieldcat-coltext = 'Grade'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'ZZOD_TXT'.
      wa_fieldcat-coltext = 'OD Name'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'ZZCS'.
      wa_fieldcat-coltext = 'Cluster / Sector '.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
       wa_fieldcat-fieldname  = 'VERTICAL'.
      wa_fieldcat-coltext = 'Vertical'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'SBUTXT'.
      wa_fieldcat-coltext = 'SBU'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'ORG_TEXT'.
      wa_fieldcat-coltext = 'Dept.'.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'LOCATION'.
      wa_fieldcat-coltext = 'Empl. Base Location '.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
       wa_fieldcat-fieldname  = 'DEPT_LOC'.
      wa_fieldcat-coltext = 'Empl. Deputation Location '.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-fieldname  = 'ENAME_S'.
      wa_fieldcat-coltext = 'IS Name '.
      wa_fieldcat-tabname   = 'IT_CONF'.
      APPEND wa_fieldcat TO fieldcat.
      clear wa_fieldcat.
    endform.                    "field_cat
    *&      Form  check_lock
          text
         -->PS_OUTTAB  text
         -->P_LOCKED   text
    form check_lock using    ps_outtab type i_conf
                    changing p_locked.
      data ls_celltab type lvc_s_styl.
      loop at ps_outtab-celltab into ls_celltab.
        if ls_celltab-fieldname = 'CHECKBOX'.
          if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
            p_locked = 'X'.
          else.
            p_locked = space.
          endif.
        endif.
      endloop.
    endform.                    "check_lock
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      IF sy-ucomm = 'EMAIL'.
        clear it_conf.
       CALL METHOD g_grid->refresh_table_display.
        data: ls_outtab type i_conf.
        data: l_valid type c,
              l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
          you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
        call method g_grid->check_changed_data
          IMPORTING
            e_valid = l_valid.
        if l_valid eq 'X'.
          loop at it_conf  into ls_outtab.
            if     not ls_outtab-checkbox is initial
               and not ls_outtab-checkbox eq '-'.
    ***************************sending mail to employee and his/her superior***********************************
              select single  sachn  telnr  into (tc_name , tc_num) from t526
             where SACHX = ls_outtab-zztc
             and werks = ls_outtab-werks .
      ******find the emil of employee.
              clear : p_0105,p_0105[].
              CALL FUNCTION 'HR_READ_INFOTYPE'
                EXPORTING
                  pernr           = ls_outtab-pernr
                  infty           = '0105'
                  BEGDA           = pn-begda
                  ENDDA           = pn-endda
                TABLES
                  infty_tab       = p_0105
                EXCEPTIONS
                  infty_not_found = 1
                  OTHERS          = 2.
              if sy-subrc = 0.
                read table p_0105 with key subty = '0010'.
                move p_0105-USRID_LONG to email.
              endif.
    find immediate superior by Z FM.
              clear pernr_s.
              CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
                EXPORTING
                  pernr     = ls_outtab-pernr
                IMPORTING
                  v_pernr   = pernr_s
                EXCEPTIONS
                  not_found = 1
                  OTHERS    = 2.
              if sy-subrc = 0.
    find the email of the immed. superiors personal number..
                clear : p_0105,p_0105[].
                CALL FUNCTION 'HR_READ_INFOTYPE'
                  EXPORTING
                    pernr           = pernr_s
                    infty           = '0105'
                    BEGDA           = pn-begda
                    ENDDA           = pn-endda
                  TABLES
                    infty_tab       = p_0105
                  EXCEPTIONS
                    infty_not_found = 1
                    OTHERS          = 2.
                read table p_0105 with key subty = '0010'.
                move p_0105-USRID_LONG to email_s.
              endif.
              if email <> ' '.
                count = 1.
                perform send_mail using ls_outtab-ename email email_s tc_name tc_num count .
              endif.
              if email_s <> ' '.
                count = 2.
                perform send_mail using ls_outtab-ename email email_s tc_name tc_num count.
              endif.
              call method g_grid->refresh_table_display.
              modify it_conf  from ls_outtab.
            endif.
          endloop.
          call method g_grid->refresh_table_display.
        endif.
        set screen 100.
      endif.
    **************************end of sending mail****************************************************
      IF sy-ucomm = 'SELECT'.
    CALL METHOD g_grid->refresh_table_display.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
          you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
        call method g_grid->check_changed_data
          IMPORTING
            e_valid = l_valid.
        if l_valid eq 'X'.
          loop at it_conf into ls_outtab.
            perform check_lock using    ls_outtab
                               changing l_locked.
            if l_locked is initial
               and not ls_outtab-checkbox eq '-'.
              ls_outtab-checkbox = 'X'.
            endif.
            modify it_conf from ls_outtab.
          endloop.
          call method g_grid->refresh_table_display.
        endif.
        set screen 100.
      endif.
      IF sy-ucomm = 'BCK'  and v_dynnr = 100.
        clear v_dynnr.
        set screen 1000.
        leave screen.                                           " 0."1000.
    **call selection-screen 1000.
    *call screen 1000.
      endif.
      IF sy-ucomm = 'EXIT'  and v_dynnr = 100.
        clear v_dynnr.
        leave program.
      endif.
      IF sy-ucomm = 'CANC'  and v_dynnr = 100.
        clear v_dynnr.
        leave program.
      endif.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  send_mail
          text
         -->EMAIL_S    text
         -->EMAIL      text
         -->TC_NAME    text
         -->TC_NUM     text
    form send_mail using  ename email email_s tc_name tc_num count.
    *Body of mail
      CLEAR objtxt.
      CLEAR objtxt[].
      objtxt = text-005.
      concatenate objtxt ename into objtxt separated by space.
      append objtxt.
      clear objtxt.
      objtxt = text-006.
      concatenate objtxt email_s into objtxt separated by space.
      append objtxt.
      clear objtxt.
      append objtxt.
      objtxt = text-002.
      append objtxt.
      clear objtxt.
      objtxt = text-003.
      append objtxt.
      clear objtxt.
      append objtxt.
      objtxt = text-004.
      concatenate objtxt tc_name 'at' tc_num into objtxt separated by space.
      append objtxt.
      clear objtxt.
      DESCRIBE TABLE objtxt LINES tab_lines.
      READ TABLE objtxt INDEX tab_lines.
    *Mail description
      CLEAR docdata.
      docdata-doc_size  = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
      docdata-obj_name  = 'Reminder'.
      docdata-obj_descr = 'REMINDER TO DO PRE-BOOKING'.
      docdata-obj_langu = sy-langu.
    *Packing list for main document
      CLEAR objpack.
      CLEAR objpack[].
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = 'RAW'.
      APPEND objpack.
    *Email receiver's list
      CLEAR reclist.
      CLEAR reclist[].
      if count = 1.
    reclist-receiver = '[email protected]'.
        reclist-receiver = email.
      else.
        reclist-receiver = email_s.
      endif.
      reclist-rec_type = 'U'.
      APPEND reclist.
      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 FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = docdata
          document_type              = 'RAW'
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          object_content             = objtxt
          receivers                  = reclist
        EXCEPTIONS
          TOO_MANY_RECEIVERS         = 1
          DOCUMENT_NOT_SENT          = 2
          DOCUMENT_TYPE_NOT_EXIST    = 3
          OPERATION_NO_AUTHORIZATION = 4
          PARAMETER_ERROR            = 5
          X_ERROR                    = 6
          ENQUEUE_ERROR              = 7
          OTHERS                     = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
       message 'mail(s) sent successfully' type 'S'.
      ENDIF.
    endform.                    "send_mail
    *&      Form  eventtab_build
    FORM eventtab_build USING rt_events TYPE slis_t_event.
    *Registration of events to happen during list display
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = rt_events.
      READ TABLE rt_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
      IF sy-subrc = 0.
        MOVE g_top_of_page TO ls_event-form.
        APPEND ls_event TO rt_events.
      ENDIF.
    ENDFORM.                    "eventtab_build
    *&      Form  top_of_page
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    "top_of_page
    *&      Form  COMMENT_BUILD
    FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.
      DATA: ls_line TYPE slis_listheader,
              rp_date TYPE string.              "report date
    LIST HEADING LINE: TYPE H
      CLEAR ls_line.
      ls_line-typ  = 'H'.
      ls_line-info = text-007.
      APPEND ls_line TO lt_top_of_page.
      CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum(4) INTO rp_date SEPARATED BY '.'.
    STATUS LINE: TYPE S
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = text-008.
      ls_line-info = rp_date.
      APPEND ls_line TO lt_top_of_page.
    ENDFORM.                    "comment_build
    *&      Form  read_info
          text
         -->P_1001     text
         -->PERNR      text
         -->STAT       text
         -->REL        text
    form read_info tables p_1001 using  pernr stat rel.
      CALL FUNCTION 'RH_READ_INFTY_1001'
        EXPORTING
          AUTHORITY        = 'DISP'
          WITH_STRU_AUTH   = 'X'
          PLVAR            = '01'
          OTYPE            = 'P'
          OBJID            = pernr
          ISTAT            = stat
          SUBTY            = rel
          BEGDA            = pn-begda
          ENDDA            = pn-endda
        TABLES
          I1001            = p_1001
        EXCEPTIONS
          NOTHING_FOUND    = 1
          WRONG_CONDITION  = 2
          WRONG_PARAMETERS = 3
          OTHERS           = 4.
    endform.                    "read_info
    *&      Module  BACK  INPUT
          text
    MODULE BACK INPUT.
      IF SY-UCOMM = 'E'.
        leave program.
      endif.
      IF SY-UCOMM = 'ENDE'.
        leave program.
      endif.
      IF SY-UCOMM = 'ECAN'.
        leave program.
      endif.
    ENDMODULE.                 " BACK  INPUT

  • ALV grid oo delete rows and update to table

    Hi all
      How can I delete one row and update to the db table?
    thanks

    Hi,
    Refer:-
    The ALV Grid has events data_changed and data_changed_finished. The former method is
    triggered just after the change at an editable field is perceived. Here you can make checks for
    the input. And the second event is triggered after the change is committed.
    You can select the way how the control perceives data changes by using the method
    register_edit_event. You have two choices:
    1. After return key is pressed: To select this way, to the parameter i_event_id pass cl_gui_alv_grid=>mc_evt_enter.
    2. After the field is modified and the cursor is moved to another field: For this, pass cl_gui_alv_grid=>mc_evt_modifies to the same parameter.
    To make events controlling data changes be triggered, you must select either way by
    calling this method. Otherwise, these events will not be triggered.
    To control field data changes, ALV Grid uses an instance of the class
    CL_ALV_CHANGED_DATA_PROTOCOL and passes this via the event data_changed.
    Using methods of this class, you can get and modify cell values and produce error messages.
    Hope this helps you.
    Regards,
    Tarun

  • Update all alv (grid) displayed records to internal table

    Hi all,
    i want to update the records into the internal table which are changed by the user in the edit field.
    after he select save button.
    i  have to save the ALV grid displayed records in the internal table.
    hw can i do this ?

    ALV with EDIT and SAVE functionality
    Code:REPORT z_demo_alv_jg.*******************************************************************
    TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.&----
    *&      Form  SET_PF_STATUS
          Setting custom PF-Status
         -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS&----
    *&      Form  user_command
          Handling custom function codes
         -->R_UCOMM      Function code value
         -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
            and populate it in an internal table for future
            action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
          and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command

  • Automatically update totals in an ALV-grid

    Hi there,
    Is there a possibility to automatically update a totals-field in an ALV-grid?
    At the moment the totals-field is only updated when the ALV-grid is refreshed (PBO). I want an immediate update when the user enters a value in the ALV.
    Who can help me?
    Angelo

    Hi,
    Subramanian has taken his time and effort to help you. if you wish to reward his effort SDN has got a way for that. Since you are new to SDN may i introduce you to the points system at SDN.
    You assign points to the replies that you have found to be useful. It's a way to say "thanks" for the effort in the replies.
    See: /people/mark.finnern/blog/2004/08/10/spread-the-love for directions.
    Click on the Yellow Star icon in each reply.
    You can give:
    1 - 10 pointer (marks it as a solved problem)
    2 - 6 pointers (very helpful)
    Lots of 2 pointers (helpful)
    Raja

  • ALV grid EDIT updation

    hi Experts!!
    I am working on a ALV Grids which are on a Tabstrip Sub screen area.I have done the ALV  in Edit mode and :
    > <b>when we enter the values in the editing colums i want it to be updateted in the DB table.
    >But when we enter values it is not comming in the internal table also and not updateing in DB table.
    >Plz suggest waht needs to be done to catch the edited valuse and update the same into DB table</b>.

    hi,
    Check this might help you...
    Regard points if helpful....
    DATA: G_CONTROL TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    G_ALV TYPE REF TO CL_GUI_ALV_GRID.
    DATA: T_FCAT TYPE LVC_T_FCAT,
    WA_FCAT TYPE LVC_S_FCAT.
    DATA: I_ZAMIT TYPE TABLE OF ZAMIT_SHIP_TAB WITH HEADER LINE.
    DATA: I_INDEX TYPE I.
    DATA: G_OK_CODE TYPE SY-UCOMM.
    DATA: G_OK_CODE1 TYPE SY-UCOMM.
    SELECT * FROM ZAMIT_SHIP_TAB INTO TABLE I_ZAMIT.
    CALL SCREEN 9000.
    SCREEN FORMS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    *& Module STATUS_9000 OUTPUT
    text
    MODULE STATUS_9000 OUTPUT.
    SET PF-STATUS 'PF9001'.
    SET TITLEBAR 'xxx'.
    ENDMODULE. " STATUS_9000 OUTPUT
    *& Module CREATE_CONTROL OUTPUT
    text
    MODULE CREATE_CONTROL OUTPUT.
    CREATE OBJECT G_CONTROL
    EXPORTING
    PARENT =
    CONTAINER_NAME = 'G_CUSTOM_CONTROL'
    STYLE =
    LIFETIME = lifetime_default
    REPID =
    DYNNR =
    NO_AUTODEF_PROGID_DYNNR =
    EXCEPTIONS
    CNTL_ERROR = 1
    CNTL_SYSTEM_ERROR = 2
    CREATE_ERROR = 3
    LIFETIME_ERROR = 4
    LIFETIME_DYNPRO_DYNPRO_LINK = 5
    others = 6
    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. " CREATE_CONTROL OUTPUT
    *& Module CREATE_ALV OUTPUT
    text
    MODULE CREATE_ALV OUTPUT.
    CREATE OBJECT G_ALV
    EXPORTING
    I_SHELLSTYLE = 0
    I_LIFETIME =
    I_PARENT = G_CONTROL
    I_APPL_EVENTS = space
    I_PARENTDBG =
    I_APPLOGPARENT =
    I_GRAPHICSPARENT =
    I_NAME =
    I_FCAT_COMPLETE = SPACE
    EXCEPTIONS
    ERROR_CNTL_CREATE = 1
    ERROR_CNTL_INIT = 2
    ERROR_CNTL_LINK = 3
    ERROR_DP_CREATE = 4
    others = 5
    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. " CREATE_ALV OUTPUT
    *& Module DISPLAY_ALV OUTPUT
    text
    MODULE DISPLAY_ALV OUTPUT.
    PERFORM PREPARE_FIELD_CATALOG.
    CALL METHOD G_ALV->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME = 'SFLIGHT'
    IS_VARIANT =
    I_SAVE = 'X'
    I_DEFAULT = 'X'
    IS_LAYOUT =
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    IT_TOOLBAR_EXCLUDING = T_TOOLBAR[]
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    IR_SALV_ADAPTER =
    CHANGING
    IT_OUTTAB = I_ZAMIT[]
    IT_FIELDCATALOG = T_FCAT
    IT_SORT =
    IT_FILTER =
    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.
    ENDMODULE. " DISPLAY_ALV OUTPUT
    *& Form PREPARE_FIELD_CATALOG
    text
    --> p1 text
    <-- p2 text
    FORM PREPARE_FIELD_CATALOG .
    REFRESH T_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-COL_POS = 1.
    WA_FCAT-COLTEXT = 'SHIPMENT NO.'.
    WA_FCAT-FIELDNAME = 'ZSHIP_NO'.
    WA_FCAT-REF_TABLE = 'I_ZAMIT'.
    WA_FCAT-edit = 'X'.
    APPEND WA_FCAT TO T_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-COL_POS = 2.
    WA_FCAT-COLTEXT = 'DOC TYPE'.
    WA_FCAT-FIELDNAME = 'ZDOC_TYP'.
    WA_FCAT-REF_TABLE = 'I_ZAMIT'.
    WA_FCAT-KEY = 'X'.
    APPEND WA_FCAT TO T_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-COL_POS = 3.
    WA_FCAT-COLTEXT = 'NAME_CR'.
    WA_FCAT-FIELDNAME = 'ZNAME_CR'.
    WA_FCAT-REF_TABLE = 'I_ZAMIT'.
    WA_FCAT-KEY = 'X'.
    APPEND WA_FCAT TO T_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-COL_POS = 4.
    WA_FCAT-COLTEXT = 'SHIP_TYP'.
    WA_FCAT-FIELDNAME = 'ZSHIP_TYP'.
    WA_FCAT-REF_TABLE = 'I_ZAMIT'.
    WA_FCAT-KEY = 'X'.
    APPEND WA_FCAT TO T_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-COL_POS = 5.
    WA_FCAT-COLTEXT = 'LEG_IND'.
    WA_FCAT-FIELDNAME = 'ZLEG_IND'.
    WA_FCAT-REF_TABLE = 'I_ZAMIT'.
    WA_FCAT-KEY = 'X'.
    APPEND WA_FCAT TO T_FCAT.
    CLEAR WA_FCAT.
    ENDFORM. " PREPARE_FIELD_CATALOG
    *& Module LEAVE INPUT
    text
    MODULE LEAVE INPUT.
    LEAVE PROGRAM.
    ENDMODULE. " LEAVE INPUT
    *& Module USER_COMMAND_9000 INPUT
    text
    MODULE USER_COMMAND_9000 INPUT.
    IF G_OK_CODE = 'CHANGE'.
    DATA: VALUE TYPE C,
    COL TYPE I ,
    ROW TYPE LVC_S_ROW,
    COLNO TYPE LVC_S_COL,
    ROWNO TYPE LVC_S_ROID.
    CALL METHOD G_ALV->GET_CURRENT_CELL
    IMPORTING
    E_ROW = I_INDEX
    CALL METHOD G_ALV->GET_CURRENT_CELL
    IMPORTING
    E_ROW =
    E_VALUE = VALUE
    E_COL = COL
    ES_ROW_ID = ROW
    ES_COL_ID = COLNO
    ES_ROW_NO = ROWNO.
    READ TABLE I_ZAMIT INDEX I_INDEX.
    CALL SCREEN 9001 STARTING AT 10 10 .
    ENDIF.
    ENDMODULE. " USER_COMMAND_9000 INPUT
    *& Module STATUS_9001 OUTPUT
    text
    MODULE STATUS_9001 OUTPUT.
    SET PF-STATUS 'PF9002'.
    SET TITLEBAR 'xxx'.
    ENDMODULE. " STATUS_9001 OUTPUT
    *& Module USER_COMMAND_9001 INPUT
    text
    MODULE USER_COMMAND_9001 INPUT.
    IF G_OK_CODE1 = 'SAVE'.
    MODIFY ZAMIT_SHIP_TAB FROM I_ZAMIT.
    SELECT * FROM ZAMIT_SHIP_TAB INTO TABLE I_ZAMIT.
    CALL METHOD G_ALV->REFRESH_TABLE_DISPLAY.
    CALL SCREEN 9000.
    ENDIF.
    ENDMODULE. " USER_COMMAND_9001 INPUT

  • Updating database table using ALV Grid class CL_ALV_CHANGED_DATA_PROTOCOL

    Hi,
    I am trying to use class CL_ALV_CHANGED_DATA_PROTOCOL to update a database table from an ALV grid.
    I have used program BCALV_EDIT_04 as an example.
    I am able to successfully processed inserted or deleted lines using the attributes
    MT_DELETED_ROWS
    MT_INSERTED_ROWS
    but I also want to process modified lines.
    I was just wondering whether anyone out there has some example code for this.
    I can see that there are the following attributes available
    MT_MOD_CELLS
    MP_MOD_ROWS.
    I would ideally like to use MP_MOD_ROWS rather than  MT_MOD_CELLS but it is not clear to me what type MP_MOD_ROWS is.
    If anyone has any example code for this sort of thing, please let me know.
    Thanks,
    Ruby

    hi Ruby,
    Yes we can use that *data reference variable *.
    It is a variable( something comparable to a pointer ) that points to a int table( table with changed contents )
    which ll be created at run-time based on the data type ot the internal table that we pass to the parameter it_outtab of method set_table_for_first_display ...
    assign er_data_changed->mp_mod_rows->* to a field-symbol and use it...
    Check the below code for example -> method refresh_changed_data
    screen flow logic.
    PROCESS BEFORE OUTPUT.
      MODULE pbo.
    PROCESS AFTER INPUT.
      MODULE pai.
    main program.
    *       CLASS lcl_event_responder DEFINITION                           *
    CLASS lcl_event_responder DEFINITION.
      PUBLIC SECTION.
        DATA  : ls_changed_cell TYPE  lvc_s_modi,
                lv_language     TYPE  spras..
        METHODS refresh_changed_data  FOR EVENT data_changed
                                      OF cl_gui_alv_grid
                                      IMPORTING er_data_changed
                                                e_ucomm.
    ENDCLASS.                    "event_responder DEFINITION
    TYPES tt_makt TYPE STANDARD TABLE OF makt.
    DATA: go_handler         TYPE REF TO lcl_event_responder,
          go_grid            TYPE REF TO cl_gui_alv_grid,
          gt_fieldcat        TYPE lvc_t_fcat,
          gv_language        TYPE spras VALUE 'E',
          gt_outtab          TYPE tt_makt,
          gs_tableline       TYPE LINE OF tt_makt.
    FIELD-SYMBOLS : <changed_rows> TYPE tt_makt.
    CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'BASIC'.
      PERFORM create_and_init_alv CHANGING gt_outtab[]
                                           gt_fieldcat.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      LEAVE PROGRAM.
    ENDMODULE.                    "pai INPUT
    FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
                                      pt_fieldcat TYPE lvc_t_fcat.
      CHECK go_grid IS NOT BOUND.
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = cl_gui_container=>default_screen.
      PERFORM build_display_table.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
      go_grid->set_table_for_first_display( CHANGING  it_fieldcatalog      = pt_fieldcat
                                                      it_outtab            = pt_outtab ).
      go_grid->set_ready_for_input( 1 ).
    * raises the 'data_changed' event when we select another cell/any action after changing the data
      go_grid->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter ).
      CREATE OBJECT go_handler.
      SET HANDLER go_handler->refresh_changed_data FOR go_grid.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    FORM build_display_table.
      FREE gt_outtab.
      SELECT * FROM makt UP TO 20 ROWS INTO TABLE gt_outtab WHERE spras EQ gv_language.
    ENDFORM.                               "build_display_table
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'MAKT'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
        ls_fcat-edit       = abap_true.
        MODIFY pt_fieldcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                               "build_fieldcat
    *       CLASS event_responder IMPLEMENTATION                          *
    CLASS lcl_event_responder IMPLEMENTATION.
      METHOD refresh_changed_data.
        ASSIGN er_data_changed->mp_mod_rows->* TO <changed_rows>.
        LOOP AT <changed_rows> INTO gs_tableline.
          BREAK-POINT.
        ENDLOOP.
      ENDMETHOD.                    "click
    ENDCLASS.                    "event_responder IMPLEMENTATION
    Cheers,
    Jose.

  • ALV-Grid and update dynpro fields

    Hi!
    I've created a dynpro with an ALV-Grid for Data-Overview and fields on the dynpro to change additional data.
    My ALV has one editable column, when this value change I calculate other value for  a field dynrpo, but I canu2019t see this change in my field dynpro.
    How can I update my data filed dynpro when changing the selected row at the ALV.
    I use the method handle_data_changed to obtain changes in ALV-Grid and it works fine, but I canu2019t update my fileds on the dynpro, when changing value in ALV.
    Thanks for any hints!
    Lili.

    This error occurs becuase when you change anything on the ALV, control is not triggering the PAI and PBO of your dynpro. Hence your values are not getting updated in the dynpro field.
    You should call the CL_GUI_CFW=>DISPATCH in PAI module to trigger the PAI also after the event has been triggered in the ALV.
      CALL METHOD CL_GUI_CFW=>DISPATCH
        importing return_code = return_code.
    * a control event occured => exit PAI
      if return_code <> cl_gui_cfw=>rc_noevent.
        clear g_ok_code.
        exit.
      endif.
    Regards,
    Naimesh Patel

  • ALV grid with 2 changable columns - need to update a non changable column

    I have an ALV Grid that has 2 columns that are editable (this works fine).  These two add to the total column which is not editable.  I need the total column to get updated when these two are changed.  (I have a pushbutton for the user to hit after the changes are made so it can go through the code). 
    I have check in debug mode and my internal table is getting changed.  Even until the container is check to see if it is build, the value is correct, however, once it goes into CALL METHOD GR_GRID->REFRESH_TABLE_DISPLAY, the old total comes up.  The new data in the two changable fields are there and correct.   I have tried deleting the container but that had not affect on the issue.
    I have tried freeing my table and repopulating it, calling the screen again (after setting screen to zero).  It seems the container has some sort of memory or buffer that it is getting the data from. 
    Any ideas how to make it think it is a new 1st time display?
    Thank you in advance.

    Good day Michelle,
    I had the same senario, but i did not use REFRESH_TABLE_DISPLAY instead
    do one thing that is add a save button to the alv grid and then after you change the
    data copy the changed data to an internal table.
    a sample code.
    METHOD handle_toolbar.
        DATA:
          lw_toolbar TYPE stb_button.
        CLEAR lw_toolbar.
        lw_toolbar-function = 'SAVE'.
        lw_toolbar-icon = 'ICON_DETAIL'.
        lw_toolbar-butn_type = '0'.
        lw_toolbar-text = 'SAVE'.
          APPEND lw_toolbar TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
        CASE e_ucomm.
          WHEN 'DETAIL'.
              IF t_emp1 IS NOT INITIAL.
                UPDATE zemp FROM TABLE t_emp1.
                MESSAGE 'Records changed' TYPE 'S'.
              ELSE.
                MESSAGE 'No records are changed' TYPE 'S'.
              ENDIF.
              REFRESH t_emp1.
            ENDIF.
        ENDCASE.
      ENDMETHOD.                    "handle_user_command
    T_EMP1 IS WHERE YOU STORE THE UPDATED RECORDS.
    Regards and Best wishes.

  • How I can update data in ALV GRID?

    Hi all,
    I have to update data in an ALV GRID and only one column is editable. I've exclude insert and delete row pushbutton, and I inserted a save pushbutton.
    What I have to write under the "save function" to update my internal table displayed in ALV GRID?
    Thanks advance
    Christian
    Message was edited by: Christian Marchiol

    REPORT  ZTESTDFALV1                             .
    *Data Declaration
    DATA: BEGIN OF T_EKKO,
      EBELN TYPE EKPO-EBELN,
      EBELP TYPE EKPO-EBELP,
    END OF T_EKKO.
    DATA: BEGIN OF IT_EKKO OCCURS 0.
            INCLUDE STRUCTURE T_EKKO.
    DATA: END OF IT_EKKO.
    DATA: BEGIN OF IT_BACKUP OCCURS 0.
            INCLUDE STRUCTURE T_EKKO.
    DATA: END OF IT_BACKUP.
    *ALV data declarations
    TYPE-POOLS: SLIS.                                 "ALV Declarations
    DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          GD_LAYOUT    TYPE SLIS_LAYOUT_ALV,
          GD_REPID     LIKE SY-REPID.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM BUILD_LAYOUT.
      IT_BACKUP[] = IT_EKKO[].
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  build_fieldcatalog
    *       text
    FORM BUILD_FIELDCATALOG.
      REFRESH FIELDCATALOG.
      CLEAR FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'EBELN'.
      FIELDCATALOG-SELTEXT_M   = 'Purchase Order'.
      FIELDCATALOG-INPUT     = 'X'.
      FIELDCATALOG-EDIT     = 'X'.
      FIELDCATALOG-COL_POS     = 2.
      APPEND FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'EBELP'.
      FIELDCATALOG-SELTEXT_M   = 'PO Item'.
      FIELDCATALOG-COL_POS     = 3.
      APPEND FIELDCATALOG.
      CLEAR  FIELDCATALOG.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    FORM BUILD_LAYOUT.
      "Permet d'ajuster les colonnes au text
    *  gd_layout-colwidth_optimize = 'X'.
      GD_LAYOUT-TOTALS_TEXT       = 'Totals'(201).
    *  gd_layout-box_fieldname = 'SELECT'.
    *  gd_layout-box_tabname   = 'IT_EKKO'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    FORM DISPLAY_ALV_REPORT.
      GD_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM        = GD_REPID
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'
                I_CALLBACK_PF_STATUS_SET  = 'SET_PF_STATUS'
                I_CALLBACK_USER_COMMAND   = 'USER_COMMAND'
    *            i_grid_title             = 'My Title'
                IS_LAYOUT                 = GD_LAYOUT
                IT_FIELDCAT               = FIELDCATALOG[]
           TABLES
                T_OUTTAB                  = IT_EKKO
           EXCEPTIONS
                PROGRAM_ERROR             = 1
                OTHERS                    = 2.
      IF SY-SUBRC <> 0.
        WRITE:/ SY-SUBRC.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM DATA_RETRIEVAL.
      SELECT EBELN EBELP
       UP TO 10 ROWS
        FROM EKPO
        INTO CORRESPONDING FIELDS OF TABLE  IT_EKKO.
    ENDFORM.                    " DATA_RETRIEVAL
    *                      FORM SET_PF_STATUS                              *
    FORM SET_PF_STATUS USING RT_EXTAB   TYPE  SLIS_T_EXTAB.
      <b>SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.</b>
    ENDFORM.                    "set_pf_status
    *&      Form  user_command
    *       text
    *      -->R_UCOMM    text
    *      -->RS_SELFIELDtext
    FORM USER_COMMAND  USING R_UCOMM LIKE SY-UCOMM
                             RS_SELFIELD TYPE SLIS_SELFIELD.
    <b> DATA: GD_REPID LIKE SY-REPID, "Exists
      REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
    </b>
    *then insert the following code in your USER_COMMAND routine...
      <b>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.</b>
      CASE R_UCOMM.
        WHEN '&IC1'.
          CHECK RS_SELFIELD-TABINDEX > 0.
          IF RS_SELFIELD-VALUE EQ '6000000001'.
            CALL TRANSACTION 'ZDF2'.
          ENDIF.
        WHEN 'REFRESH'.
          READ TABLE IT_EKKO INDEX  RS_SELFIELD-TABINDEX.
          IF SY-SUBRC = 0.
            READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
            IF SY-SUBRC = 0.
              IF IT_EKKO <> IT_BACKUP.
    *  then do your check
              ENDIF.
            ENDIF.
          ENDIF.
          PERFORM DATA_RETRIEVAL.
          RS_SELFIELD-REFRESH = 'X'.
      when 'SAVE'.
    ***do your save**
      ENDCASE.
    ENDFORM.                    "user_command
    concentrate on Bold....
    regards
    vijay

  • To update an alv grid..

    Hello everyone,
    I have a requirement.
      update button in selection-screen.
    I have an alv grid display and I have to maintain last 2 fields in editable mode in the output and the user will enter the values after executing the report in the output screen and will save it.
    and when he will select  display radiobutton in the selection-screen ,,
    the entries which he entered above has to display ,,( all the entries should display in the output ).
    is it possible ? if yes, then let me know the procedure.
    will be rewarded..

    Hi,
           yes it is possible 
    all u need to do is call a new alv with same funtion modules and pass the updated internal table to these function modules
    i have the same req for 'SAVE' button in menu , u just change it by your radio button in the sample code below
    type-pools : slis.
    types : begin of t_mat,
            matnr type matnr,
            werks type werks_d,
            lgort type lgort_d,
            labst type labst,
            meins type meins,
            maktx type maktx,
            name1 type name1,
            lgobe type lgobe,
            msehl type msehl,
            v_lights type c,
            v_row type c length 4,     "FOR ROW COLOR
            v_col type slis_t_specialcol_alv,
            end of t_mat,
            begin of t_makt,
            matnr type matnr,
            maktx type maktx,
            end of t_makt,
            begin of t_marc,
            matnr type matnr,
            werks type werks_d,
            end of t_marc,
            begin of t_mard,
            matnr type matnr,
            werks type werks_d,
            lgort type lgort_d,
            labst type labst,
            end of t_mard,
            begin of t_t001l,
            werks type werks_d,
            lgort type lgort_d,
            lgobe type lgobe,
            end of t_t001l,
            begin of t_t001w,
            werks type werks_d,
            name1 type name1,
            end of t_t001w.
    types : begin of wa_mat,
            werks type werks,
            end of wa_mat.
    data : flag type i value 0.
    ******VARIABLE DECLARATION********
    data:v_prog_name type sy-repid,      "VARIABLE FOR PROG NAME
         v_grid_title type lvc_title. "VARIABLE FOR GRID TITLE
    *****INTERNAL TABLE DECLARATION***
    data:  it_mat type standard table of t_mat,
           it_marc type standard table of t_marc,
           it_mard type standard table of t_mard,
           it_t001l type standard table of t_t001l,
           it_t001w type standard table of t_t001w,
           it_makt type standard table of t_makt,
           it_fieldcat  type slis_t_fieldcat_alv,
           it_sortinfo   type slis_t_sortinfo_alv,
           it_eventcat   type slis_t_event,
           it_listheader type slis_t_listheader,
           t_color type slis_specialcol_alv.
    data : it_werks type standard table of wa_mat.
    *****WORK AREA DECLARATION*********
    data:  wa_mat type t_mat,
           wa_mard type t_mard,
           wa_t001l type t_t001l,
           wa_t001w type t_t001w,
           wa_makt type t_makt,
           wa_layout type slis_layout_alv.
    data : wa_werks type wa_mat.
    data : wa_variant1          like disvariant,
           wa_variant2          like disvariant.
               Selection-Screen                        *
    selection-screen begin of block plant with frame title text-001.
    select-options:  s_plant for wa_mat-werks,
                     s_stor for wa_mat-lgort.
    parameters     : p_var like disvariant-variant.
    selection-screen end of block plant.
    selection-screen begin of block output with frame title text-002.
    parameter:  p_rb_01 radiobutton group rd1 default 'X',  " list
                p_rb_02 radiobutton group rd1.              " grid
    selection-screen end of block output.
                   Initialization                      *
    perform zf_initialization.
                 At Selection Screen                   *
    at selection-screen on value-request for p_var.
      wa_variant1-report = sy-repid.
      call function 'REUSE_ALV_VARIANT_F4'
        exporting
          is_variant                = wa_variant1
      I_TABNAME_HEADER          =
      I_TABNAME_ITEM            =
      IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
       i_display_via_grid        = 'X'
    importing
        e_exit                    = v_exit
         es_variant                = wa_variant2
       exceptions
         not_found                 = 1
         program_error             = 2
         others                    = 3
      if sy-subrc = 0.
        p_var = wa_variant2-variant.
      else.
        clear wa_variant2.
      endif.
    at selection-screen.
      perform zf_validate_sel_screen.
                Start of Selection                     *
    start-of-selection.
      perform zf_get_data.
              End of Selection                         *
    end-of-selection.
      perform zf_display_data.
    *&      Form  zf_initialization
      This will intialize all the variables, work area & subroutines
    -->  p1        text
    <--  p2        text
    form zf_initialization .
      clear :   wa_mat,
                wa_mard,
                wa_t001l,
                wa_t001w,
                wa_makt,
                wa_layout.
      refresh : it_mat,
                it_marc,
                it_mard,
                it_t001l,
                it_t001w,
                it_makt,
                it_fieldcat,
                it_sortinfo,
                it_eventcat,
                it_listheader.
      v_prog_name = sy-repid.
      wa_variant2-report = sy-repid.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        exporting
          i_save        = 'A'
        changing
          cs_variant    = wa_variant2
        exceptions
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          others        = 4.
      if sy-subrc = 0.
        p_var = wa_variant2-variant.
      else.
        p_var = '/DEFAULT'.
      endif.
    endform.                    " zf_initialization
    *&      Form  zf_validate_sel_screen
      This is to validate the inputs on the selction screen
    -->  p1        text
    <--  p2        text
    form zf_validate_sel_screen .
      if not p_var is initial.
        wa_variant1-report = sy-repid.
        wa_variant1-variant = p_var.
        call function 'REUSE_ALV_VARIANT_EXISTENCE'
          exporting
            i_save        = 'A'
          changing
            cs_variant    = wa_variant1
          exceptions
            wrong_input   = 1
            not_found     = 2
            program_error = 3
            others        = 4.
        if sy-subrc = 0.
          clear wa_variant2.
          move p_var to wa_variant2-variant.
          move sy-repid to wa_variant2-report.
        else.
          message e006. "No such variant exists
        endif.
      else.
        clear wa_variant1.
      endif.
      select werks from marc into wa_mat-werks where werks in s_plant.
        exit.
      endselect.
      if sy-subrc <> 0.
        message e002.
        clear wa_mat.
      endif.
      select lgort from mard into wa_mat-lgort where lgort in s_stor.
        exit.
      endselect.
      if sy-subrc <> 0.
        message e003.
        clear wa_mat.
      endif.
    endform.                    " zf_validate_sel_screen
    *&      Form  zf_get_data
      This will fetch data from the database tables & finally merge them
         into a single internal table, to pass it to alv
    -->  p1        text
    <--  p2        text
    form zf_get_data .
      select matnr werks into table it_marc from marc where werks in s_plant
      if sy-subrc = 0.
        sort it_marc by matnr werks.
      endif.
      if it_marc[] is not initial.
        select matnr maktx into table it_makt from makt
                          for all entries in it_marc
                          where matnr = it_marc-matnr
                            and spras = sy-langu.
        if sy-subrc = 0.
          sort it_makt by matnr.
        endif.
        select matnr werks lgort labst into table it_mard from mard
                                       for all entries in it_marc
                                       where matnr = it_marc-matnr
                                             and werks = it_marc-werks
                                             and lgort in s_stor.
        if sy-subrc = 0.
          sort it_mard by matnr werks lgort.
        endif.
        select werks name1 into table it_t001w from t001w
                           for all entries in it_marc
                           where werks = it_marc-werks.
        if sy-subrc = 0.
          sort it_t001w by werks.
        endif.
      endif.
      if it_mard[] is not initial.
        select werks lgort lgobe into table it_t001l from t001l
                                 for all entries in it_mard
                                 where werks = it_mard-werks
                                   and lgort = it_mard-lgort.
        if sy-subrc = 0.
          sort it_t001l by werks lgort.
        endif.
      endif.
      clear : wa_mat,
              wa_mard,
              wa_t001l,
              wa_t001w,
              wa_makt.
      loop at it_mard into wa_mard.
        wa_mat-matnr = wa_mard-matnr.
        wa_mat-werks = wa_mard-werks.
        wa_mat-lgort = wa_mard-lgort.
        wa_mat-labst = wa_mard-labst.
        read table it_makt into wa_makt with key matnr = wa_mard-matnr
    binary search.
        if sy-subrc = 0.
          wa_mat-maktx = wa_makt-maktx.
        endif.
        read table it_t001l into wa_t001l with key werks = wa_mard-werks
    lgort = wa_mard-lgort binary search.
        if sy-subrc = 0.
          wa_mat-lgobe = wa_t001l-lgobe.
        endif.
        read table it_t001w into wa_t001w with key werks = wa_mard-werks
    binary search.
        if sy-subrc = 0.
          wa_mat-name1 = wa_t001w-name1.
        endif.
        append wa_mat to it_mat.
      endloop.
      sort it_mat by matnr werks lgort.
      loop at it_mat into wa_mat.
        clear t_color.
        if wa_mat-labst < 100.
          wa_mat-v_lights = '1'.
          t_color-fieldname = 'LABST'.
          t_color-color-col = 6.
          append t_color to wa_mat-v_col.
          wa_mat-v_row = 'C610'.
          modify it_mat from wa_mat.
        elseif wa_mat-labst < 1000.
          wa_mat-v_lights = '2'.
          t_color-fieldname = 'LABST'.
          t_color-color-col = 3.
          append t_color to wa_mat-v_col.
          wa_mat-v_row = 'C510'.
          modify it_mat from wa_mat.
        else.
          wa_mat-v_lights = '3'.
          t_color-fieldname = 'LABST'.
          t_color-color-col = 5.
          append t_color to wa_mat-v_col.
          wa_mat-v_row = 'C210'.
          modify it_mat from wa_mat.
        endif.
        clear wa_mat.
      endloop.
    endform.                    " zf_get_data
    *&      Form  zf_display_data
    -->  p1        text
    <--  p2        text
    form zf_display_data .
    *If Internal Table Is Populated Then Only Display Alv Report.
      if not it_mat[] is initial.
    &---Prepare fieldcatalog .
        perform zf_build_fieldcat using it_fieldcat.
    &---Build event catalog.
        perform zf_eventcat using it_eventcat.
    &---Build Listheader for TOP OF PAGE EVENT.
        perform zf_build_listheader using it_listheader.
    &---Build layout.
        perform zf_layout.
    &---Build sorting.
        perform zf_sorting using it_sortinfo.
    &---Initializating Grid Title
        perform zf_build_grid_title.
    IF GRID RADIO button (ALV GRID) IS selected .
        if p_rb_02 is not initial.
    DISPLAY ALV GRID.
          perform zf_display_alv_grid.
        else.
    DISPLAY ALV LIST.
          perform zf_display_alv_list.
        endif.
      else.
    *&---If Table is not Populated ie Records Does not exist
        message s001.
      endif.
    endform.                    " zf_display_data
    *&      Form  ZF_BUILD_FIELDCAT
          text
         -->P_IT_FIELDCAT  text
    form zf_build_fieldcat  using    p_it_fieldcat type slis_t_fieldcat_alv.
    *Declaring Local Variable
      data: l_fieldcat type slis_fieldcat_alv.
      clear l_fieldcat.
    for First field
      l_fieldcat-col_pos     = '1'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'WERKS'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARC'.       "FOR F1 & F4 HELP AS REFERNCED
      l_fieldcat-key         = 'X'.          "MAKING FIELD AS KEY FIELD
      l_fieldcat-outputlen   =  4.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-003.  "Long text for header.
      l_fieldcat-seltext_m   = text-003.    "Medium text for header.
      l_fieldcat-seltext_s   = text-003.           "Short text for header.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    for Second field
      l_fieldcat-col_pos     = '2'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'LGORT'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARD'.       "FOR F1 & F4 HELP AS REFERNCED
      l_fieldcat-key         = 'X'.          "MAKING FIELD AS KEY FIELD
      l_fieldcat-outputlen   =  4.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-004.  "Long text for header.
      l_fieldcat-seltext_m   = text-005.    "Medium text for header.
      l_fieldcat-seltext_s   = text-006.           "Short text for header.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    for third field
      l_fieldcat-col_pos     = '3'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'MATNR'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARA'.       "FOR F1 & F4 HELP AS REFERNCED
    l_fieldcat-key         = 'X'.          "MAKING FIELD AS KEY FIELD
      l_fieldcat-outputlen   =  18.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-007.  "Long text for header.
      l_fieldcat-seltext_m   = text-008.    "Medium text for header.
      l_fieldcat-seltext_s   = text-009.           "Short text for header.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    for fourth field
      l_fieldcat-col_pos     = '4'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'LABST'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARD'.       "FOR F1 & F4 HELP AS REFERNCED
      l_fieldcat-outputlen   =  16.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-010.  "Long text for header.
      l_fieldcat-seltext_m   = text-011.    "Medium text for header.
      l_fieldcat-seltext_s   = text-012.           "Short text for header.
      l_fieldcat-do_sum = 'X'.
      l_fieldcat-input       = 'X'.          "Making the field editable
      l_fieldcat-edit        = 'X'.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    endform.                    " ZF_BUILD_FIELDCAT
    *&      Form  zf_eventcat
          text
         -->P_IT_EVENTCAT  text
    form zf_eventcat  using    p_it_eventcat type slis_t_event.
      data l_eventcat type slis_alv_event.
      clear l_eventcat.
    *Get all the events.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type     = 0
        importing
          et_events       = p_it_eventcat
        exceptions
          list_type_wrong = 1
          others          = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    TOP-OF-PAGE FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_top_of_page.
      if sy-subrc = 0.
        move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                             transporting form.
      endif.
    PF_STATUS_SET FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_pf_status_set.
      if sy-subrc = 0.
        move 'ZF_PF_STATUS_SET' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    USER_COMMAND FORM
      clear l_eventcat.
      read table p_it_eventcat into  l_eventcat with key
                               name = slis_ev_user_command.
      if sy-subrc = 0.
        move 'ZF_USER_COMMAND' to  l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    endform.                    " zf_eventcat
    *&      Form  ZF_BUILD_LISTHEADER
          text
         -->P_IT_LISTHEADER  text
    form zf_build_listheader  using  p_it_listheader type slis_t_listheader.
      data: l_listheader type slis_listheader.
      refresh p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'H'.   "Header
    l_listheader-key = 'FCIL,INDIA'. "Ignored for "Header" Type
      l_listheader-info = text-013.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      data : lv_date(10) type c .
      write sy-datum to lv_date .
      l_listheader-typ = 'S'.
      l_listheader-key = 'DATE'.
      l_listheader-info = lv_date.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'A'.
    l_listheader-key = 'COMMENT'.    " key is ignored
      l_listheader-info = text-014.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'S'.
      l_listheader-key = text-016.
    l_listheader-info = 'Input Plant'.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'S'.
      l_listheader-key = text-017.
    l_listheader-info = 'Plant'.
      append l_listheader to p_it_listheader.
      select werks from marc into  table it_werks where werks in s_plant.
      sort it_werks by werks.
      delete adjacent duplicates from it_werks comparing werks.
      loop at it_werks into wa_werks.
        clear l_listheader.
        l_listheader-typ = 'S'.
       l_listheader-key = 'X'.
        l_listheader-info = wa_werks-werks.
        append l_listheader to p_it_listheader.
      endloop.
    endform.                    " ZF_BUILD_LISTHEADER
    *&      Form  ZF_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    form zf_layout .
      clear wa_layout.
      wa_layout-zebra = 'X'.
      wa_layout-lights_fieldname = 'V_LIGHTS'.
      wa_layout-lights_tabname   = 'IT_MAT'.
      wa_layout-info_fieldname = 'V_ROW'. " infofield for listoutput
      wa_layout-coltab_fieldname = 'V_COL'. " colors
    endform.                    " ZF_LAYOUT
    *&      Form  ZF_SORTING
          text
         -->P_IT_SORTINFO  text
    form zf_sorting  using    p_it_sortinfo type slis_t_sortinfo_alv.
      data l_sortinfo type slis_sortinfo_alv.
      clear l_sortinfo.
      l_sortinfo-spos = '1'.
      l_sortinfo-fieldname = 'WERKS'.
      l_sortinfo-tabname = 'IT_MAT'.
      l_sortinfo-up = 'X'.
      l_sortinfo-group = 'UL'.              "UNDERLINE AFTER EVERY GROUP
      l_sortinfo-subtot = 'X'.
      append l_sortinfo to p_it_sortinfo.
    endform.                    " ZF_SORTING
    *&      Form  ZF_BUILD_GRID_TITLE
          text
    -->  p1        text
    <--  p2        text
    form zf_build_grid_title .
      v_grid_title = text-015.
    endform.                    " ZF_BUILD_GRID_TITLE
    *&      Form  ZF_DISPLAY_ALV_GRID
          text
    -->  p1        text
    <--  p2        text
    form zf_display_alv_grid .
      call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = v_prog_name
       i_callback_pf_status_set          = 'ZF_PF_STATUS_SET'
       i_callback_user_command           = 'ZF_USER_COMMAND'
       i_callback_top_of_page            = 'ZF_TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
         i_grid_title                      = v_grid_title
      I_GRID_SETTINGS                   =
         is_layout                         = wa_layout
         it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sortinfo
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant2
       it_events                         = it_eventcat
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        tables
          t_outtab                          = it_mat
    exceptions
       program_error                     = 1
       others                            = 2
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " ZF_DISPLAY_ALV_GRID
    *&      Form  zf_display_alv_list
          text
    -->  p1        text
    <--  p2        text
    form zf_display_alv_list .
      call function 'REUSE_ALV_LIST_DISPLAY'
       exporting
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         i_callback_program             = v_prog_name
       i_callback_pf_status_set       = 'ZF_PF_STATUS_SET'
       i_callback_user_command        = 'ZF_USER_COMMAND'
      I_STRUCTURE_NAME               =
         is_layout                      = wa_layout
         it_fieldcat                    = it_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       it_sort                        = it_sortinfo
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = 'A'
      IS_VARIANT                     = WA_VARIANT2
       it_events                      = it_eventcat
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        tables
          t_outtab                       = it_mat
       exceptions
         program_error                  = 1
         others                         = 2
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " zf_display_alv_list
    *&      Form  zf_top_of_page
          text
    -->  p1        text
    <--  p2        text
    form zf_top_of_page .
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary       = it_listheader
         i_logo                   = 'ENJOYSAP_LOGO'
      I_END_OF_LIST_GRID       =
    endform.                    " zf_top_of_page
    *&      Form  zf_pf_status_set
          text
    -->  p1        text
    <--  p2        text
    form zf_pf_status_set using rt_extab type slis_t_extab.
      set pf-status  'ALV_MENU_MAT' excluding  'BACK'.
      case sy-ucomm.
        when 'SAVE'.
    IF flag <> 0.
          set pf-status  'ALV_MENU_MAT' .
    ENDIF.
      endcase.
    endform.                    " zf_pf_status_set
    *&      Form  zf_user_command
          text
    -->  p1        text
    <--  p2        text
    form zf_user_command using r_ucomm like sy-ucomm
                            rs_selfield type slis_selfield.
    sy-ucomm = r_ucomm.
      case r_ucomm.
        when 'SAVE'.
          flag = flag + 1.
          read table it_mat index rs_selfield-tabindex into wa_mat.
          wa_mat-labst = rs_selfield-value.
          if rs_selfield-value < 100.
            wa_mat-v_lights = '1'.
            t_color-fieldname = 'LABST'.
            t_color-color-col = 6.
            wa_mat-v_row = 'C610'.
            clear wa_mat-v_col.
            append t_color to wa_mat-v_col.
          elseif rs_selfield-value < 1000.
            wa_mat-v_lights = '2'.
            t_color-fieldname = 'LABST'.
            t_color-color-col = 3.
            wa_mat-v_row = 'C510'.
            clear wa_mat-v_col.
            append t_color to wa_mat-v_col.
          else.
            wa_mat-v_lights = '3'.
            t_color-fieldname = 'LABST'.
            t_color-color-col = 5.
            wa_mat-v_row = 'C210'.
            clear wa_mat-v_col.
            append t_color to wa_mat-v_col.
          endif.
          modify it_mat from wa_mat index rs_selfield-tabindex.
    IF GRID RADIO button (ALV GRID) IS selected .
          if p_rb_02 is not initial.
           SET PF-STATUS  'ALV_MENU_MAT'.
    DISPLAY ALV GRID.
            perform zf_display_alv_grid.
          else.
           SET PF-STATUS  'ALV_MENU_MAT'.
    DISPLAY ALV LIST.
            perform zf_display_alv_list.
          endif.
          set screen 0.
        when 'BACK'.
          leave screen.
        when others.
          message i004.
      endcase.
       WHEN 'BACK'.
    CASE sy-ucomm.
       WHEN 'BACK'.
         LEAVE SCREEN.
    ENDCASE.
    endform.                    " zf_user_command
    reward points if helpful

  • Field catalog update in ALV grid

    Hi All,
    When you're changing an existing field catalog in an ALV grid, there's a possibility this change will not appear immediately in the list display.
    Can anyone explain this,
    Kind regards,
    Rob Makelaar.
    The Netherlands

    Hi Rob
    ALV as an encapsulated object uses some kind of buffer for the field catalog. You can switch buffer capabilities with the parameter <b>"I_BUFFER_ACTIVE"</b> of the method <b>"set_table_for_first_display"</b>.
    The use of this parameter is explained as follows:
    <i>Flag to be set by the application if the method call is static. This means the method is always called with the same field catalog. In this case, the field catalog can be held in a special buffer. This accelerates the display of small lists, in particular.</i>
    And as an additional point, you should have marked this thread as a question thread since you require some answer. If you want so, you can do this by editing your original post and check relevant checkbox under the editbox. This way you can reward points to helpful posts using the scala at the left of each particular post and you can mark a question as solved to save SDNers's times.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Maybe you are looking for