2007 Sep 03 5:04 PM
Hi,
I am triyng to make a program for maintain a Z table using ALV... the program i was used as a template is BCALV_EDIT_04 but this program only insert and delete records but not maintain existing records.. please if any have a code or site where i can download it...
Thanks In Advance
Juan
2007 Sep 03 5:11 PM
Hi,
U need to manage the event DATA_CHANGED: in the report BCALV_EDIT_04
An example of handler class:
CLASS lcl_alv_handler_1100 DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
ENDCLASS.
a®
2007 Sep 03 5:11 PM
Hi,
U need to manage the event DATA_CHANGED: in the report BCALV_EDIT_04
An example of handler class:
CLASS lcl_alv_handler_1100 DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
ENDCLASS.
a®
2007 Sep 03 5:14 PM
Thanks a®s...
I figure that... but could u be more specific??
Thanks In Advance
Juan
2007 Sep 03 5:21 PM
Hi,
In OO case:
after creating your ALV, you have first to register to teh 'ENTER' event: everytime the user press enter, the event will be triggered:
CALL METHOD gr_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
Then you have to create the event handler:
CREATE OBJECT gr_alv_handler_1100.
SET HANDLER gr_alv_handler_1100->handle_data_changed FOR gr_alv.
An example of handler class:
CLASS lcl_alv_handler_1100 DEFINITION. "#EC CLAS_FINAL
PUBLIC SECTION.
METHODS:
handle_data_changed "#EC CALLED
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
ENDCLASS. "LCL_ALV_HANDLER_1100
a®
2007 Sep 03 5:57 PM
Thanks again its more clear now... but i am stucked in the:
LOOP AT pr_data_changed->
.
.
.
.
endloop
Thanks In Advance
Juan
2007 Sep 03 6:11 PM
Hi,
Simply call this method . This will automatically update your changes in the GRID to your output table
call method g_grid->check_changed_data
importing
e_valid = v_valid.
a®
2007 Sep 03 6:28 PM
Hi,
Ok but i need to execute a modify comand to update my z table...
I dont know in which internal is the data changed,... gs_outtab? if so i need to read this table to know which records was modified
Thanks In advance
Juan
2007 Sep 03 6:37 PM
Hi,
If you check the program BCALV_EDIT_04
call method g_grid->set_table_for_first_display
exporting it_toolbar_excluding = lt_exclude
is_layout = gs_layout
changing it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab[]. "<<<< Output table
Once user press SAVE button In the PAI
*----------------------------------------------------------------------*
* Module Pai INPUT *
*----------------------------------------------------------------------*
* PAI module *
*----------------------------------------------------------------------*
module pai input.
save_ok = ok_code.
clear ok_code.
case save_ok.
when 'EXIT'.
perform f_exit_program.
when 'CANC'.
perform f_exit_program.
when 'BACK'.
perform f_exit_program.
when 'SAVE'.
perform f_save_data. "<<< You need to write a perform
when 'EVEW'.
perform f_set_fcode.
perform f_save_data .
when 'VADD'.
perform f_f4_help_fieldname.
endcase.
endmodule. " Pai INPUT
*&---------------------------------------------------------------------*
* Form f_save_data *
*&---------------------------------------------------------------------*
* After save *
*----------------------------------------------------------------------*
form f_save_data .
data : p_index like sy-index.
refresh : i_message, i_message1.
call method g_grid->check_changed_data
importing
e_valid = v_valid.
if not v_valid is initial.
if save_ok eq 'SAVE'.
loop at pt_outtab.
"<<<<< write your statement to update your ZTABLE
endloop,
endif.
endif.
endform.
a®
2007 Sep 03 6:48 PM
Thanks a lot...
Could u send me please the complete code of your example to jcdiezdemedina@gmail.com... it seems that the version are differentt.. we are on 4.6c
Thanks In Advance
Juan
2007 Sep 03 6:55 PM
Hi,
form save_data.
data: l_valid type c.
* §7.Check if any errors exist in protocol by using method
* CHECK_CHANGED_DATA of your ALV Grid instance.
* The method CHECK_CHANGED_DATA checks all new cells syntactically,
* raises event DATA_CHANGED and looks then for any entries
* in the error protocol. If any exist the parameter e_valid
* is initial ('X' in the other case).
*
call method g_grid->check_changed_data
importing e_valid = l_valid.
if l_valid is initial.
call function 'POPUP_TO_INFORM'
exporting
titel = text-i06
txt1 = text-i07
txt2 = text-i08
txt3 = text-i09.
else.
perform update_database. "<<< Check this form you need to write your update statements here
message s000(0k) with text-s01.
endif.
endform.
a®
2007 Sep 03 7:02 PM
Hi,
Ok but i dont think that the best way was to update my z table from outab.. i only need to update the modified records...
* 1.Delete Lines:
* call method g_verifier->get_deleted_rows
* importing deleted_rows = lt_del_rows.
*
* delete sflight from table lt_del_rows.
*
** 2.Insert Lines:
* call method g_verifier->get_inserted_rows
* importing inserted_rows = lt_ins_keys.
*
* loop at lt_ins_keys into l_ins_key.
* read table gt_outtab into ls_outtab
* with key carrid = l_ins_key-carrid
* connid = l_ins_key-connid
* fldate = l_ins_key-fldate.
* if sy-subrc eq 0.
* move-corresponding ls_outtab to ls_sflight.
* append ls_sflight to lt_instab.
* endif.
* endloop.
*
* insert sflight from table lt_instab.
*
the point 3 modified records is missing jajaja this the code i need...
Thanks In Advance
Juan