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

Similar Messages

  • Regarding editable ALV in OOPS

    Hi,
    I have an editable alv.
    I have requirement like i need to validate the data which is edited on pressing "ENTER" or "SAVE"
    for this iam using the event DATA_CHANGED
    and define a local class lcl_event handler and also set handler for it.
    But iam able to validate using this event only if the data is changed inspite of SAVE or ENTER its getting triggered.
    But if the data is not changed its not triggering please suggest me an event which triggers on clicking SAVE in menu bar.
    Thanks,
    Phani.

    Hello
    If the event is not triggered but you need to do the validation then just call the event handler method yourself:
    " PAI: USER_COMMAND module
      CASE gd_okcode.
       WHEN 'SAVE'.
         " Now call your event handler method directly
         go_grid->handle_data_changed( )
           EXPORTING
      WHEN OTHERS.
      ENDCASE.
    Within your event handler method you can easily distinguish between whether the method is triggered by the control framework or by your direct call:
    METHOD handle_data_changed.
    " instance exists -> triggered by framework
      IF ( er_data_changed IS BOUND ).
    " direct call
      ELSE.
      ENDIF.
    ENDMETHOD.
    Regards
      Uwe

  • Regarding editable alv  save button

    Hi Friends,
                      I have an ALV report in which one of the Column is in editable mode.
                       i want to edit that column field with new value and press save .
                       Friends , i want to know what should i write to get things done.
    regards,
    Rajesh

    Hi Friends,
                      I have an ALV report in which one of the Column is in editable mode.
                       i want to edit that column field with new value and press save .
                       Friends , i want to know what should i write to get things done.
    regards,
    Rajesh

  • Doubt regarding editable ALV report using Classes

    I need to create an ALV report and make few fields editable
    and i need to update the changes  to the corresponding database tables
    for that please suggest me some idea or provide me sample code for that
    urgent

    Hi ramesh,
    Please check this example program. I think it will help for some extent.
    [code]&----
    *& Report  ZSUMA_INTERACTIVEREPORT                                     *
    report zsuma_interactivereport.
    tables: vbak.
    data :gr_alvgrid type ref to cl_gui_alv_grid,
          gr_cc_name type scrfname value 'CC_ALV',
          gr_ccontainer type ref to cl_gui_custom_container,
          gr_fieldcat type lvc_t_fcat,
          gr_layout type lvc_s_layo,
          gr_sort type lvc_t_sort,
          gr_get_cell type lvc_t_cell,
          gr_set_cell type lvc_t_cell,
          gr_hyper type lvc_t_hype,
          gr_drop_down type lvc_t_drop,
          is_variant type disvariant,
          line_number type lvc_s_roid-row_id,
          line(5) type c ,
          cell_value type lvc_value.
    data: begin of it_vbak occurs 0,
          vbeln type vbak-vbeln,
          erdat like vbak-erdat,
          erzet like vbak-erzet,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
    *Below field is useful for making the entire row with different colors.
    it must be a char of 4.and layout-info_fname should populate with
    *this field.
          rowcolor(4) type c,
    *Below field is useful for making the INDIVIDUAL CELL with different
    *colors.for this we have to include structure of type lvc_t_scol.
    *layout-ctab_fname should be populate with this field.
          cellcolor type lvc_t_scol,
    *below field is added for for providing the hyperlinks to perticular
    *field. at the time of field catalog , it_fcatalog-web_field should be
    *populate with this field.
          vbeln_hyper type int4,
    *For displaying one cell as button.we have to declare one styles
    *internal table .it has to be populate.at layout structure this table
    *name has to be populate at layout-stylename.
         cellstyle type lvc_t_styl,
          end of it_vbak.
    *&   SELECTION SCREEN
    selection-screen begin of block b1 with frame title text-001.
    select-options s_vbeln for vbak-vbeln.
    selection-screen end of block b1.
    start-of-selection.
    select vbeln
           erdat
           erzet
           netwr
           waerk
           from vbak
           into corresponding fields of table it_vbak
           where vbeln in s_vbeln.
    data: wa_cellcolor type lvc_s_scol,
          wa_style type lvc_s_styl.
    loop at it_vbak.
    FOR ROW COLORING
    if sy-tabix = 1.
    it_vbak-rowcolor = 'C511'.
    FOR PUTTING THE HYPERLINKS ON VBELN FIELD
    it_vbak-vbeln_hyper = '1'.
    modify it_vbak.
    endif.
    FOR CELL COLORING
    if sy-tabix = 2.
    wa_cellcolor-fname = 'ERZET'.
    wa_cellcolor-color-col = '6'.
    wa_cellcolor-color-int = '1'.
    wa_cellcolor-color-inv = '1'.
    append wa_cellcolor to it_vbak-cellcolor.
    modify it_vbak index 2.
    endif.
    FOR DISPLAYING THE CELL AS A BUTTON
    clear it_vbak-cellstyle.
    at last.
    read table it_vbak index sy-tabix.
    wa_style-fieldname = 'NETWR'.
    wa_style-style = cl_gui_alv_grid=>mc_style_button.
    append wa_style to it_vbak-cellstyle .
    modify it_vbak .
    endat.
    endloop.
    if not it_vbak[] is initial.
      call screen 100.
    endif.
    *CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler definition.
    public section.
    methods:handle_hotspot_click
                  for event hotspot_click of cl_gui_alv_grid
                   importing e_row_id e_column_id es_row_no.
    endclass.
    *CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler implementation.
    method handle_hotspot_click.
    perform handle_hotspot_click using e_row_id e_column_id es_row_no.
    endmethod.
    endclass.
    *&      Form  BUILDING_FIELDCATALOG
          text
         <--P_GR_FIELDCAT  text
    form building_fieldcatalog  changing p_gr_fieldcat type lvc_t_fcat.
    data s_fieldcat type lvc_s_fcat.
    s_fieldcat-fieldname = 'VBELN'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '1'.
    s_fieldcat-coltext   = 'DOCCUMENT NO.'.
    s_fieldcat-key   = ' '.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-web_field = 'VBELN_HYPER'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERDAT'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '2'.
    s_fieldcat-coltext   = 'REC CREATE DATE.'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-hotspot = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERZET'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '3'.
    s_fieldcat-coltext   = 'TIME ENTRY.'.
    *S_FIELDCAT-EMPHASIZE = 'C311'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'NETWR'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '4'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-coltext   = 'NET WEIGHT.'.
    s_fieldcat-do_sum   = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'WAERK'.
    s_fieldcat-outputlen = '5'.
    s_fieldcat-col_pos   = '5'.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-coltext   = 'CURR.'.
    FOR PUTTING THE DROP DOWN BOX.
    s_fieldcat-drdn_hndl = '1'.
    s_fieldcat-edit = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    endform.                    " BUILDING_FIELDCATALOG
    *&      Form  CREATE_CCONTAINER_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_ccontainer_instance .
    create object gr_ccontainer
    exporting
    container_name              = gr_cc_name
    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.
    endform.                    " CREATE_CCONTAINER_INSTANCE
    *&      Form  CREATE_ALVGRID_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_alvgrid_instance .
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
      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.
    endform.                    " CREATE_ALVGRID_INSTANCE
    *&      Form  DISPLAYING_ALVGRID
          text
    -->  p1        text
    <--  p2        text
    form displaying_alvgrid .
    call method gr_alvgrid->set_table_for_first_display
      exporting
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
        is_variant                    = is_variant
        i_save                        = 'A'
       I_DEFAULT                     = 'X'
        is_layout                     = gr_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
        it_hyperlink                  = gr_hyper
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = it_vbak[]
        it_fieldcatalog               = gr_fieldcat
       it_sort                       = gr_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.
    *CALL METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
    IMPORTING
       ES_LAYOUT = GR_LAYOUT
    *GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
    *CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
    EXPORTING
       IS_LAYOUT = GR_LAYOUT
    endform.                    " DISPLAYING_ALVGRID
    *&      Form  REFRESH_DISPLAY_TABLE
          text
    -->  p1        text
    <--  p2        text
    form refresh_display_table .
    call method gr_alvgrid->refresh_table_display
    EXPORTING
       IS_STABLE      =
       I_SOFT_REFRESH =
      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.
    endform.                    " REFRESH_DISPLAY_TABLE
    *&      Form  SETTING_LAYOUT
          text
         <--P_GR_LAYOUT  text
    form setting_layout  changing p_gr_layout type lvc_s_layo.
    p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
    p_gr_layout-zebra = 'X'.
    p_gr_layout-no_toolbar = ''.
    p_gr_layout-sel_mode = 'D'.
    p_gr_layout-info_fname = 'ROWCOLOR'.
    p_gr_layout-ctab_fname = 'CELLCOLOR'.
    p_gr_layout-stylefname = 'CELLSTYLE'.
    endform.                    " SETTING_LAYOUT
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    set pf-status 'MENU'.
    if gr_alvgrid is initial.
    *CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
    *TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
    perform create_ccontainer_instance.
    perform create_alvgrid_instance.
    *VARIANT POPULATION.
    perform setting_variants changing is_variant.
    *BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
    *TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
    perform setting_hyperlinks_field changing gr_hyper.
    *TO MAKE THE COLOUMN AS DROP DOWN.
    perform setting_dropdown_column changing gr_drop_down.
    perform building_fieldcatalog changing gr_fieldcat.
    perform setting_layout changing gr_layout.
    perform setting_sorting changing gr_sort.
    perform setting_cells changing gr_set_cell.
    perform displaying_alvgrid.
    *PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
                                                 FOR ME AND I HAVE DOUBT .
    perform creating_event_object.
    *PERFORM REFRESH_DISPLAY_TABLE.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
      when 'BACK'.
      leave to screen 000.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  SETTING_SORTING
          text
         <--P_GR_SORT  text
    form setting_sorting  changing p_gr_sort type lvc_t_sort.
    data: lr_sort type lvc_s_sort.
    lr_sort-spos = '1'.
    lr_sort-fieldname = 'VBELN'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    lr_sort-spos = '2'.
    lr_sort-fieldname = 'ERDAT'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    endform.                    " SETTING_SORTING
    *&      Form  GETTING_CELL_DETAILS
          text
         <--P_GR_GET_CELL  text
    form getting_cell_details  changing p_gr_get_cell.
    call method gr_alvgrid->get_selected_cells
      importing
        et_cell = p_gr_get_cell
    *CELL_VALUE = P_GR_GET_CELL-VALUE.
    endform.                    " GETTING_CELL_DETAILS
    *&      Form  SETTING_CELLS
          text
         <--P_GR_SET_CELL  text
    form setting_cells  changing p_gr_set_cell type lvc_t_cell.
    data:s_gr_set_cell type lvc_s_cell.
    s_gr_set_cell-col_id-fieldname = 'NETWR'.
    s_gr_set_cell-row_id-index = '3'.
    append s_gr_set_cell to p_gr_set_cell.
    call method gr_alvgrid->set_selected_cells
      exporting
        it_cells = p_gr_set_cell.
    endform.                    " SETTING_CELLS
    *&      Form  SETTING_HYPERLINKS_FIELD
          text
         <--P_GR_HYPER  text
    form setting_hyperlinks_field  changing p_gr_hyper type lvc_t_hype.
    data: is_hype type lvc_s_hype.
    is_hype-handle = '1'.
    is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
    append is_hype to p_gr_hyper.
    is_hype-handle = '2'.
    is_hype-href = 'HTTP://SDN.SAP.COM'.
    append is_hype to p_gr_hyper.
    endform.                    " SETTING_HYPERLINKS_FIELD
    *&      Form  SETTING_DROPDOWN_COLUMN
          text
         <--P_GR_DROP_DOWN  text
    form setting_dropdown_column  changing p_gr_drop_down type lvc_t_drop.
    data: wa_drop type lvc_s_drop.
    wa_drop-handle = '1'.
    wa_drop-value = '$'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'Rs'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'CUR'.
    append wa_drop to p_gr_drop_down.
    call method gr_alvgrid->set_drop_down_table
      exporting
        it_drop_down       = p_gr_drop_down
       IT_DROP_DOWN_ALIAS =
    endform.                    " SETTING_DROPDOWN_COLUMN
    *&      Form  SETTING_VARIANTS
          text
         <--P_IS_VARIANT  text
    form setting_variants  changing p_is_variant type disvariant.
    p_is_variant-report = sy-repid.
    endform.                    " SETTING_VARIANTS
    *&      Form  HANDLE_HOTSPOT_CLICK
          text
         -->P_E_ROW  text
         -->P_E_COLUMN  text
         -->P_E_ROW_NO  text
    form handle_hotspot_click  using    p_e_row_id type lvc_s_row
                                        p_e_column_id type lvc_s_col
                                        p_es_row_no type lvc_s_roid.
    read table it_vbak index p_es_row_no-row_id.
    if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
    line = p_es_row_no-row_id.
    line_number = p_es_row_no-row_id.
    leave to screen 200.
    endif.
    endform.                    " HANDLE_HOTSPOT_CLICK
    *&      Form  CREATING_EVENT_OBJECT
          text
    -->  p1        text
    <--  p2        text
    form creating_event_object .
    data event_handle type ref to gr_event_handler.
    create object event_handle.
    set handler event_handle->handle_hotspot_click for gr_alvgrid.
    endform.                    " CREATING_EVENT_OBJECT
    *&      Module  STATUS_0200  OUTPUT
          text
    module status_0200 output.
      set pf-status 'BB'.
    SET TITLEBAR 'xxx'.
    *LINE = LINE_NUMBER.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module user_command_0200 input.
    if sy-ucomm = 'BACK'.
    leave to screen 100.
    endif.
    endmodule.                 " USER_COMMAND_0200  INPUT[/code]
    Reward points if helpful
    Thanks,
    Suma.

  • 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

  • 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

  • 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

  • Row wise total in editable ALV

    hello all,
                I am workin on editable alv, the user need to enter the values in the editable fields and in the last column(non-editable) i need to populate the total row wise,as soon as user enters a value and goes to next editable cell or on entering a vale and press enter.how to accomplish this task...
    with regards,
    sandeep akella.
    Edited by: sandeep akella on Aug 20, 2009 1:58 PM

    You need to Implement the OnCellAction event.follow these steps;
    1. Goto WDDOMODIFYVIEW and place the following code
    IF first_time IS INITIAL.
        DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
        lo_cmp_usage =   wd_this->wd_cpuse_usg_alv( ).
        IF lo_cmp_usage->has_active_component( ) IS INITIAL.
          lo_cmp_usage->create_component( ).
        ENDIF.
        DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
        lo_interfacecontroller =   wd_this->wd_cpifc_usg_alv( ).
        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_cell_action_event_enabled
         EXPORTING
            value = abap_true.
      ENDIF.
    2. Implement the onCellAction event as follows;
        Goto Methods tab, create a new method. Method Type- Event Handler , Event - ON_CELL_ACTION
    3. Now in this  method retrive the contents of the row and calculate the value as follows.
    DATA: l_element TYPE REF TO if_wd_context_element.
      DATA:ls_stru TYPE wd_this->element_cn_alv.
      DATA: l_node TYPE REF TO if_wd_context_node.
      l_node  = wd_context->get_child_node( 'CN_ALV' ).
      l_element = l_node->get_element(  r_param->index ).
      l_element->get_static_attributes( IMPORTING static_attributes = ls_stru ).
      ls_stru-last_col = ls_stru-col1+ls_stru-col2....+ ls_stru-col5. " add all the cells data
      l_element->set_static_attributes( exporting static_attributes = ls_stru ).

  • Check_changed_data method on editable ALV Grid ( class cl_gui_alv_grid)

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

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

  • My changes edited on editable ALV report are not transferring back to itab?

    Hello
    I was developed a heirarchila editable ALV by using FM 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'. The user will do some changes in the ITEMs (Z_VBAP_TABLE) on this heirarchila ALV report and presses the SAVE button.
    In my program am handling this SAVE command and even my break point is also triggering at SAVE, but my ITAB is not having the CHANGED/new data!! still it has the old data in it! How to capture the user changes done on the report? those changes are not tranferring back to my itab/prog! because, ineed to update Z_VBAP_TABLE with those changes
    Thank you

    Hi Raju,
    it is possible . But i know about your code.
       WHEN 'SAVE'(003).
        Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = viewname
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
          IF NOT grid1 IS INITIAL .
            CALL METHOD grid1->check_changed_data .
          ENDIF .
          SORT i_mod BY row.
          DELETE ADJACENT DUPLICATES  FROM i_mod COMPARING row.
          lh_norec = LINES( i_mod ).
          lh_total = lh_norec.
          SHIFT lh_total LEFT DELETING LEADING space.
    Standard Table Update
          IF i_mod[] IS NOT INITIAL.
            LOOP AT i_mod INTO lwa_mod.
              READ TABLE <i_itab> INTO <wa_tab> INDEX lwa_mod-row.
              IF sy-subrc = 0 .
                IF lh_flag NE 'X'.
                  MODIFY (viewname) FROM <wa_tab>.
                ELSE.
                  INSERT (viewname) FROM <wa_tab>.
                  IF sy-subrc NE 0.
                    MESSAGE 'DATA NOT SAVED' type 'I'.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDLOOP.
            CONCATENATE lh_total '  ' text-s01 INTO lh_succ SEPARATED BY space.
            MESSAGE 'Data Saved' TYPE 'I'.
    This i did a long back. Check your code . I created an alv that will display data from my table . In this the user can click in any line item and he can change any value and press save  that will save the value .
    Regards,
    Madhu.

  • Urgent : Problem with Editable  ALV Grid  for Quantity and Currency Fields

    Hi All,
    I am using Editable ALV Grid display and have quantity and value as editable fields in the display.
    When user changes these values these values are not changing properly .
    For the quantity field the domain is MENG13 with 3 deciamal places and here  if we enter 500 it takes it as 0.500   .
    The same problem is for the currency field. Here the Domain is WERT7 with 3 decimal places.
    Here also it takes last 2 digits after decimal places by default.
    Please advice how to get proper values in this case from ALV editable fields.
    Thanks and Regards
    Harshad
    Edited by: Harshad Rahirkar on Dec 25, 2007 7:39 AM

    for all the currency field , it will display like that only.
    u have to manipulate uin program before displaying.
    if they are giving 500, in program multiply with 100 and move it to table.
    when u are getting from table, divinde and display.
    this is what I am doing.
    Reward if helpfull.

  • 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

  • Editable ALV & Foreign Key Check

    I am working on an Editable ALV. Here if I try to enter some value into a field which doesnt exist in the corresponding Check table of the field, ALV throws me an error. This scenario is working fine.
    But in some scenarios I populate the ALV table from a Z table (Z table has the same strucutre as the ALV table) and then show this to the user as an editable ALV but in this scenarios if some erroneous values exist in my Z table for a particular fieId I am not getting the Foreign Key check I mentioned earlier.  Here I was hoping to get error message after SET_TABLE_FOR_FIRST_DISPLAY !
    I am using CL_GUI_ALV_GRID, has anyone found a workaround for this
    Antony

    Hi Antony,
    you can INHERIT a class from CL_GUI_ALV_GRID and then redefine SET_TABLE_FOR_FIRST_DISPLAY adding the raising EVENT data_changed for all cells.
    Regards,
    Clemens

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

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

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

  • 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