2009 Jan 02 8:34 AM
hi all,
can anyone find me a solution for alv edit and save...the issue is that i will be editing and just clicking on save button withot any row selction and the data changed should be updated in database.
sunil.
2009 Jan 02 8:37 AM
you would need to use Data change events of ALV to achive this functionality. check BALCV* alv programs for thier functionality in SE38,.
hi all,
can anyone find me a solution for alv edit and save...the issue is that i will be editing and just clicking on save button withot any row selction and the data changed should be updated in database.
sunil.
2009 Jan 02 8:37 AM
you would need to use Data change events of ALV to achive this functionality. check BALCV* alv programs for thier functionality in SE38,.
2009 Jan 02 8:39 AM
Hi
You need to include a edit field in the fieldcatalog to make the ALV editable .
fieldcat-edit = 'X'.
after changing the values in ALV , press enter .
and the internal table used for ALV will have the changed values .
reg
Ramya
Edited by: Ramya S on Jan 2, 2009 9:40 AM
2009 Jan 05 5:24 AM
can i do without pressing enter botton? i.e just edit and press save button
2009 Jan 02 8:40 AM
Try using the structure LVC_S_STYLE.
Declare a field of type LVC_S_STYLE in ur internal table,
In the class CL_GUI_ALV_GRID, you have the methods like MC_STYLE_ENABLED and MC_STYLE_DISABLED.
sample code:
ls_stylerow type LVC_S_STYLE.
LOOP AT it_itab INTO wa_itab.
IF wa_itab-field1(this will be the field by which u will validate) = 'X'.
ls_stylerow-fieldname = 'FIELD2' . "Field which you want to grey
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled. "set field to disabled
APPEND ls_stylerow TO wa_itab-field_style.
MODIFY it_itab FROM wa_itab.
ENDIF.
ENDLOOP.
and after this write the logic to update the table on saving.
OR jus check this:
https://www.sdn.sap.com/irj/scn/profile?editmode=true&userid=3759676
Edited by: Kalyan Chakravarthi on Jan 2, 2009 9:42 AM
2009 Jan 02 8:43 AM
Check these sdtandard alv Programs: BCALV_TEST_GRID
BCALV_TEST_GRID_DRAG_DROP
BCALV_TEST_GRID_EDIT
BCALV_TEST_GRID_EDITABLE
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDIT_02
BCALV_TEST_GRID_EDIT_04_FORMS
BCALV_TEST_GRID_EVENTS
BCALV_TEST_GRID_F4_HELP
BCALV_TEST_GRID_FIELDS
BCALV_TEST_GRID_INDEX
BCALV_TEST_GRID_LAYOUT
BCALV_TEST_GRID_ONPOPUP
BCALV_TEST_GRID_PERFORMANCE
BCALV_TEST_GRID_PRINT
BCALV_TEST_GRID_REPREP
BCALV_TEST_GRID_REPREP_1
BCALV_TEST_GRID_TOOLBAR
2009 Jan 02 8:44 AM
2009 Jan 02 8:55 AM
HI,
To achive ur target u need to use few methods.
CLASS-METHODS : data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
In this method it gets the what ever u have changed in the alv screen to the previous version.
keep a loop for the er_data_changed as given below.
DATA : changed_data TYPE lvc_s_modi.
DATA : lv_change TYPE c,
lv_werks TYPE t001w-werks,
gv_error_in_data TYPE c.
LOOP AT er_data_changed->mt_mod_cells INTO changed_data.
endloop.
Write a modify statement inside the loop to update the database table as well as the internal table.
The whole code should in save button u have placed on the alv screen.
Regards,
Naresh
2009 Jan 02 9:06 AM
hi sunil,
check this site
http://saptechnical.com/Tutorials/ALV/Edit/demo.htm
hope it helps you.
thanks
Sachin
2009 Jan 02 9:21 AM
Hi Bhaskar,
To make fields editable in ALV, while creating the field catalog for ALV, use:-
wa_field-edit = 'X'. " to make a field editable
To check the data changed in ALV, use code:-
*----------------------------------------------------------------------*
ALV GRID Display
*----------------------------------------------------------------------*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy_repid " report id
i_callback_user_command = 'USER_COMMAND' " to handle user command
it_fieldcat = it_field " for field catalog
it_sort = it_sort " for sort records info
TABLES
t_outtab = it_final "internal table with records
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.
*----------------------------------------------------------------------*
Sub-routine USER_COMMAND
*----------------------------------------------------------------------*
FORM user_command USING v_okcode LIKE sy-ucomm selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
v_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE v_okcode.
* when the function code is EXECUTE then process the selected records
WHEN 'EXECUTE'.
*to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
* refresh the ALV Grid output from internal table
selfield-refresh = c_check.
ENDCASE.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
2009 Jan 02 9:33 AM
Hi,
If edited value wants to update in Database table You should use event as 'USER_COMMAD'. Once you click on SAVE there you have to call BDC.
FROM TABLE IT_OUT_TAB INTO WA_OUT_TAB INDEX WA_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
SET PARAMETER ID: 'BLN' field WA_OUT_TAB-BELNR.
CALL TRANSACTION 'FB03' .
EDNIF.
ENDFORM.
Regards
Md.MahaboobKhan
2009 Jan 05 6:00 AM
Hi,
you want to mention this ls_fieldcatalog-edit = 'X' in the field catalog and use i_save = 'X' in the FM
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = gs_layout
it_fieldcat = i_fieldcat[]
it_events = i_event[]
it_sort = i_sort[]
i_save = 'X'
TABLES
t_outtab = i_final_1
EXCEPTIONS
program_error = 1
OTHERS = 2.
Regards,
Joan
2009 Jan 05 6:08 AM