Quantcast
Channel: AX Developer Forum
Viewing all articles
Browse latest Browse all 9880

Exploding BOM through recursive CTE

$
0
0

Hi Guys,

 

I'm trying to explode the BOM through recursive CTE, but I'm still getting the anchor rows only. However, I'm trying to use this SQL code:

 

With BOMTree_CTE

AS

(

--Anchor

Select 

B.BOMID

,B.ITEMID 

,B.LINENUM

,B.position

,B.BOMQTY

,B.INVENTDIMID

,0 as 'CurrentLevel'

,BV.BOMID as BVBomId

,BV.ITEMID 

FROM BOM B Left Join BomVersion BV On B.ItemID = BV.ItemId

 

Union All

Select 

BB.BOMID

,BB.ITEMID

,BB.LINENUM

,BB.position

,BB.BOMQTY

,BB.INVENTDIMID

,CurrentLevel+1

,CAST('1' as nvarchar(20)) 

,CAST('2' as nvarchar(20))

From Bom BB  Join BOMTree_CTE C On BB.BOMID = C.BVBomId

)

select * from BOMTree_CTE C 

 

 

I don't wanna do it through X++, I need it through SQL!

 

Any help is highly appreciated! 


Viewing all articles
Browse latest Browse all 9880

Latest Images

Trending Articles



Latest Images