HI Murli,
You are right that you need a routine for the requirement.
Go to VOFM select menu - requirements - > pricing and create a new routine there. You will need an access key for the same.
As you want the condition value to appear in sales order and in proforma invoice then your abap code should check that the document category, VBTYP is - C or U.
Regards
Ankit