Getting the customer hierarchy partners as partner functions in the sales document is one thing - if you perform the search as already suggested, you will find very good documentation on the subject in help.sap.com.
Getting customer hierarchy in CO-PA seems to be a different story. I strongly suggest that you perform a search in SCN - for example customer hierarchy co-pa and read the discussions/wiki etc.
Some forum members suggest that using the SD hierarchy may not be a very good idea in certain cases and provide an alternative approach. Unfortunately I do not consider myself an expert in that area, so cannot comment whether this is a cause for concern for your requirement.