However, on older R/3 systems, it's still possible to fall foul of this problem when the service port mappings are not present in the /etc/services file.
When using RFC connections or testing a connection in SM59, you're seeing CPI-C (CPIC) errors with "Service sapgw00 Unknown" and CM_RESOURCE_FAILURE_NO_RETRY.
It's normally visible as a connectivity error when testing connections in SM59:
You should ensure that the connection test fails when you put the exact numerical port number into the SM59 "Gateway service" connection details, as well as failing when you have the service port name e.g. sapgw00: