Cause: AFPCOA failed due to ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Solution
In my case I was using the root user to execute the script, which should be run by applmgr user. Use applmgr to run the script and you will not get the above error.
Environment
+ Oracle E-Business Suite Release 12.2.7
+ Oracle Linux x86-64