on 10-24-2008 10:32 AM
Hi there,
I have a WDP with an ALV table, with activated delete row and save buttons. I have also activated the field editors. After the user does some changes, I want to write the current table content back to the database.
I have implemented a method to save the changes, just as in WDT_TABLE sample. For reasons of efficiency, I would write only the updated/inserted/deleted items back to the database. However, the method get_context_change_log() gives me headaches. It returns all the updated and inserted rows but not the deleted rows; I have debugged the table. function and fields long enough 😠
Now theoretically I could write the whole table back to database, but with several thousands items in the table, this would be absolute unacceptable (the sysadmin would kill me, heh). I could save the old contents in an attribute/context table and compare it to the current table but this also would be resource-wasting.
Is there any way to get the deleted rows as well as the others? My last resort is to get rid of the standard delete button, put a custom button there, and implement an event handler to log all deletion events. Would this work?
All answers will be rewarded.
TIA,
Cüneyt
Hi,
As you are tracking changes in ALV data you must define a event handler for ALV evenr ONDATA_CHECK.
On defining an event handler you will be getting a structure called t_param.
It contains an element called t_deleted rows.
See this code to have an idea.
method ONDATACHECK .
DATA: x_delete_row LIKE LINE OF r_param->t_deleted_rows.
" i_addr_factr TYPE STANDARD TABLE OF ycot_addr_factr,
" x_addr_factr LIKE LINE OF i_addr_factr.
TYPES t_proj_constr TYPE ycot_proj_constr.
FIELD-SYMBOLS: <fs_row> TYPE t_proj_constr.
IF wd_comp_controller->ya_optyp = 'DELETE'.
LOOP AT r_param->t_deleted_rows INTO x_delete_row.
"x_addr_factr ?= x_delete_row-r_value.
ASSIGN x_delete_row-r_value->* TO <fs_row>.
DELETE FROM ycot_proj_constr WHERE plant = <fs_row>-plant
AND yr_nbr = <fs_row>-yr_nbr
AND period = <fs_row>-period
AND billback_pr_fmly = <fs_row>-billback_pr_fmly
AND prd_nm = <fs_row>-prd_nm.
ENDLOOP.
.
I hope it helps.
Regards,
Sumit Oberoi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cüneyt,
I am dealing with the same problem to log deleted, changed or inserted table records in a WD application. I am not sure if the sequence deleted rows, then inserted rows and lastly modified rows is always correct when it comes to the DB operation. If a user deletes a record and inserts a record with the same values it shouldn't be a problem. But if a new record is inserted in the internal table of the WD app and then deleted again from the internal table you have to pay attention:
-Either no change to the db table
or
-First insert the record and then delete it again.
I am going to create the change log by myself from the parameters of event handler ONDATACHECK. The change log will contain all fields of the record plus a change indicator (U=updated, I=inserted, D=deleted). The log will be processed record after record to the db table.
Regards,
Bernd
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.