Replace a part of the string

Hi

I need to Replace a part of string in between one complete string.

For e.g..  
in the file the value is as:
jobnm_$code_xyz_001 
In script we are having a variable code=$3, where $3=ab
 
final output should be jobnm_ab_xyz_001.

But it is not working. Your help will be highly appriciated.

KSH:

>CODE=ab
>echo jobnm_${CODE}_xyz_001
jobnm_ab_xyz_001