Why not take all in awk, do you need the "program"?
awk 'BEGIN {n=split("abc def lce",q," ");for (i=1;i<=n;i++) d[q[i]]="P"i} {sub($2,d[$2])}8' file
12 P1 13 14
13 P2 14 15
1 P3 22 14
How it works
awk '
BEGIN { # Begin block
n=split("abc def lce",q," ") # split the list of data in to array "q" and set "n" to number of elements
for (i=1;i<=n;i++) # loop trough all elements
d[q[i]]="P"i # assing P1, P2 etc to first, second element "d[abc]=P1" etc
}
{sub($2,d[$2])} # change filed 2 to new element
8 # print the new line
' file # input file
If table with "P" data is not sequel, you can add it just like other table:
awk 'BEGIN {n=split("abc def lce",q," ");split("P2 Q4 A3",r," ");for (i=1;i<=n;i++) d[q[i]]=r[i];print d["def"]}'