Do a search on the iPhone forum for this issue, there are several threads on how to get it done.
From memory, if you plug your iPhone in to iTunes, then right click (option click) on your iPhone name on the left side of iTunes, then click 'transfer purchases'. Once that is done, right click again and back up your phone.
Using the above method will not transfer non iTunes music....