2023 Apr 05 4:49 AM
Hi Experts!
i want to delete all the existing record in ztable everytime my program is executed, and new records will be inserted.
what can i do here ?
LOOP at itab into wa.
IF wa-shkzg = 'H'.
wa-dmbtr = -100 * WA-DMBTR.
ELSEIF wa-shkzg = 'S'.
wa-dmbtr = 100 * wa-dmbtr.
ENDIF.
MODIFY itab FROM wa TRANSPORTING dmbtr.
ENDLOOP.
LOOP at itab into wa.
IF wa-shkzg = 'H'.
wa-WRBTR = -100 * WA-WRBTR.
ELSEIF wa-shkzg = 'S'.
wa-WRBTR = 100 * wa-WRBTR.
ENDIF.
MODIFY itab FROM wa TRANSPORTING WRBTR.
ENDLOOP.
LOOP at itab into wa.
IF wa-shkzg = 'H'.
wa-dmbE2 = -1 * WA-DMBE2.
ELSEIF wa-shkzg = 'S'.
wa-dmbe2 = 1 * wa-dmbe2.
ENDIF.
MODIFY itab FROM wa TRANSPORTING dmbe2.
MODIFY ZDATAGL2 FROM WA.
ENDLOOP.
2023 Apr 05 1:14 PM
demaauliansyah 1) First you pick the available records into an Internal table and use DELETE statement as sandra.rossi suggested. 2) And then add your new records into your table with the help of MODIFY statement.
2023 Apr 05 6:48 AM
Transaction ABAPDOCU
search for keyword DELETE
and select DELETE dbtable
2023 Apr 05 9:13 AM
2023 Apr 05 12:24 PM
demaauliansyah I think that the answer was very clear. You must use DELETE to delete all the existing record. What don't you understand?
2023 Apr 05 1:14 PM
demaauliansyah 1) First you pick the available records into an Internal table and use DELETE statement as sandra.rossi suggested. 2) And then add your new records into your table with the help of MODIFY statement.
2023 Apr 05 4:04 PM
Easier solution, use DELETE statement.
NB: Only in case of 'very big' table and performance problems, look at FM such as MCS_BIW_DROP_CREATE_TABLE or native SQL statements related to TRUNCATE statement.
NB: Optimize your code, use a single LOOP with ASSIGNING to a <fs>. And put the MODIFY with FROM TABLE option out of the loop
2023 Apr 05 6:06 PM