Hi Shihari,
as Raymond already said, calling RFC_PING and catching the EXCEPTIONS SYSTEM_FAILURE and COMMUNICATION_FAILURE should do the trick. (By the way, you should always catch these two EXCEPTIONS also in the "real" function calls. Then you can exit gracefully with a meaningfull error message in case of network problems.)
An alternative solution is to call the FM RFC_VERIFY_DESTINATION with DESTINATION = 'name of your destination' and catch its exceptions.
Best Regards, Ulrich