ALV: Selection mode in  editable ALV

Hi guys,
I have another ALV problem:
I have an ALV which is editable. I found out, that in this case the settings which I made in the field SEL_MODE of the layout are overwritten. [An easy ALV Reference, p. 26|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907] . In there a way to avoid that the settings are overwritten or to change them? I already tried it using the get/set layout methods, but it didn't work. The user should only be able to select one row.
Regards,
Martin

go to se51 double click on your table control open a properties
window inside of table control in that click on line sel single radio button
& also column sel single radio button
there are 3 types of selection
none
single
multiple
just click on single radio button
save check activate
regards
Aniruddh Singh

Similar Messages

  • How to validate cells of selected rows in editable ALV

    Hi,
    I have created an ALV grid which is editable. Now I have entered the values in the grid, and selected some rows for which I need to validate the cells. But this is not happening. It is validating all the cells edited in the grid.
    Can anyone help me...
    Regards,
    Satish Kanteti.

    Hi Satish,
    Follow below steps,
    1. Declare a additional field for selection flag in your internal table like below,
    DATA: BEGIN OF g_t_vekp OCCURS 0,
          flag(1) TYPE c,             "  <------   Flag for selection
          venum TYPE vekp-venum,
          exidv TYPE vekp-exidv,
          vbeln_gen TYPE vekp-vbeln_gen,
          END OF g_t_vekp.
    2.  Add extra  parameter  'i_callback_user_command'  in FM 'REUSE_ALV_GRID_DISPLAY'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = g_r_repid
          i_callback_user_command = 'USER_COMMAND'         "   <------  Additional parameter
          is_layout               = g_wa_layout
          it_fieldcat             = g_t_fieldcat[]
        TABLES
          t_outtab                = g_t_vekp
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
    3. Define a form 'USER_COMMAND'  like below  to  check or save only selected  rows.
    FORM user_command USING l_r_ucomm LIKE sy-ucomm l_r_selfield TYPE slis_selfield.
      CASE l_r_ucomm.
    *Updating database when 'Save' is pressed
        WHEN '&DATA_SAVE'.
          LOOP AT g_t_vekp INTO g_wa_vekp WHERE flag = 'X'.    "   <----   Loop through only  selected rows
          "  Ur  operation on  selected  records
          ENDLOOP.
      ENDCASE.
      l_r_selfield-refresh = 'X'.
    ENDFORM.                    "user_command
    Might solve ur problem.
    Thanks,
    Edited by: Sap Fan on Oct 13, 2009 5:10 PM

  • Goes to 'nothing selected' mode when editing tables entries? (Sometimes)

    When trying to edit entries in table cells pages sometimes flips into 'nothing selected' mode and return to the top of the table leaving the cell entry partially changed. This can happen anytime during the typing of characters to replace other text. Reselecting the cell and editng the text as before will then work!
    There was one occasion when Pages terminated with an error when I was changing the cell contents but when restarted it let me make the changes to the table cell without terminating.

    Pages Version is 5.2.
    The keyboard (cable connect version, not bluetooth) is clean and works OK with all my other apps.
    I use an Apple Magic Trackpad to move cursor and select cell/text etc.

  • Get Selections From ALV on Multiple Selection Mode

    Hi,
    How can i get values of selected rows from ALV that has selection '0..n' (multiple selection) ?
    Can somebody help me pls?
    Thanks.

    Hi Nurullah,
    Steps to make multiple rows selectable in ALV:
    1) Create the selection property of the node that you are binding to the DATA node as o..n
    2) Un-check the, "Initialization Lead Selection" checkbox for the node which you are using to bind to the DATA node
    3) In the WDDOINIT method specify the ALV's selection mode as MULTI_NO_LEAD. It is important that you set the selection mode to MULTI_NO_LEAD or else in the end you would be capturing 1 row lesser than the total number of rows the user has selected. This is because 1 of the rows would have the LeadSelection property & our logic wouldnt be reading the data for that row. Check the example code fragment as shown below:
    DATA lo_value TYPE REF TO cl_salv_wd_config_table.
      lo_value = lo_interfacecontroller->get_model( ).
      CALL METHOD lo_value->if_salv_wd_table_settings~set_selection_mode
        EXPORTING
          value = cl_wd_table=>e_selection_mode-MULTI_NO_LEAD.
    Steps to get the multiple rows selected by the user
    In order to get the multiple rows which were selected by the user you will just have to call the get_selected_elements method of if_wd_context_node. So as you can see its no different from how you would get the multiple rows selected by the user in a table ui element. First get the reference of the node which you have used to bind to the ALV & then call this method on it. Check the example code fragment below:
    METHOD get_selected_rows .
      DATA: temp TYPE string.
      DATA: lr_node TYPE REF TO if_wd_context_node,
                wa_temp  TYPE REF TO if_wd_context_element,
                ls_node1 TYPE wd_this->element_node_flighttab,
                lt_node1 TYPE wd_this->elements_node_flighttab.
      lr_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' ).
    " This would now contain the references of all the selected rows
      lt_temp = lr_node->get_selected_elements( ).
        LOOP AT lt_temp INTO wa_temp.
    " Use the references to get the exact row data
          CALL METHOD wa_temp->get_static_attributes
            IMPORTING
              static_attributes = ls_node1.
          APPEND ls_node1 TO lt_node1.
          CLEAR ls_node1.
        ENDLOOP.
    ENDMETHOD.
    Hope this helps resolve your problem.
    Regards,
    Uday

  • Reg editing alv in output mode

    Hi,
    Cud any one let me know how to edit alv ?
    im using fcat-edit = 'x' option in function module approach....but even then im not able to edit columns/fields....?
    how to edit columns/rows using function modules and OOPs methos in alv????
    Thanks
    Jay

    Hi
    i am sending you a code where the output field is edtable in the ALV oop
    you can understand very easily
    reward if usefull
    *& Report  ZAMIT_ALV_OOP_EDITABLE
    REPORT  ZAMIT_ALV_OOP_EDITABLE.
    *data declaration
    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.
    <b>  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'.</b>
      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

  • Edit a selected row in an alv report after pressing a push button ?

    hi all ,
    I want to edit a selected row in an alv report but that too after i press a push button . After pressing the push button , a pop up shud *** showing all the entries of the selected row which shud be editable and after editing it shud be saved into the database table.
    How can i do this please help asap ???

    May this prog. of mine can solve your requirement.
    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
    Regards,
    Joy.

  • ALV selection field of displayed table is not populated properly

    Hi,
    I am using OO ALV in my screen. I have two tabs. In one tab I display one ALV output in edit mode with selection option and passing internal table field for box_selection. In the other tab I am displaying another ALV output but in display mode.
    My problem is when I switch from tab in edit mode to tab in display mode and back to tab in edit mode, then select a line on the tab in the edit mode, the method I am calling:
      CALL METHOD grid1->get_selected_rows
        IMPORTING
          et_index_rows = i_sel_alvrows[].
    would return table "i_sel_alvrows" empty.
    If i do not switch between the tabs, the ->get_selected_rows logic works perfectly.
    You reply will be greatly appreciated.
    Thanks.

    Oleg,
    I have doubt ,
    This is example:--> if you have selected a line in edit tab and going to display tab and coming back to edit tab, at the point your selected line is there in edit tab as in selected mode ?
    After freeing the container?
    aRs
    Message was edited by:
            aRs

  • How to Edit ALV

    Hi all,
    I have created an ALV Grid display using container.
    My question is : How to edit an AlV.
    Initially some of column are in Display Mode, That i had set as non editable.
    But i want that when i create new/insert new record using the Insert button of alv , the only new column should apper as editable (all columns) as it is new record. So i can insert it into batabase.
    Any one an help me with this .
    Thanks
    Amar

    Hi Amar,
    I have added one Sample program pls check it and Let me know
    INCLUDE .
    TABLES: lfa1, lfb1, ekko, ekpo.
    TYPE-POOLS: slis.
    DATA: ok_code LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'CONTAINER',
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    DATA: repname LIKE sy-repid.
    DATA: t_disvariant TYPE TABLE OF disvariant WITH HEADER LINE.
    DATA: t_fieldtab TYPE lvc_t_fcat.
    DATA: t_layout TYPE lvc_s_layo.
    DATA: gs_toolbar  TYPE stb_button.
    DATA: t_rows TYPE lvc_t_row WITH HEADER LINE.
          TABLA DE DATOS
    DATA: BEGIN OF ti_acred OCCURS 0,
               bukrs LIKE lfb1-bukrs,
               lifnr LIKE lfa1-lifnr,
               land1 LIKE lfa1-land1,
               name1 LIKE lfa1-name1,
               ort01 LIKE lfa1-ort01,
               pstlz LIKE lfa1-pstlz,
               regio LIKE lfa1-regio,
               sortl LIKE lfa1-sortl,
               stras LIKE lfa1-stras,
               adrnr LIKE lfa1-adrnr,
       END OF ti_acred.
    DATA i_salida LIKE ti_acred OCCURS 0.
    DATA: d_bukrs LIKE t001-bukrs.
    DATA  container.
    DATA save VALUE 'X'.
                  Pantalla de Selección                 -
    SELECTION-SCREEN BEGIN OF BLOCK bloq1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : lifnr FOR lfa1-lifnr,
                     bukrs FOR lfb1-bukrs.
    SELECTION-SCREEN END OF BLOCK bloq1.
    SELECTION-SCREEN BEGIN OF BLOCK bloq3 WITH FRAME TITLE text-003.
    PARAMETERS: p_alvasg TYPE slis_vari.  " Disposición ALV
    SELECTION-SCREEN END   OF BLOCK bloq3.
    LOCAL CLASSES: Definition
    *===============================================================
    class lcl_event_receiver: local class to
                            define and handle own functions.
    Definition:
    ~~~~~~~~~~~
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
        handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive,
        handle_menu_button
            FOR EVENT menu_button OF cl_gui_alv_grid
                IMPORTING e_object e_ucomm,
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.
    lcl_event_receiver (Definition)
    *===============================================================
    LOCAL CLASSES: Implementation
    *===============================================================
    class lcl_event_receiver (Implementation)
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
    § 2.At event TOOLBAR define a toolbar element of type 1 by using
        event paramenter E_OBJECT. Remember its function code.
    Part I: Define a menu button including a function code that
            is evaluated in 'handle_MENU_BUTTON
    append a menu with default button (Type 1)
    The function code of the default button is the same as
    the one for the menu.
    If the user klicks on the default button ALV raises
    directly event BEFORE_USER_COMMAND
    (then USER_COMMAND, AFTER_USER_COMMAND).
    If the user klicks on the menu button ALV raises event MENU_BUTTON.
        CLEAR gs_toolbar.
        MOVE 'MODIFY' TO gs_toolbar-function.
    --&gt; This function code is evaluated in 'handle_menu_button'
        MOVE icon_change TO gs_toolbar-icon.
        MOVE 'Modificar' TO gs_toolbar-quickinfo.
        MOVE 0 TO gs_toolbar-butn_type.
        MOVE space TO gs_toolbar-disabled.
        APPEND gs_toolbar TO e_object-&gt;mt_toolbar.
      ENDMETHOD.
      METHOD handle_menu_button.
    § 3.At event MENU_BUTTON query your function code and define a
        menu in the same way as a context menu.
    Part II: Evaluate 'e_ucomm' to see which menu button of the toolbar
             has been clicked on.
             Define then the corresponding menu.
             The menu contains function codes that are evaluated
             in 'handle_user_command'.
    query e_ucomm to find out which menu button has been clicked on
        IF e_ucomm = 'MODIFY'.
          CALL METHOD e_object-&gt;add_function
                      EXPORTING fcode   = 'MODIFY'
                                text    = 'Modificar'. "modificar
    § 3a.) choose a default function and define the same function code
            as used for the menu.
         CALL METHOD e_object-&gt;add_function
                     EXPORTING fcode   = 'DECISION'
                               text    = 'Decisión de empleo'. "Decisión
                                                               "de empleo
        ENDIF.
      ENDMETHOD.
      METHOD handle_user_command.
    § 4.At event USER_COMMAND query the function code of each function
        defined in step 3.
    Part III : Evaluate user command to invoke the corresponding
                      function.
        DATA: lt_rows TYPE lvc_t_row.
    get selected row
        CALL METHOD grid1-&gt;get_selected_rows
                 IMPORTING et_index_rows = lt_rows.
        CALL METHOD cl_gui_cfw=&gt;flush.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
               EXPORTING
                    titel = repname
                    txt2  = sy-subrc
                    txt1  = 'Error in Flush'(500).
        ENDIF.
    go to other table
        CASE e_ucomm.
         WHEN 'DECISION'.
           REFRESH T_ROWS.
           PERFORM SELECCION_LINEAS_DECISION TABLES lt_rows.
          WHEN 'MODIFY'.
            REFRESH t_rows.
           PERFORM SELECCION_LINEAS_modify TABLES lt_rows.
           CALL SCREEN 200.
        ENDCASE.
      ENDMETHOD.                           "handle_user_command
    ENDCLASS.
    lcl_event_receiver (Implementation)
    *===================================================================
                   INITIALIZATION                      -
    INITIALIZATION.
      repname = sy-repid.
      PERFORM initialize_fieldcat.
      PERFORM initializa_layout.
       AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alv     -
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvasg.
      PERFORM alvl_value_request USING p_alvasg '  '.
                 START-OF-SELECTION                     -
    START-OF-SELECTION.
      PERFORM obtener_datos.
                 END-OF-SELECTION                        -
    END-OF-SELECTION.
      CALL SCREEN 9010.
                   Subrutinas                            -
         Form  obtener_datos
    FORM obtener_datos.
      REFRESH ti_acred.
      CLEAR ti_acred.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE ti_acred
               FROM lfa1
               WHERE lifnr IN lifnr.
      LOOP AT ti_acred.
        SELECT SINGLE bukrs INTO ti_acred-bukrs FROM lfb1
               WHERE lifnr = ti_acred-lifnr.
        MODIFY ti_acred.
      ENDLOOP.
      i_salida[] = ti_acred[].
    ENDFORM.
          MODULE PBO OUTPUT                                             *
    MODULE status_9010 OUTPUT.
      DATA it_toolbar_excluding TYPE ui_func.
      SET PF-STATUS 'EMPRESA'.
    CLEAR g_custom_container.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container.
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container.
        CALL METHOD grid1-&gt;set_table_for_first_display
             EXPORTING i_structure_name = 'I_SALIDA'
                       is_variant       = t_disvariant
                       i_save           = save
                      I_DEFAULT        = ' '
                       is_layout        = t_layout
             CHANGING  it_outtab        = i_salida
                       it_fieldcatalog  = t_fieldtab.
        SET HANDLER lcl_event_receiver=&gt;handle_user_command
                    lcl_event_receiver=&gt;handle_menu_button
                    lcl_event_receiver=&gt;handle_toolbar FOR ALL INSTANCES.
        CALL METHOD grid1-&gt;set_toolbar_interactive.
      ELSE.
        CALL METHOD grid1-&gt;refresh_table_display.
      ENDIF.
    ENDMODULE.
         Module  EXIT  INPUT
    MODULE exit INPUT.
    REFRESH i_salida.
    CLEAR i_salida.
      SET SCREEN 0.
      LEAVE SCREEN.
    ENDMODULE.                 " EXIT  INPUT
         Form  initialize_fieldcat
    FORM initialize_fieldcat.
      DATA: l_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
      REFRESH t_fieldtab.
    Catálogo de Campos
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
      l_fieldcat-key        = 'X'.
      l_fieldcat-ref_field   = 'BUKRS'.
      l_fieldcat-ref_table   = 'LFB1'.
      l_fieldcat-fieldname  = 'BUKRS'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
      l_fieldcat-key        = 'X'.
      l_fieldcat-ref_field   = 'LIFNR'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'LIFNR'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'NAME1'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'NAME1'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'LAND1'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'LAND1'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'ORT01'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'ORT01'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'PSTLZ'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'PSTLZ'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'REGIO'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'REGIO'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'SORTL'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'SORTL'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
    l_fieldcat-edit       = 'X'.
      l_fieldcat-ref_field   = 'STRAS'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'STRAS'.
      APPEND l_fieldcat TO t_fieldtab.
      CLEAR l_fieldcat.
      l_fieldcat-tabname    = 'I_SALIDA'.
      l_fieldcat-fix_column = 'X'.
      l_fieldcat-no_out     = 'O'.
      l_fieldcat-key        = 'X'.
      l_fieldcat-ref_field   = 'ADRNR'.
      l_fieldcat-ref_table   = 'LFA1'.
      l_fieldcat-fieldname  = 'ADRNR'.
      APPEND l_fieldcat TO t_fieldtab.
    ENDFORM.                    " initialize_fieldcat
         Form  initializa_layout
    FORM initializa_layout.
      t_layout-zebra        = 'X'.
      t_layout-cwidth_opt   = 'X'.
    t_layout-no_toolbar   = 'X'.
    T_LAYOUT-EDIT         = 'X'.
      T_LAYOUT-DETAILINIT    = 'X'.
      T_LAYOUT-CWIDTH_OPT    = 'X'.
      T_LAYOUT-TOTALS_BEF    = 'X'.
      T_LAYOUT-NUMC_TOTAL    = 'X'.
    ENDFORM.                    " initializa_layout
         Module  USER_COMMAND_9010  INPUT
    MODULE user_command_9010 INPUT.
      CASE sy-ucomm.
        WHEN 'SAVE'.
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
             TITLEBAR                    = ' '
             DIAGNOSE_OBJECT             = ' '
              text_question               = 'Pulsaste SAVE'
             TEXT_BUTTON_1               = 'Ja'(001)
             ICON_BUTTON_1               = ' '
             TEXT_BUTTON_2               = 'Nein'(002)
             ICON_BUTTON_2               = ' '
             DEFAULT_BUTTON              = '1'
             DISPLAY_CANCEL_BUTTON       = 'X'
             USERDEFINED_F1_HELP         = ' '
             START_COLUMN                = 25
             START_ROW                   = 6
             POPUP_TYPE                  =
           IMPORTING
             ANSWER                      =
           TABLES
             PARAMETER                   =
           EXCEPTIONS
             TEXT_NOT_FOUND              = 1
             OTHERS                      = 2
          IF sy-subrc &lt;&gt; 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9010  INPUT
         Form  alvl_value_request
    FORM alvl_value_request USING    pi_alv
                                     value(p_0158).
      DATA: l_disvariant TYPE disvariant.
    Wertehilfe
      l_disvariant-report  = sy-cprog.
    l_disvariant-report(1) = 'A'.
      l_disvariant-variant = pi_alv.
      l_disvariant-log_group = p_0158.
      CALL FUNCTION 'LVC_VARIANT_SAVE_LOAD'
           EXPORTING
                i_save_load = 'F'
                i_tabname   = '1'
           CHANGING
                cs_variant  = l_disvariant
           EXCEPTIONS
                OTHERS      = 1.
      IF sy-subrc = 0.
        pi_alv = l_disvariant-variant.
      ELSE.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " ALVL_VALUE_REQUEST
    Kanagaraja L

  • Custom button on a editable alv grid

    Hi experts,
    I'm using an editable alv   like this:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
           EXPORTING
                i_callback_program            = gd_repid
                i_callback_user_command  = 'USER_COMMAND'
    *            I_STRUCTURE_NAME       = 'ZPEDAUTOMTAB'
                is_layout_lvc           = gd_layout
                it_fieldcat_lvc         = it_fieldcat
                i_save                  = 'X'
           TABLES
                t_outtab                = gt_zpedautomtab
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
    Does anybody know if i can add a custom button to the header or anywhere else to program a custom action?
    If it is not; i can use another type of editable alv that lets me do that; if that exists.
    Tank-you.

    Hi
    Check the following template code and adjust accordingly:
    Call the ALV
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          i_callback_pf_status_set    = 'PF_STATUS_SET'
          i_callback_user_command     = 'LINE_CLICK'
          i_callback_top_of_page      = 'TOP_ROUTINE'
          i_callback_html_end_of_list = 'EOL_LOG'
          i_grid_title                = text-ttl
          is_layout                   = my_layout
          it_fieldcat                 = it_fieldcatalog
          it_sort                     = it_sort
          i_save                      = g_save
          i_grid_settings             = lc_glay
          is_variant                  = w_variant
          is_print                    = my_print
        TABLES
          t_outtab                    = i_out
        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.
    *&      Form  top_routine
    FORM top_routine.
    { Local
      DATA:
        w_page(5) TYPE c,
        l_line TYPE slis_entry,
        lh_top TYPE slis_listheader,
        lt_top TYPE slis_t_listheader.
      DEFINE top_line.
        clear lh_top.
        lh_top-typ = &1.
        lh_top-key = &2.
        lh_top-info = &3.
        append lh_top to lt_top.
      END-OF-DEFINITION.
      WRITE sy-datum TO l_line.
      top_line 'S' text-t01 l_line.
      WRITE sy-uname TO l_line.
      top_line 'S' text-t02 l_line.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = lt_top.
    ENDFORM.  "top_routine
    *&      Form  pf_status_set
    FORM pf_status_set USING extab TYPE slis_t_extab.
      data: wa_extab like LINE OF extab.
      wa_extab-fcode = '&REFRESH'.
      append wa_extab to extab.
      wa_extab-fcode = 'MODE'.
      append wa_extab to extab.
      SET PF-STATUS 'ZSD_DA01' EXCLUDING extab.
    ENDFORM.  "pf_status_set
    *&      Form  line_click
    FORM line_click USING ucomm LIKE sy-ucomm
                           selfield TYPE slis_selfield.
      DATA: wl_ucomm LIKE sy-ucomm.
      DATA: es_l TYPE slis_layout_alv,
            es_fld TYPE slis_t_fieldcat_alv,
            es_sort TYPE slis_t_sortinfo_alv,
            es_mark TYPE slis_t_fieldcat_alv.
      wl_ucomm = sy-ucomm.
      CLEAR sy-ucomm.
      CASE wl_ucomm.
    Set printing mode
        WHEN 'MODE'.
          IF w_mode = 'O'.
            w_mode = 'T'.
            w_mode_txt = text-018.
          ELSE.
            w_mode = 'O'.
            w_mode_txt = text-019.
          ENDIF.
          SET PF-STATUS 'ZSD_DA01'.
    Exit Functions
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          LEAVE TO SCREEN 0.
    Show Log
        WHEN 'LOG'.
          selfield-refresh = 'X'.
          PERFORM log_show.
    Issue output
        WHEN 'ISSUE'.
          selfield-refresh = 'X'.
          PERFORM print_deliveries.
    Select all
        WHEN 'SALL'.
          selfield-refresh = 'X'.
          LOOP AT i_out.
            i_out-box = 'X'.
            MODIFY i_out.
          ENDLOOP.
    Deselect all
        WHEN 'DSAL'.
          selfield-refresh = 'X'.
          LOOP AT i_out.
            i_out-box = ' '.
            MODIFY i_out.
          ENDLOOP.
      ENDCASE.
    Handle User clicks
      CASE selfield-fieldname.
    Display Vendor Master
        WHEN 'KUNNR' OR 'KUNAG'.
          IF NOT selfield-value IS INITIAL.
            READ TABLE i_out INDEX selfield-tabindex.
            IF selfield-fieldname = 'KUNAG'.
              SET PARAMETER ID 'KUN' FIELD i_out-kunag.
            ELSEIF selfield-fieldname = 'KUNNR'.
              SET PARAMETER ID 'KUN' FIELD i_out-kunnr.
            ENDIF.
            SET PARAMETER ID 'BUK' FIELD i_out-bukrs_vf.
            SET PARAMETER ID 'VKO' FIELD i_out-vkorg.
            SET PARAMETER ID 'VTW' FIELD i_out-vtweg.
            SET PARAMETER ID 'SPA' FIELD i_out-spart.
            CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
          ENDIF.
    Go To VL03N
        WHEN 'VBELN'.
          READ TABLE i_out INDEX selfield-tabindex.
          IF NOT i_out-vbeln IS INITIAL.
            SET PARAMETER ID 'VL' FIELD i_out-vbeln.
            CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
          ENDIF.
    Go To VA03
        WHEN 'VGBEL'.
          READ TABLE i_out INDEX selfield-tabindex.
          IF NOT i_out-vgbel IS INITIAL.
            SET PARAMETER ID 'AUN' FIELD i_out-vgbel.
            CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    ENDFORM.  "line_click
    Please, reward if helpful
    Regards,
    George

  • Update the Billing orders after display/ modifiy in the Editable ALV

    Hi Experts,
    I have created one Editable ALV to display theBilling order with BP details,
    Once user get the ALV output he can modify the content and same will be updated once he hits UPDATE button.
    my requirement is after user hits the UPDATE button a background should be created and update of BO should happen also user user should able to see the status by checking the SPOOL.
    currently i am using the FM crm_order_maintain to update, kindly guide me how to process this step in background for all the entries which are selected in ALV by user.
    i think i can use SUBMIT with JOB_OPEN and JOB_CLOSE, but i need some same code & guidance.
    Thanks in Advance.
    Regards,
    Pradeep

    problem solved

  • Check unchanged data in an editable alv grid

    Hi,
    I have a problem with my editable ALV. As long as I'm changing my data the event DATA_CHANGED is raised and my fields are checked correctly. But what about unchanged data like appended rows. In that case no changes have been made and the event is not triggered.
    Even if i raise the event by using the method:      
    CALL METHOD gr_grid1->check_changed_data
        IMPORTING
          e_valid   = lv_valid
        CHANGING
          c_refresh = lv_refresh.
    there are no changed data so that my checks:
    FORM data_changed USING  lr_data_changed TYPE REF TO
                                             cl_alv_changed_data_protocol.
      DATA: ls_mod_cells TYPE lvc_s_modi.
      DATA: ls_cells TYPE lvc_s_modi,
            lv_value TYPE lvc_value ,
            lv_matnr TYPE matnr,
            lv_maktx TYPE maktx,
            lv_error TYPE c.
      CLEAR lv_error.
      LOOP AT lr_data_changed->mt_good_cells INTO ls_mod_cells.
        CASE ls_mod_cells-fieldname.
          WHEN 'MATNR'.
            CALL METHOD lr_data_changed->get_cell_value
              EXPORTING
                i_row_id    = ls_mod_cells-row_id
                i_fieldname = 'MATNR'
              IMPORTING
                e_value     = lv_value.
    * CHECK MARA SEGMENT
            SELECT SINGLE mara~matnr
                          makt~maktx INTO (lv_matnr,
                                           lv_maktx)
                                      FROM mara AS mara
                                INNER JOIN makt AS makt
                                        ON mara~matnr = makt~matnr
                                WHERE mara~matnr = lv_value AND
                                      makt~spras = sy-langu.
            IF NOT sy-subrc IS INITIAL.
              CALL METHOD lr_data_changed->add_protocol_entry
                EXPORTING
                  i_msgid     = 'M3'
                  i_msgno     = '305'
                  i_msgty     = 'E'
                  i_msgv1     = lv_value
                  i_fieldname = ls_mod_cells-fieldname
                  i_row_id    = ls_mod_cells-row_id.
              lv_error = 'X'.
            ELSE.
              CALL METHOD lr_data_changed->modify_cell
                EXPORTING
                  i_row_id    = ls_mod_cells-row_id
                  i_fieldname = 'MAKTX'
                  i_value     = lv_maktx.
            ENDIF.
          WHEN OTHERS.
        ENDCASE.
      ENDLOOP.
    ENDFORM.
       are not working.
    Thank you for your help
    Gregor
    Edited by: Gregor Sure on Oct 13, 2009 1:58 PM

    Try to capture the event DATA_CHANGED_FINISHED. You can use the method REGISTER_EDIT_EVENT of the class CL_GUI_ALV_GRID to register the edit events.
    Regards,
    Naimesh Patel

  • Regarding editable alv

    Hi all,
              Frnds i am working in editable alv using function modules not object oriented abap.
    i m trying to edit a Field(MATNR ) in my output list and finally update it with changed values in the DB table.
    But i m getting syntax error like
    "the work area i_final is not alligned properly
    below i m providing my code.
    <code>
    *& Report  ZEDITABLE_ALV1
    REPORT  ZEDITABLE_ALV1.
    TABLES: vbak,vbap.
    TYPE-POOLS: slis. "ALV Declarations
    data: BEGIN OF i_final occurs 0,
          vbeln like vbap-vbeln,
          posnr like vbap-posnr,
          matnr like vbap-matnr,
          erdat like vbap-erdat,
    END OF i_final.
    DATA : C_X(1) TYPE C VALUE 'X',
           C_FC_MODIFY(6) TYPE C VALUE 'MODIFY'.
    *DATA: i_final TYPE STANDARD TABLE OF T_FINAL with header line.
         i_temp type standard table of T_FINAL with header line.
    *wa_final like line of i_final.
    *DATA:i_final LIKE vbap OCCURS 0.
    *DATA:wa_final LIKE vbap.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    gd_tab_group TYPE slis_t_sp_group_alv,
    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.
    PERFORM display_alv_report.
    *& Form BUILD_FIELDCATALOG
    *•     Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    fieldcatalog-fieldname = 'VBELN'.
    fieldcatalog-seltext_m = 'sales order'.
    fieldcatalog-col_pos = 0.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'ERDAT'.
    fieldcatalog-seltext_m = 'date'.
    fieldcatalog-col_pos = 1.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'material no.'.
    fieldcatalog-col_pos = 2.
    fieldcatalog-edit = 'X'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'POSNR'.
    fieldcatalog-seltext_m = 'line item no.'.
    fieldcatalog-col_pos = 3.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-FIELDNAME = 'REC_SEL'.
    fieldcatalog-NO_OUT = C_X.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    ENDFORM. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    *•     Build layout for ALV grid report
    FORM build_layout.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-totals_text = 'Totals'(201).
         gd_layout-totals_only = 'X'.
         gd_layout-f2code = 'DISP'. "Sets fcode for when double
         "click(press f2)
         gd_layout-zebra = 'X'.
         gd_layout-group_change_edit = 'X'.
         gd_layout-header_text = 'helllllo'.
    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_user_command = 'USER_COMMAND'
    i_callback_pf_status_set = 'GUI_STAT'
    *i_grid_title = outtext
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    *it_special_groups = gd_tabgroup
    *it_events = it_events
    i_save = 'X'
    *is_variant = z_template
    TABLES
    t_outtab = i_final
    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. " DISPLAY_ALV_REPORT
    **& Form DATA_RETRIEVAL
    *•     Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
    *SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
    *INNER JOIN vbap AS b ON avbeln = bvbeln
    *INTO TABLE i_final WHERE a~vbeln = b~vbeln.
    select VBELN ERDAT MATNR POSNR up to 10 rows from vbap into corresponding fields of  table i_final.
    ENDFORM. " DATA_RETRIEVAL
    *•     FORM GUI_STAT *
    *•     --> RT_EXTAB *
    FORM gui_stat USING rt_extab TYPE slis_t_extab.
    SET PF-STATUS 'MODIFY' EXCLUDING rt_extab.
    ENDFORM.
    *•     FORM USER_COMMAND *
    *•     --> U_COMM *
    *•     --> RS_SELFIELD *
    FORM user_command USING u_comm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
    DATA:selfield TYPE slis_selfield.
    *RS_SELFIELD-REFRESH = C_X.
    CASE u_comm.
    *IF U_COMM = C_FC_MODIFY.
    WHEN 'UPDATE'.
    LOOP AT i_final. " into wa_final."into wa_final.
    *READ TABLE I_TEMP WITH KEY VBELN = I_FINAL-VBELN.
    *IF SY-SUBRC = 0.
    i_final-matnr = vbap-matnr.
    *MODIFY I_final INDEX SY-TABIX.
    *ENDIF.
    ENDLOOP.
    *ENDIF.
    MODIFY VBAP FROM TABLE i_final.
    IF SY-SUBRC = 0.
    COMMIT WORK AND WAIT.
    *MESSAGE I000 WITH SY-DBCNT
    *' Record(s) has been Updated'(020).
    ENDIF.
    *append i_final.
    *it_temp = i_final.
    *append it_temp.
    **UPDATE sflight FROM TABLE sflight_tab.
    *ENDLOOP.
    *update vbap from table i_final.
    *IF sy-subrc = 0.
    *MESSAGE s000(0) WITH 'records updated successfully'.
    *ENDIF.
    ENDCASE.
    ENDFORM.
    </code>
    Frnds plz help me in this regard.
    Thanks,
    satya

    Try something like this...ur code was not clear..i have done something u can understand.
    First check that u r not trying to update the primary key field.
    first before updating.
    Before updating select the record u r going to update from the main table.
    select single * from VBAP where <pass the key values>.
    if sy-subrc = 0.
    move the rest of the values to the table header except the key values.
    vbap-<field1> = value1.
    vbap-<field2> = value2.
    after moving the values.
    update <table>.
    if sy-subrc = 0.
    commit work.
    endif.
    data:st_vbap type vbap.
    WHEN 'UPDATE'.
    LOOP AT i_final. " into wa_final."into wa_final.
    select single * from vbap where vbeln = I_FINAL-VBELN.
    move-corresponding i_final to vbap.
    update vbap.
    if sy-subrc = 0.
    commit work.
    wk_cnt = wk_cnt + 1.
    endif.
    at last.
    *MESSAGE I000 WITH SY-DBCNT
    *' Record(s) has been Updated'(020).
    endat.
    endloop

  • Problem While Saving the editable ALV GRID

    Dear Experts,
    I have a scenario in which i am display the ALV(using class) with some data in the custom container of module pool screen in the non-editable mode.Also i have save and edit buttons.If i click the edit button i have written the code to edit the some columns in the ALV grid, it is working fine.After editing it,when i click the save button then ALV has to refreshed with edited data and then it should go to non editable mode but it is not working.I have written the code for changing the editable ALv to non editable mode as follows :
      call method c_alvgd->set_ready_for_input
        exporting
          i_ready_for_input = 0.
    *****Row and column of the alv are refreshed after changing values
      stable-row = 'X'.
      stable-col = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      call method c_alvgd->refresh_table_display
        exporting
          is_stable = stable
        exceptions
          finished  = 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.
    Could you Suggest me solution for this issue ?
    Thanks & Regards,
    R.Dhineshraj.

    Dhinesh,
    I suppose that you are able to get your changes values on screen but not able to get your field in DISPLAY mode from editable mode, let me know if this is not your problem.
    When you press SAVE, after the PAI, again PBO will run and hence the editable code for that field will overwrite which will keep it editable.
    So, do something like this.
    data: gv_edit value 'X'.....  "global variable in TOP include
    PBO....
    loop at ...
    if gv_edit = 'X'.
    CALL METHOD lo_alv->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
    else.
    CALL METHOD lo_alv->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
    endif.
    endloop.
    PAI.
    when 'SAVE'.
    gv_edit =  space.
    When 'EDIT'.
    gv_edit = 'X'.
    Regards,
    Diwakar

  • Get Current row in Editable ALV

    Hi,
    I have editable alv, when i press "insert row" or "Append row" i need to get current inserted/appended row element reference or index.
    How can i get this??
    Please suggest.

    Hi kranthi ,
    While inserting row you must be selecting a row, you can get the index of the selected row by this following code
    get Index of selected table item
    CALL METHOD NODE_NAME->GET_LEAD_SELECTION_INDEX
    RECEIVING INDEX = Lv_Indx.
    ( DATA: Lv_Indx Type i )
    or while you are appending a row you can use Describe int_table LINES lv_line and use the value of 'lv_line' as the index.
    Regards

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

    Hi all,
    I've implemented an editable ALV and also the ON_DATA_CHECK event to check the values, entered in the ALV. So this works fine and I can check the values.
    But now, I want to throw an error message corresponding to the field in the ALV, where the error occured.
    How can I throw this error message corresponding to a specific line/field in the ALV?
    I was using REPORT_ATTRIBUTE_ERROR_MESSAGE and REPORT_ELEMENT_ERROR_MESSAGE but without success.
    I'm also using a loop over the "CHANGES" in the ALV and within this loop, I use
    elem_alv = node_alv->get_element( index = <change>-element_index ) 
    to get the element for the message.
    CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
      EXPORTING
        MESSAGE_TEXT              = 'my message'
        ELEMENT                   = elem_alv
    *    ATTRIBUTES                =
    *    PARAMS                    =
    *    MSG_USER_DATA             =
    *    IS_PERMANENT              = ABAP_FALSE
    *    SCOPE_PERMANENT_MSG       = CO_MSG_SCOPE_CTXT_ELEMENT
    *    MSG_INDEX                 =
    *    CANCEL_NAVIGATION         =
    *    IS_VALIDATION_INDEPENDENT = ABAP_FALSE.
    2.) is it right, that for an editable ALV, I can't use the WDDOBEFOREACTION to do the checks?
    If I try to use this, I can't get the values of my ALV table to check it.
    Thanks,
    Andreas

    Hi Andreas,
    I have tried to replicate your problem and I am getting the desired output. I have a row by name TEMP_NEW in my ALV and I want to throw an error message whenever the user enters a value of 4 for that particular field. Please find my coding as below. The important thing is where we perform the actual comparison between the r_value and 4. r_value is defined in SALV_WD_S_TABLE_MOD_CELL as reference to type DATA. So suppose the user enters a value of say 3 in the TEMP_NEW field of the ALV then r_value would contain 3 but if you observe its type in debugging mode it would be as TYPE REF TO I and not TYPE I. So you cannot directly say something like:
    "if ls_modified_cells-r_value = 3" as this would lead to a syntax error. Define a field-symbol say <temp> and then use it to get the actual value into it by saying like:
    ASSIGN ls_modified_cells-r_value->* TO <temp>.
    Then you can use this <temp> for comparison in your IF statement like:
    IF  <temp> = 3.
    Find the entire coding as below:
    METHOD check_data.
      DATA: lr_node TYPE REF TO if_wd_context_node,
            lr_element TYPE REF TO if_wd_context_element,
            ls_modified_cells TYPE salv_wd_s_table_mod_cell.
      FIELD-SYMBOLS <temp> TYPE data.
    " get message manager
      DATA lo_api_controller     TYPE REF TO if_wd_controller.
      DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
      lo_api_controller ?= wd_this->wd_get_api( ).
      CALL METHOD lo_api_controller->get_message_manager
        RECEIVING
          message_manager = lo_message_manager.
      lr_node = wd_context->get_child_node( name = 'NODE' ).
      LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
        lr_element = lr_node->get_element( index = ls_modified_cells-index ).
        IF ls_modified_cells-attribute = 'TEMP_NEW'.
    " Get the value extracted into the field symbol from the reference variable
          ASSIGN ls_modified_cells-r_value->* TO <temp>.
    " Use the value present in this field-symbol for your comparison
          IF  <temp> = 4.
    " report message
            CALL METHOD lo_message_manager->report_attribute_error_message
              EXPORTING
                message_text   = 'Sample message text'
                element        = lr_element
                attribute_name = ls_modified_cells-attribute.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDMETHOD.
    Hope this helps resolve your problem.
    Regards,
    Uday

Maybe you are looking for