How do I roll up BOM total cost into quotation item?

In quotation item,when we choose item,can we show a field to select its BOM ,it should show total cost of the BOM selected. How to setup custom script for this ?