In Sage 50, you do this when you actually enter the costs, rather than when you create the job, phase, or cost code. So when you set up Sage 50 for your jobs, you will separately set up all of your jobs, then all of the various phases (parts) of your jobs, then all of the specific types of costs (cost codes) for each aspect of the work you will perform.
Then, when you purchase, say, materials for a job, you will enter the job, phase, and cost code that the materials were used for in Purchases/Receive Inventory, on the line item for that purchase. Internally, Sage 50 will keep track of which job, phase, and cost code were used and report on the job appropriately.