2022 Apr 19 11:20 AM
I have a ztable with 3 rows,

I fill an ITAB with this 3 rows .
Then the user deletes the row with material 202 from the ITAB.
So now the ITAB has the following records:

How can I update the DB ZTABLE in order to have the same records as the ITAB.
1 way is to delete the records from ZTABLE and then MODIFY it from the ITAB.
So my question is, how to DELETE the extra row from ZTABLE in order to have the same number of rows with ITAB?
Thanks
Elias
I have a ztable with 3 rows,

I fill an ITAB with this 3 rows .
Then the user deletes the row with material 202 from the ITAB.
So now the ITAB has the following records:

How can I update the DB ZTABLE in order to have the same records as the ITAB.
1 way is to delete the records from ZTABLE and then MODIFY it from the ITAB.
So my question is, how to DELETE the extra row from ZTABLE in order to have the same number of rows with ITAB?
Thanks
Elias
2022 Apr 19 1:14 PM
Could you please, post your code, using the beautoful button [CODE].
Or just check the transaction ABAPDOCU, enter the keywork DELETE
2022 Apr 19 2:12 PM
Alternatively, the step 4 can be avoided if the logic records the type of operation for each changed line (i.e. delete, insert, modification)
2022 Apr 19 2:24 PM
Thanks Sandra. My problem is in step No 5. The Insertion & Modification are covered by the command MODIFY. But how to tell the SAP: DELETE the lines from DB ZTABLE that do not exist in ITAB or KEEP only the lines that exist in ITAB?
2022 Apr 19 5:27 PM
Hi Elias,
I think you can do this:
Create 2 internal tables, one of them with all selected records, the other one with those records that were deleted by the user.
DATA: ti_selected TYPE STANDARD TABLE OF tp_table,
ti_deleted TYPE STANDARD TABLE OF tp_table.
SELECT field1, field2,....
INTO @ti_selected
FROM dbtable.
*When the user deletes a row, move it to TI_DELETED, then delete it from TI_SELECTED.
APPEND es_selected TO ti_deleted.
DELETE ti_selected WHERE .... .
*At the end of the process, delete the data base table with the records in TI_DELETED.
DELETE dbtable FROM TABLE @ti_deleted.
*Modify the records with TI_SELECTED
MODIFY dbtable FROM TABLE @ti_selected.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |