I brought a new flip cover which has magnet for easy closingup. After putting that case my s pen connection got some issue. My phone didn't detect s pen when i put it in its cabin. Later i realised that it is due to the interfere of magnetic field of that flip cover. I confirm it by removing flip cover.
So for those who face any issue with s pen connection please remove flip cover if there is and test your phone.
This is the cheap local flip cover i brought.
can you send me a Galaxi S9