That topic is covered in the Advanced training class for WinRunner. I recommend you talk to your manager to get you some formal training in the tool. It isn't one of the easiest ones out there.
In the meantime you can read the WinRunner User's Guide, Chapter 29, pp 559. This Chapter is called "Creating User-Defined Functions". This will get you started down the road with the information you need to attempt some trial and error and learn from the situation.
If you haven't done so already, and you initial post doesn't lend to thinking different, you should spend some time and go through the Tutorial and read the User's Guide. It is there for the basic questions of using the tool and gaining more benefit from its use than standard record and playback.