I am working with the following code in order to delete all those records from my ztable (zvdelivery1) that do not have the MATNR (mat.no.) of 18 characters. In other words I wish to delete the corrupt data from this table but there is something wrong with this code as it's not deleting the said data.
Kindly have a look and advise the corrections.
select amatnr abox_no adat aexcise_from aexcise_to abox_size1
into corresponding fields of table itab
from zvdelivery1 as a where
plant eq '1010'.
loop at itab.
count = strlen( itab-matnr ).
if count lt 18.
main_table-matnr = itab-matnr.
main_table-box_no = itab-box_no.
main_table-dat = itab-dat.
main_table-excise_from = itab-excise_from.
main_table-excise_to = itab-excise_to.
main_table-box_size1 = itab-box_size1.
loop at main_table.
DELETE from zvdelivery1
WHERE MATNR = MAIN_TABLE-MATNR AND
BOX_NO = main_table-box_no.