Hi Amine,
you were not able to restrict the characteristics with this pattern in Bex query designer?
in filters ->characteristics exclude with value of *D4.
if this doesn't work, you can write a exit to have this logic for exclude using CP(contains pattern) operator.
Regards,
Sakthi