How can I output a top level BOM that totals all of the components in the top level as well as all components in sub assemblies?

We are currently manually creating BOM outputs and then sorting and adding quantities in Excel. How can I use API and Macro's to do this? We typically have a top level assembly with several repeating sub assemblies below the top level. Our purchasing department is requiring us to supply a BOM with a single line per component with a total quantity for the top level assembly. The current way we are doing it is prone to mistakes.

BTW, I know NOTHING about API. Are there any textbooks/reference manuals out there for Solidworks API?

We are currently running SW 2019 on a combination of Windows 7 and 10 on our design computers.

Any help would be greatly appreciated.

SolidworksBill Of Materials