Quantity structure in SAP product costing enables calculating the cost of goods manufactured and cost of goods sold based on the bill of materials (BOM) and routing or master recipe. It requires defined master data like material masters, BOMs, work centers, routings/master recipes, and production versions. A BOM lists component materials and quantities, while a routing/master recipe defines production processes and work centers/resources. Multiple production versions can exist if there are different ways to produce a material. Quantity structure is key for integrating finance and logistics modules to accurately value inventory using component, activity, and overhead costs.