Your understanding about the 'withdrawal' of gratuity and PF is incorrect. Both of these cannot be withdrawn while you are in service. Gratuity is an amount that will accrue only when you leave the establishment after completing at least five years of continuous service. To be considered in continuous service, you should have worked for at least 240 days (pay days) in a year. Therefore, the question of its encashability does not arise if you are leaving the company before the said period of five years. There are some confusions regarding whether gratuity can be claimed if you have worked for four years and some 240 days in the fifth year, as is supported by some court verdicts. However, the employer can refuse to pay gratuity in such cases since there is nothing mentioned in the Payment of Gratuity Act regarding eligibility of gratuity for an employee who has not completed five years but has only completed 4 years and 240 days.
As for EPF, it is also a payment that cannot be withdrawn while in service. However, subject to certain conditions relating to years of service, you can get advances from PF accumulations for the purchase or construction of a residential building, marriage, education, etc.
Regards,
Madhu.T.K