Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Records from Ztable

former_member844813
Participant
0 Kudos
720

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.
1 ACCEPTED SOLUTION

Mohamed
Explorer
643

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.

6 REPLIES 6

FredericGirod
Active Contributor
643

Transaction ABAPDOCU

search for keyword DELETE

and select DELETE dbtable

0 Kudos
643

and which one should i follow dear sir ?

643

demaauliansyah I think that the answer was very clear. You must use DELETE to delete all the existing record. What don't you understand?

Mohamed
Explorer
644

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.

raymond_giuseppi
Active Contributor
0 Kudos
643

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

0 Kudos
643

delete ztable.