Handling SAP connection time out in the flow service

Hi All,

I had a scenario,where I need to call a BAPI in SAP. In that there is a scenario when the service calls BAPI, if the SAP system in down it could result in failure. For this I need to develop a service which handles this case by waiting out for a certain period of time. If the SAP HR system doesn’t send a response within the agreed time frame, we need to exit the flow. Can anyone please guide me and advise me if there is any built in service to handle this situation if not the steps which i need to follow.

Following are the steps which i am using to call a BAPI.

1.opening a session with SAP
2.sap.map:outbound is a service which i am using to call a bapi.
3.check for the error messages depending on the value of I_Return
if I_RETURN has 0 records ,exit flow
else call another flow

Please let me know where i need to change the flow.

Thanks in advance
Naren