I have created a bill of material report showing the bom level, the top level part, the child part and the child parts, children. It gives me the right data and end users are using it but they have to a wee bit of cross referring
One user has asked if they can get this as an indented bom. They want to see each assembly, it’s sub assemblies and it’s sub assemblies. I was intending to modify the existing SSRS report but given we can have up to 8 levels on the bill of material I am struggling to come up with any sensible way to do this with grouping/sub reports etc.
The first example below is how the data currently comes out of the report
BOMLEVEL TopLevelPartNum PartNum RevNum QtyPer Apprvd FQty ChildPartNum PartQty
1 379-3778 379-3778 0A 1 1 0 194-4302 1
1 379-3778 379-3778 0A 1 1 0 310-6810 1
1 379-3778 379-3778 0A 2 1 0 363-6269 2
1 379-3778 379-3778 0A 1 1 0 364-5733 1
1 379-3778 379-3778 0A 1 1 0 382-1712 1
2 379-3778 382-1712 0A 0.04761 1 0 4330X15X3 0.04761
2 379-3778 363-6269 0 1 1 0 363-6268 2
2 379-3778 363-6269 0 2 1 0 8T-3490 4
3 379-3778 363-6268 0 0.00606 1 0 4325X12X3 0.01212
2 379-3778 310-6810 0 0.00699 1 0 5825X12X3 0.00699
2 379-3778 194-4302 0 0.00543 1 0 4325X12X3 0.00543
What I actually want to structure this like is
This is all based on querying the part material table. What I essentially want to replicate without creating a job, is a structure similar to what the system does when populating the job assembly table. Does anyone please have any ideas on how to do this without having an infinitely cascading series of sub reports.
The underlying query used the generate this data is below
with pm as (select x.Company, x.PartNum,x.MtlSeq, x.RevisionNum, QtyPer, pr.Approved,
FixedQty, MtlPartNum as ChildPartNum
from erp.PartMtl x
inner join erp.PartRev pr on pr.Company = x.Company
and pr.PartNum = x.PartNum
and pr.RevisionNum = x.RevisionNum
and pr.Approved = 1
and pr.EffectiveDate <= GetDate()
and pr.EffectiveDate = (select max(effectiveDate)
from erp.PartRev pr2
where pr2.Company = pr.Company
and pr2.PartNum = pr.PartNum
and pr2.Approved = 1
and pr2.EffectiveDate <= GetDate()) ),
bm as (select 1 as BOMLevel,
root.PartNum as TopLevelPartNum, root.*,
cast(root.QtyPer as decimal(30,10)) as PartQty
from pm as root
where not exists (select null
from Erp.PartMtl b
where b.MtlPartNum = root.PartNum)
union all
select BOMLevel + 1 as BOMLevel,
bm.TopLevelPartNum, node.*,
cast(node.QtyPer * bm.PartQty as decimal(30,10)) as PartQty
from pm as node inner join bm on bm.Company = node.Company
and bm.ChildPartNum = node.PartNum)
Select BOMLEVEL, TopLevelPartNum,PartNum, RevisionNum, QtyPer, Approved, FixedQty, ChildPartNum, PartQty
from bm
where TopLevelPartNum='379-3778'