Please also have a look in our OnlineHelp for further information.
When IDocs are sent by SAP while the external system is not available at this moment, these IDocs / calls are flagged with error in SM58 (tRFC monitor). The calls are resent automatically after minutes depending on the system configuration.
These code snippet shows an option to force the resend.
It looks up all errors in tables ARFCSSTATE of a given destination and then calls ARFC_RUN_NOWAIT to resend each call.