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.
--> 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->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->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->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->get_selected_rows
             IMPORTING et_index_rows = lt_rows.
    CALL METHOD cl_gui_cfw=>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->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=>handle_user_command
                lcl_event_receiver=>handle_menu_button
                lcl_event_receiver=>handle_toolbar FOR ALL INSTANCES.
    CALL METHOD grid1->set_toolbar_interactive.
  ELSE.
    CALL METHOD grid1->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 <> 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

Similar Messages

  • How to edit ALV report using function modules

    I have a ALV report , i want to edit the report
    using function modules.
    how can i do that...
    Edited by: ms kumar on Mar 6, 2008 3:24 PM

    hi i had used this report with the check box,
    using the fm of alvs.....
    *& Report  ZZZ00
    REPORT  ZPR_02.
    TYPE-POOLS: SLIS.
    TABLES:pa0002,pa0008.
    data:begin of it_pa0002 occurs 0,
         checkbox,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         end of it_pa0002.
    data:begin of it_pa00021 occurs 0,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         expand TYPE xfeld value 'X',
         end of it_pa00021.
    data:begin of it_pa0008 occurs 0,
         pernr like pa0008-pernr,
         begda like pa0008-begda,
         endda like pa0008-endda,
         ANSAL like pa0008-ANSAL,
         LGA01 like pa0008-LGA01,
         BET01 LIKE PA0008-BET01,
         end of it_pa0008.
    DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
          IT_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
          WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
          WA_FIELD_CAT1 TYPE SLIS_FIELDCAT_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_HEADER TYPE SLIS_T_LISTHEADER,
          WA_HEADER TYPE SLIS_LISTHEADER,
          wa_keyinfo TYPE slis_keyinfo_alv.
    CONSTANTS:c VALUE 'X'.
    SELECT-OPTIONS: S_pernr FOR pa0002-pernr.
    START-OF-SELECTION.
      SET PF-STATUS 'DATA' .
      PERFORM GET_DATA.
      PERFORM BUILD_FIELD_CAT.
      PERFORM GET_EVENTS.
      PERFORM DISPLAY_DATA.
    *&      Form  get_data
          text
    FORM GET_DATA .
      SELECT pernr
             begda
             endda
             vorna
             nachn
             FROM pa0002
             INTO CORRESPONDING FIELDS OF TABLE IT_pa0002
             WHERE pernr IN S_pernr.
    ENDFORM.                    " get_data
    *&      Form  build_field_cat
          text
    FORM BUILD_FIELD_CAT .
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'CHECKBOX'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Check Box'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'PERNR'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'BEGDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'ENDDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'VORNA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'NACHN'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'PERNR'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'BEGDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'ENDDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'VORNA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'NACHN'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'PERNR'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'personnelno'.
        APPEND wa_field_cat1 TO it_field_cat1.
       CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BEGDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'begindate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ENDDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'enddate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ANSAL'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'annualsalary'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'LGA01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'wagetype'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BET01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'Amount'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
    ENDFORM.                    " build_field_cat
    *&      Form  display_data
          text
    FORM DISPLAY_DATA .
    it_layout-box_fieldname = 'CHECKBOX'.
    it_layout-EDIT = 'X'.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM             = SY-REPID
          I_CALLBACK_PF_STATUS_SET       = 'PF_STATUS'
          I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
          IT_FIELDCAT                    = IT_FIELD_CAT
          IS_LAYOUT                      = IT_LAYOUT
          IT_EVENTS                      = IT_EVENTS
        TABLES
          T_OUTTAB           = IT_pa0002.
    ENDFORM.                    " display_data
    *&      Form  get_events
          text
    FORM GET_EVENTS .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       IMPORTING
         ET_EVENTS             = IT_EVENTS .
      READ TABLE IT_EVENTS INTO WA_EVENTS
                           WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
      IF SY-SUBRC = 0.
        WA_EVENTS-FORM = 'TOP_OF_PAGE'.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDIF.
    ENDFORM.                    " get_events
    *&      Form  top_of_page
          text
    FORM TOP_OF_PAGE.
      WA_HEADER-TYP = 'H'.
      WA_HEADER-INFO = 'EMPLOYEE DATA'.
      APPEND WA_HEADER TO IT_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_HEADER
    ENDFORM. "top_of_page
    *&      Form  GUI_SET
    FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
      SET PF-STATUS 'DATA' .
    ENDFORM.                    "GUI_SET
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            R_SELFIELD TYPE SLIS_SELFIELD.
    DATA:V_PERNR LIKE PA0002-PERNR.
      CASE R_UCOMM.
        WHEN 'DET'.
    DATA: V_FLAG.
      clear : v_flag.
    LOOP AT IT_PA0002.
         if it_PA0002-checkbox =  'X'.
                   v_flag = 'X'.
              v_pernr = IT_PA0002-PERNR.
    SELECT  PERNR
            BEGDA
            ENDDA
            VORNA
            NACHN
            FROM PA0002
            INTO CORRESPONDING FIELDS OF TABLE IT_PA00021
            WHERE PERNR = V_PERNR.
    SORT IT_PA00021 BY PERNR.
    DELETE ADJACENT DUPLICATES FROM IT_PA00021 COMPARING PERNR.
    READ TABLE IT_PA00021 INDEX 1.
    SELECT PERNR
           BEGDA
           ENDDA
           ANSAL
           LGA01
           BET01
           FROM PA0008
           INTO TABLE IT_PA0008
           FOR ALL ENTRIES IN IT_PA00021
           WHERE PERNR = IT_PA00021-PERNR.
              if not it_PA0008[] Is initial.
              SORT IT_PA0008 BY PERNR.
             delete adjacent duplicates from  it_PA0008 comparing pernr.
              READ TABLE IT_PA0008 INDEX 1.
              endif.
            endif.
         enddo.
      it_layout1-group_change_edit = c.
      it_layout1-colwidth_optimize = c.
      it_layout1-zebra             = c.
      it_layout1-detail_popup      = c.
      it_layout1-get_selinfos      = c.
      it_layout-expand_fieldname  = 'EXPAND'.
      wa_keyinfo-header01 = 'PERNR'.
      wa_keyinfo-item01 = 'PERNR'.
    IF NOT V_FLAG IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
        IS_LAYOUT                      = IT_LAYOUT1
       IT_FIELDCAT                    =  IT_FIELD_CAT1
        I_TABNAME_HEADER               = 'PA0002'
        I_TABNAME_ITEM                 = 'PA0008'
        IS_KEYINFO                     = wa_keyinfo
        TABLES
        T_OUTTAB_HEADER                = IT_PA00021
        T_OUTTAB_ITEM                  = IT_PA0008.
    ENDIF.
    CLEAR: IT_PA00021,IT_PA0002,IT_PA0008.
    ENDLOOP.
    WHEN 'BACK'.
    EXIT.
    ENDCASE.
    ENDFORM.                    "USER_COMMAND
    reward points if useful,
    venkat.

  • Editable ALVs - How to update DB?

    Hi Experts,
    Out of my curiosity, wuld like to know,
    How the Editable ALVs do updation of DB? I mean, prog. flow?
    thanq.

    ThanQ Sarda,
    OK, I got it.
    Actually, I dont hv much idea abt Editable ALVs! My thinking is like,
    Supose,
    the user changed from 4.63 to 5.63 on ALV grid,
    then, the user either pressed the SAVE(Floppy) or used the programmer defined push button on the front end screen, say the push button name is, UPDATE.
    So,
    1 - Now, How I hv to pull( I mean, How I hv to read the ALV grid?) the (front end value of) 5.63 value to back end, which is to b used for passing to either BAPI/FM or BDC etc. in the prog. for DB updation?
    2 - If the user used the FLOPPY button i.e. SAVE, How to track it ( I know, if the user defined push button is there, we can track by using SY-UCOMM)?
    thanq.

  • 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

  • How can we find out data in an editable ALV grid has been changed or not?

    Hi Experts,
    How can we find out whether a data in an editable ALV grid has been changed or not.
    I am using the
    FM -> REUSE_ALV_GRID_DISPLAY_LVC
    for ALV display.
    I have to chekc whther data has been changed or not befor saving. if changed then only i want to
    SAVE
    . I cannot use the internal table comparison method for this purpose also i am not using OOP ALV.
    So kindly sugest me an alternative.
    Thanks and Regards,
    Shahana

    Hi,
    Thanks for your answer. I already saw this post.
    See this method.
    CALL METHOD reuse_alv_grid->check_changed_data
    IMPORTING
    e_valid = lv_check.
    This will update the internal table with the edited values. Then we can go for internal table comparison.
    But my scenario will not allow me for itab comparisons.I just want to know the ALV data has been changed or not.
    Regards,
    Shahana

  • Here's how to do ALV (OO) with dynamic fcat, int table and editable data

    Hi everybody
    Here's a more useful approach to ALV grid with OO using dynamic table, data NOT from DDIC, dynamic FCAT and how to get changed lines from the grid when ENTER key is pressed.
    It's really not too dificult but I think this is more useful than the ever present SFLIGHT methods from the demos.
    This also defines a subclass of cl_gui_alv_grid so you can access the protected attributes / methods of that class.
    You don't need to add the class via SE24 -- done fron this ABAP.
    When you run it click Edit for the first time.
    After editing data press ENTER and the break point should bring you into the relevant method.
    Code developed on NW2004S trial version but also works on rel 6.40 on a "Real" system.
    The code should work without any changes on any system >=6.40.
    All you need to do is to create a blank screen 100 via SE51  with a custom container on it called CCONTAINER1.
    The rest of the code can just be uploaded into your system using the SE38 upload facility.
    When running the program click on the EDIT button to enable the edit functionality of the grid.
    Change your data and when you press ENTER you should get the break-point where you can see the original table and changed rows.
    This program is actually quite general as it covers Dynamic tables, building a dynamic fcat where your table fields are NOT in the DDIC, intercepting the ENTER key via using an event, and accessing the protected attributes of the cl_gui_alv_grid by defining a subclass of this class in the abap.
    I've seen various questions relating to all these functions but none in my view ever answers the questions in a simple manner. I hope this simple program will answer all these and show how using OO ALV is actually quite easy and people shouldn't be scared of using OO.
    Have fun and award points if useful.
    Cheers
    Jimbo.
    <b>PROGRAM zdynfieldcat.
    Simple test of dynamic ITAB with user defined (not ddic) fields
    Build dynamic fcat
    use ALV grid to display and edit.
    *When edit mode set to 1 toolbar gives possibility of adding and
    *deleting rows.
    *Define subclass of cl_gui_alv_grid so we can use protected attributes
    *and methods.
    Add event handler to intercept user entering data and pressing the
    *ENTER key.
    When enter key is pressed get actual value of NEW table (all rows)
    rather than just the changed data.
    *use new RTTI functionality to retrieve internal table structure
    *details.
    Create a blank screen 100  with a custom container called CCONTAINER1.
    James Hawthorne
    include <icon>.
    define  any old internal structure  NOT in DDIC
    types: begin of s_elements,
           anyfield1(20) type c,
           anyfield2(20) type c,
           anyfield3(20) type c,
           anyfield4(20) type c,
           anyfield5(11) type n,
           end of s_elements.
    types:  lt_rows  type lvc_t_roid.
    Note new RTTI functionality allows field detail retrieval
    at runtime for dynamic tables.
    data:   wa_element type s_elements ,
            wa_data type s_elements,
            c_index type sy-index,
            c_dec2 type s_elements-anyfield5,
            wa_it_fldcat type lvc_s_fcat,
            it_fldcat type lvc_t_fcat,
            lr_rtti_struc TYPE REF TO cl_abap_structdescr,    "RTTI
            lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
            ls_comp LIKE LINE OF lt_comp,                     "RTTI
            zog  like line of lr_rtti_struc->components,      "RTTI
            struct_grid_lset type lvc_s_layo,
            l_valid  type c,
            new_table type ref to data.
    field-symbols: <dyn_table> type standard table,
                   <actual_tab> type standard table,
                   <fs1> type ANY,
                   <FS2> TYPE TABLE.
    data: grid_container1 type ref to cl_gui_custom_container.
    class lcl_grid_event_receiver definition deferred.
    data: g_event_receiver type ref to lcl_grid_event_receiver.
    data: ls_modcell type LVC_S_MODI,
          stab type ref to data,
          sdog type  s_elements.      .
    class lcl_grid_event_receiver definition.
      public section.
        methods:
        handle_data_changed
             for event data_changed of cl_gui_alv_grid
                 importing er_data_changed,
           toolbar for event toolbar of cl_gui_alv_grid
                     importing e_object
                               e_interactive,
          user_command for event user_command of cl_gui_alv_grid
                     importing e_ucomm.
    endclass.
    *implementation of Grid event-handler class
    class lcl_grid_event_receiver implementation.
    method handle_data_changed.
    code whatever required after data entry.
    various possibilites here as you can get back Cell(s) changed
    columns or the entire updated table.
    Data validation is also possible here.
    perform check_data using er_data_changed.
    endmethod.
    Method for handling all creation/modification calls to the toolbar
      method toolbar.
        data : ls_toolbar type stb_button.
    Define Custom Button in the toolbar
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EDIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Edit' to ls_toolbar-text.
        move icon_change_text to ls_toolbar-icon.
        move 'Click2Edit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'UPDA' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Update' to ls_toolbar-text.
        move icon_system_save to ls_toolbar-icon.
        move 'Click2Update' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EXIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Exit' to ls_toolbar-text.
        move icon_system_end to ls_toolbar-icon.
        move 'Click2Exit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.
      method user_command.
        case e_ucomm .
          when 'EDIT'.          "From Tool bar
            perform set_input.
             perform init_grid.
          when 'UPDA'.          "From Tool bar
            perform refresh_disp.
            perform update_table.
          when 'EXIT'.          "From Tool bar
            leave program.
        endcase.
      endmethod.
    endclass.
    class zcltest definition inheriting from  cl_gui_alv_grid.
    define this as a subclass so we can access the protected attributes
    of the superclass cl_gui_alv_grid
    public section.
    methods: constructor, disp_tab.
    endclass.
    need this now to instantiate object
    as we are using subclass rather than the main cl_gui_alv_grid.
    class zcltest implementation.
    METHOD constructor.
    CALL METHOD super->constructor
            exporting i_appl_events = 'X'
               i_parent = grid_container1.
    endmethod.
    method disp_tab.
    FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
    break-point 1.
    mt_outtab is the data table held as a protected attribute
    in class cl_gui_alv_grid.
    ASSIGN me->mt_outtab->* TO <outtab>.  "Original data
    do whatever you want with <outtab>
    contains data BEFORE changes each time.
    Note that NEW (Changed) table has been obtained already by
    call to form check_data USING P_ER_DATA_CHANGED
             TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Entered data is in table defined by <fs2>
    In this method you can compare original and changed data.
    Easier than messing around with individual cells.
    do what you want with data in <fs2>  validate / update / merge etc
    endmethod.
    endclass.
    data :
        ok_code like sy-ucomm,
        save_ok like sy-ucomm,
        i4 type int4,
    Container Object [grid_container]
    now created via method constructor
    in the subclass zcltest.
    Control Object [grid]
    grid1 type ref to zcltest,
    Event-Handler Object [grid_handler]
    grid_handler type ref to lcl_grid_event_receiver.
    start-of-selection.
    call screen 100.
    module status_0100 output.
    now display it as grid
    if grid_container1 is initial.
        create object grid_container1
            exporting
              container_name = 'CCONTAINER1'.
        create object grid1.
         break-point 1.
        create object grid_handler.
        set handler:
           grid_handler->user_command for grid1,
           grid_handler->toolbar for grid1,
           grid_handler->handle_data_changed for grid1.
    perform create_dynamic_fcat.
    perform create_dynamic_itab.
    perform populate_dynamic_itab.
    perform init_grid.
    perform register_enter_event.
    set off ready for input initially
    i4 = 0.
      call method grid1->set_ready_for_input
             exporting
               i_ready_for_input = i4.
    endif.
    endmodule.
    module user_command_0100 input.
    *PAI not needed in OO ALV anymore as User Commands are handled as events
    *in method user_command.
    *we can also get control if the Data entered and the ENTER is pressed by
    *raising an event.
    Control then returns to method handle_data_changed.
    endmodule.
    form create_dynamic_fcat.
    get structure of our user table for building field catalog
    Use the RTTI functionality
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
    Build field catalog just use basic data here
    colour specific columns as well
    loop at lr_rtti_struc->components into zog.
    c_index = c_index + 1.
    clear wa_it_fldcat.
      wa_it_fldcat-fieldname = zog-name .
      wa_it_fldcat-datatype =  zog-type_kind.
      wa_it_fldcat-inttype =   zog-type_kind.
      wa_it_fldcat-intlen =    zog-length.
      wa_it_fldcat-decimals =  zog-decimals.
      wa_it_fldcat-lowercase = 'X'.
      if c_index eq 2.
      wa_it_fldcat-emphasize = 'C411'.
         endif.
        if c_index eq 3.
      wa_it_fldcat-emphasize = 'C511'.
       endif.
      append wa_it_fldcat to it_fldcat .
    endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to field sysmbol.
    Use dynamic field catalog just built.
    call method cl_alv_table_create=>create_dynamic_table
                 exporting
                    it_fieldcatalog = it_fldcat
                 importing
                    ep_table        = new_table.
    assign new_table->* to <dyn_table>.
    endform.
    form populate_dynamic_itab.
    load up a line of the dynamic table
    c_dec2 = c_dec2 + 11.
    wa_element-anyfield1 = 'Tabbies'.
    wa_element-anyfield2 = 'ger.shepards'.
    wa_element-anyfield3  = 'White mice'.
    wa_element-anyfield4 =  'Any old text'.
    wa_element-anyfield5 =  c_dec2.
    append  wa_element to <dyn_table>.
    endform.
    form check_data USING P_ER_DATA_CHANGED
               TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Get altered data back
      ASSIGN   p_er_data_changed->mp_mod_rows TO <FS1>.
    stab =       p_er_data_changed->mp_mod_rows.
    ASSIGN STAB->* TO <FS2>.
    LOOP AT <FS2> INTO sdog.
    ALV grid display with altered data is now in <fs2>.
    do any extra processing you want here
    endloop.
    now display new table
    call method grid1->disp_tab.
    endform.
    form exit_program.
      call method grid_container1->free.
      call method cl_gui_cfw=>flush.
      leave program.
    endform.
    form refresh_disp.
      call method grid1->refresh_table_display.
    endform.
    form update_table.
    The dynamic table here is the changed table read from the grid
    after user has changed it
    Data can be saved to DB or whatever.
    loop at <dyn_table> into wa_element.
    do what you want with the data here
    endloop.
    switch off edit mode again for next function
    i4 = 0.
      call method grid1->set_ready_for_input
          exporting
              i_ready_for_input = i4.
    endform.
    form set_input.
    i4 = 1.
      call method grid1->set_ready_for_input
         exporting
           i_ready_for_input = i4.
    endform.
    form switch_input.
    if i4 = 1.
    i4 = 0.
    else.
    i4 = 1.
    endif.
      call method grid1->set_ready_for_input
         exporting
           i_ready_for_input = i4.
    endform.
    form init_grid.
    Enabling the grid to edit mode,
         struct_grid_lset-edit = 'X'. "To enable editing in ALV
         struct_grid_lset-grid_title  = 'Jimbos Test'.
         call method grid1->set_table_for_first_display
           exporting
             is_layout           = struct_grid_lset
           changing
             it_outtab             =  <dyn_table>
             it_fieldcatalog       =  it_fldcat.
    endform.
    form register_enter_event.
    call method grid1->register_edit_event
                   exporting
                      i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    Instantiate the event or it won't work.
    create object g_event_receiver.
    set handler g_event_receiver->handle_data_changed for grid1.
    endform.</b>

    Hi there
    IE7 doesn't give me the add new page option and I get 404 error when trying to access the "How to contribute" section.
    I'll load up Firefox later (this browser usually works when IE7 doesn't always work properly).
    I'll copy the stuff to the wiki when I've got the browser sorted out.
    Cheers
    jimbp

  • How to edit only some rows in ALV

    Hi Experts,
    I have editable ALV. I need to allow edit only for some rows, not generaly all of them.
    Do you have any idea how to do it?
    I use ALV through FM module REUSE_ALV_GRID_DISPLAY.
    Thenks&regards,
    Jirka

    Hi,
    You need to use events. Sample code from sdn.
    TYPE-POOLS:SLIS.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:IT_EVENTS TYPE SLIS_T_EVENT.
    data: begin of it_chg occurs 0,
          index type sy-tabix,
          end of it_chg.
    DATA:  X_EVENTS    TYPE SLIS_ALV_EVENT.
    DATA: BEGIN OF ITAB OCCURS 0,
          NAME(10) TYPE C,
          ZTERM TYPE C,
          END OF ITAB.
    PERFORM FILL_TABLE.
    loop at itab where zterm = 'A'.
    it_chg-index = sy-tabix + 3. 
    " addition 3 IS FOR FIELD LABELS
    append it_chg.
    clear it_chg.
    endloop.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    **fieldcatalog
    X_FIELDCAT-FIELDNAME = 'NAME'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-FIELDNAME = 'ZTERM'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    **events
    REFRESH:IT_EVENTS.
    CLEAR:X_EVENTS,IT_EVENTS.
    X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
    X_EVENTS-FORM = 'MODIFY_LIST'.
    APPEND X_EVENTS TO IT_EVENTS.
    CLEAR X_EVENTS.
    END-OF-SELECTION.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = SY-REPID
          IT_FIELDCAT        = IT_FIELDCAT
          IT_EVENTS          = IT_EVENTS
        TABLES
          T_OUTTAB           = ITAB
        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 FILL_TABLE
          text
    FORM FILL_TABLE.
      ITAB-NAME = 'vijay'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ABC'.
      ITAB-ZTERM = 'B'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'TEST'.
      ITAB-ZTERM = 'C'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'DILIP'.
      ITAB-ZTERM = 'D'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = '123'.
      ITAB-ZTERM = 'E'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'GEN'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALV'.
      ITAB-ZTERM = 'F'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALVTEST'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
    ENDFORM.                    "FILL_TABLE
    *&      Form  MODIFY_LIST
          text
    FORM MODIFY_LIST.
    data: l_lines type i.
    describe table itab lines l_lines.
      L_LINES  = L_LINES + 3.
      "because we have 3 lines extra occupied by lables.
      "if we have header,i mean top of page add the no.of lines
      "how many ever top of page have + 3 for labels.
      DO L_LINES TIMES.
        read table it_chg with key INDEX = sy-index.
        if sy-subrc = 0.
    **This code is for reading the out put line
    **and modify accordinlg to our requiremnet.
    **don't chnage this.
          READ LINE SY-INDEX INDEX SY-LSIND.
          IF SY-SUBRC = 0.
            MODIFY LINE SY-INDEX INDEX SY-LSIND
                       FIELD FORMAT ITAB-NAME INPUT.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    "MODIFY_LIST

  • 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

  • How to Edit the CheckBox in Classic ALV GRID Display

    Hi,
    I want to Edit the checkbox in Grid Display.
    I have one checkbox field in my internal Table,
    Code Of the Program,
    Data :
    Begin of itab occurs 0,
    CHK type C,
    MATNR like MARA-MATNR,
    end of itab.
    Iam building the fieldcatelog using Merge Funcion module.
    After that I am chaning the properties of the field
    catelog like below,
    loop at I_FCAT assigning <FCAT>.
    Case <FCAT>-Fieldname
    When 'CHK'.
    <FCAT>-Checkbox = 'X'.
    <FCAT>-INPUT = 'X'.
    I dont have edit option in fieldcatelog.
    modify I_FCAT from <FCAT>.
    endcase.
    endloop.
    In the Layout,
    I_LAYOUT-box_fieldname = 'CHK'.
    I_LAYOUT-box_tabname = 'ITAB'.
    It is displaying the Checkbox field.but I couldnt edit the checkBox.
    I can able to edit in REUSE_ALV_LIST_DISPLAY.
    But I  have to use REUSE_ALV_GRID_DISPLAY.How to edit the checkbox.
    Thanks in Advance,
    Sumithra

    Hi vasu,
    The below procedure explains you to create a checkbox cloumn in the grid and allows you to edit i hope this will helps u.
    The ALV Grid Control displays the cells of a column as checkboxes if the column is marked as a checkbox column in the field catalog.
    •     Add another field to the output table in which you want to display checkboxes
    OR
    •     Define an existing field as a checkbox.
    Procedure
    1.     Add a field to your output table:
    Data: gt_fieldcat type lvc_t_fcat.
    Types: begin of gs_outtab.
    Types: checkbox type c. "field for checkbox
    Include structure <ABAP Dictionary structure> .
    Types: end of gs_outtab.
    Data: gt_outtab type gs_outtab occurs 0 with header line.
    2 * Add an entry for the checkbox to the field catalog
    clear ls_fcat.
    ls_fcat-fieldname = 'CHECKBOX'.
    * Essential: declare field as checkbox and
    * mark it as editable field:
    ls_fcat-checkbox = 'X'.
    ls_fcat-edit = 'X'.
    * do not forget to provide texts for this extra field
    ls_fcat-coltext = text-f01.
    ls_fcat-tooltip = text-f02.
    ls_fcat-seltext = text-f03.
    append ls_fcat to gt_fieldcat.
    regards,
    venu.

  • Hi gurus in ALV how to edit the fields on out put list

    hi gurus in ALV how to edit the fields on out put list

    hi
    REPORT ZSB_ALV_EDITABLE_SAMPLE.
    TABLES: SFLIGHT.
    DATA: gc_container TYPE scrfname VALUE 'LIST_AREA',
    gc_custom_container TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    gc_grid TYPE REF TO CL_GUI_ALV_GRID,
    gs_layout TYPE LVC_S_LAYO,
    gt_fieldcat TYPE LVC_T_FCAT.
    DATA: ok_code TYPE SY-UCOMM.
    DATA: gt_outtab TYPE TABLE OF SFLIGHT.
    *DYNPRO
    CALL SCREEN 100.
    *& Module STATUS_0100 OUTPUT
    MODULE STATUS_0100 OUTPUT.
    SET PF-STATUS '100'.
    CREATE OBJECT gc_custom_container
    EXPORTING
    container_name = gc_container
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    OTHERS = 6.
    CREATE OBJECT gc_grid
    EXPORTING
    i_parent = gc_custom_container
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    OTHERS = 5 .
    PERFORM prepare_field_catalog CHANGING gt_fieldcat .
    PERFORM prepare_layout CHANGING gs_layout .
    PERFORM get_alv_display.
    ENDMODULE.
    *& Module USER_COMMAND_0100 INPUT
    MODULE USER_COMMAND_0100 INPUT.
    OK_CODE = SY-UCOMM.
    IF OK_CODE = 'BACK'.
    SET SCREEN 0.
    LEAVE SCREEN.
    CLEAR OK_CODE.
    ENDIF.
    ENDMODULE.
    FORM prepare_field_catalog CHANGING gt_fieldcat TYPE LVC_T_FCAT.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    I_BUFFER_ACTIVE =
    I_STRUCTURE_NAME = 'SFLIGHT'
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_BYPASSING_BUFFER =
    I_INTERNAL_TABNAME =
    CHANGING
    ct_fieldcat = gt_fieldcat[].
    ENDFORM.
    FORM prepare_layout changing p_gs_layout TYPE lvc_s_layo.
    p_gs_layout-zebra = 'X'.
    p_gs_layout-edit = 'X'.
    ENDFORM. " prepare_layout
    FORM get_alv_display .
    SELECT * FROM sflight INTO TABLE gt_outtab UP TO 10 ROWS.
    CALL METHOD gc_grid->set_table_for_first_display
    EXPORTING
    I_STRUCTURE_NAME = 'SFLIGHT'
    IS_LAYOUT = gs_layout
    CHANGING
    it_outtab = gt_outtab
    IT_FIELDCATALOG = gt_fieldcat
    ENDFORM. " get_alv_display

  • How to make cell editable alv in WebDynpro for ABAP?

    I make Column editable ALV.(See under source code)
    But I can't make Cell editable ALV.
    How to make Cell editable ALV in WebDynpro for ABAP?
    and..how to get changed data?
    DATA: l_value TYPE REF TO cl_salv_wd_config_table.
      l_value = l_ref_interfacecontroller->get_model( ).
    * { EDITABLE
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
            lr_input_field     TYPE REF TO cl_salv_wd_uie_input_field,
            lr_column          TYPE REF TO cl_salv_wd_column.
      lr_column_settings ?= l_value.
      lr_column = lr_column_settings->get_column( 'TOTAL_COUNT' ).
      CREATE OBJECT lr_input_field
        EXPORTING
          value_fieldname = 'TOTAL_COUNT'.
      lr_column->set_cell_editor( lr_input_field ).
      DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.
      lr_table_settings ?= l_value.
      lr_table_settings->set_read_only( abap_false ).

    the code seems to be correct....but where are you writing it?
    put the code in the wddoinit method and it should work.
    have a look at this article..
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1

  • How to Edit selected row in ALV

    Hi Experts,
                    I new to webdynpro ABAP. How to Edit the entire selected row in ALV. Please suggest?
    Thanks in advance.

    Hi,
    I guess you have created the node as dynamic and also set this to the ALV..
    1.  Have you created READ_ONLY attribute of type wdy_boolean inside the node to which the ALV is bound..If not create it first and set the default value for this readonly as abap_true...ie X.
    2.  Got the contents in the internal table.
    bind the table to the node..
    3.Instantiate the ALV.
    4. Now get teh column refrences of this ALV using the cl_salv_wd_config_table..and for columns
    use the cell editor type as cl_salv_wd_uie_input_field...
    loop through the column references and for all refrences create an object of type Input field and inside this class
    use the method set_read_only_field_name ( 'READ_ONLY' ).
    For the table settings if_salv_wd_table_settings of cl_salv_wd-config_table.. set the read only mode as abap_false..
    5 create the custom button in the ALV using the cl_salv_wd_fe_button..
    6 In this go for the events ON_FUCNTION and inside this method..do the coding
    7 .Initially the table will  be set to non editable..
    In the button handler....
    Get the refernece of this node to which the ALV is bound.....
    lr_node = wd_context->get_child_node( 'VBAK' ).  "dynamic node name
    lv_index  = lr_node->get_lead_selection_index ( ).
    loop at it_table into ls_table.
    if sy-tabix eq lv_index.
    ls_table-read_only = abap_false.  "editable
    else.
    ls_table-read_only = abap_true. "non editable
    endif.
    modify table
    endloop.
    lr_node->bind_table( lt_table ).
    If you have any doutbs just refer the previous thread posted on the same..
    You can follow the above steps to acheive thjs..
    Regards,
    Lekha.
    Edited by: Lekha on Dec 17, 2009 6:10 PM

  • How to make a filed mandatory of an editable ALV

    Hi Guru,
    Pls tell me how to make a filed mandatory of an editable ALV so that while a new records is inserted the mandatory fields are filled.

    hi,
    You can make fields as mandatory fields using data changed event.
    validate the entered or blank entries of a column in data changed event and call method 'add_protocol_entry' to raise errors.
    Check the program : BCALV_EDIT_03 & BCALV_EDIT_04for more details.
    Refer to this link....
    about field in alv
    obligatory field editable in ALV

  • How to Edit in ALV?

    Hi Experts,
    I am working on a BAPI for creating Requsition where i am taking one ref PR and then modifying required details and then creating a new PR.
    Everything is working fine but before creating the new PR i want to display that data in the form of alv grid and where i can edit the values and save then a new PR will be created as per modification on alv.
    check the sample code wht i hv done....
    SELECT * FROM EBAN INTO CORRESPONDING FIELDS OF TABLE IT_EBAN WHERE
    BANFN EQ S_BANFN.
    LOOP AT IT_EBAN.
    ENDLOOP.
    LOOP AT IT_EBAN.
    T_REQUISITION_ITEMS-DOC_TYPE = 'ZSD'.
    MOVE IT_EBAN-BNFPO TO T_REQUISITION_ITEMS-PREQ_ITEM.
    MOVE IT_EBAN-ERNAM TO T_REQUISITION_ITEMS-CREATED_BY.
    MOVE IT_EBAN-AFNAM TO T_REQUISITION_ITEMS-PREQ_NAME.
    MOVE IT_EBAN-BADAT TO T_REQUISITION_ITEMS-PREQ_DATE.
    MOVE IT_EBAN-TXZ01 TO T_REQUISITION_ITEMS-SHORT_TEXT.
    MOVE IT_EBAN-MATNR TO T_REQUISITION_ITEMS-MATERIAL.
    MOVE IT_EBAN-EMATN TO T_REQUISITION_ITEMS-PUR_MAT.
    T_REQUISITION_ITEMS-PLANT = '4000'.
    T_REQUISITION_ITEMS-STORE_LOC = 'YRD1'.
    T_REQUISITION_ITEMS-PUR_GROUP = 'JSD'.
    MOVE IT_EBAN-MATKL TO T_REQUISITION_ITEMS-MAT_GRP.
    MOVE IT_EBAN-MENGE TO T_REQUISITION_ITEMS-QUANTITY.
    MOVE IT_EBAN-MEINS TO T_REQUISITION_ITEMS-UNIT.
    T_REQUISITION_ITEMS-DELIV_DATE = '20080618'.
    APPEND T_REQUISITION_ITEMS.
    CALL FUNCTION 'BAPI_REQUISITION_CREATE'
    EXPORTING
    SKIP_ITEMS_WITH_ERROR =
    IMPORTING
    NUMBER = E_NUMBER
    TABLES
    REQUISITION_ITEMS = T_REQUISITION_ITEMS
    *REQUISITION_ACCOUNT_ASSIGNMENT = T_REQ_ACCOUNT_ASSIGNMENT
    REQUISITION_ITEM_TEXT =
    REQUISITION_LIMITS =
    REQUISITION_CONTRACT_LIMITS =
    REQUISITION_SERVICES =
    REQUISITION_SRV_ACCASS_VALUES =
    RETURN = T_RETURN
    REQUISITION_SERVICES_TEXT =
    EXTENSIONIN =
    REQUISITION_ADDRDELIVERY =
    ENDLOOP.
    IF NOT E_NUMBER IS INITIAL .
    WRITE:/ 'REQ NO:' , E_NUMBER , 'CREATED'.
    ELSE.
    LOOP AT T_RETURN.
    WRITE T_RETURN-MESSAGE.
    ENDLOOP.
    ENDIF.
    what i want is before calling BAPI_REQUISITION_CREATE  i need to display it_eban as alv and then where i can edit the values and save and that values will move to T_REQUISITION_ITEMS table. no need of hard cording Plant and purch. grop and storage location details. I know how to display the ALV grid just tell me how to edit in ALV and when i cllick save it shold move to BAPI_REQUISITION_CREATE.
    its an urgent...
    <b>points will be rewarded for useful answers</b>
    Regards,
    sunil kairam.

    Check this editable alv report...
    REPORT zjay_edit_alv.
    * 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 DEFAULT 'MARA',
    lines(5) TYPE n DEFAULT 7.
    * 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 'ZSTANDARD'. "copy it from SALV func group 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 = sy-repid
    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

  • How to create editable ALV grid/list

    Hi,
    I want to create editable ALV grid/list so that user can modify the data in the ALV.
    And when user presses save button data will get saved in Z table.
    I dont know how to create editable ALV so could anybody please help me regarding this?
    Thanks & regards,
    Sameer Dhuke

    HI
    check the demo programs BCALV_FULLSCREEN_GRID_EDIT
    BCALV_GRID_EDIT
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDITABLE
    REUSE_ALV_GRID EDITABLE
    ALV Grid editable fields
    Just to make things a bit easy
    In the layout,there is a property called edit, make it 'X' for the particular field whichever you want to make editable.
    Hope this helps,
    Suruchi
    Message was edited by:
            Suruchi Mahajan

Maybe you are looking for

  • "ReferenceError: "myIpAddr"  is not defined, when call JavaScript from java

    Hi developers, My java application was trying to issue a http request via proxy auto-config. So, I did below jobs 1. Read URL of *.pac from registry 2. Call FindProxyForURL from java, the code is like below                ScriptEngineManager factory

  • Reading wmf files

    Just switched computers and viewing WMF files is really spotty. I could read them before but half of them now just have a default icon. What's wrong with this picture. Yet another bug to add to the pile?

  • I Want To Change My Payment Due Date

    Change Payment DateFrom: szygw9To: ATTCustomerCareSent: ‎07-08-2015 7:15:33 AMRead: Not Yet ReadI want to change my payment DUE date to the first week of the month, preferrably to the 1st day of every month! Because AT&T changed my payment DUE date t

  • Lost my videos on iphone

    I sync my iphone with my computer and lost my playlists, videos and many more ... how can i get it back,

  • Hide "Hold" button in PR

    Hi, Is it possible to hide the "Hold" button in a Purchase Requisition? Thanks, Luis G.