Prior to announcing year-end results of companies, dates are set out for the Closure of Register of members for the purpose of payment of dividend and issue of scrip popularly known as 'Bonus'. These dates will determine the qualification for dividends and scrips.
Hence, "cum div" or "cum scrip" means purchases before the Closure of Register (or sales after the closure) will be entitled to all the benefits payable on the investment while "ex div" or "ex scrip" means purchases made after the entitlements were declared (or sales before closure).
Conversely, if you sell your shares before the Closure of Register, you sold so to say "ex div" and "ex scrip" and hence you will not enjoy the dividend or scrip to be issued at the coming AGM. The reverse is the case when you sell your share "cum div" and cum scrip"