if @Item_No='' and @Component_No=''
Begin
select @TheFirst=1
DECLARE Bom_Product CURSOR local FOR
SELECT Item_No,Component_No,Qtyper,IsProduct,IsHalfProduct,IsMaterial
FROM Mrp_bomdetailBak
OPEN Bom_Product
FETCH NEXT FROM Bom_Product
INTO @1Item_No,@1Component_No,@1Qtyper,@1IsProduct,@1IsHalfProduct,@1IsMaterial
End
else
Begin
select @TheFirst=0
DECLARE Bom_Product CURSOR local FOR
SELECT Item_No,Component_No,Qtyper,IsProduct,IsHalfProduct,IsMaterial
FROM Mrp_bomdetailBak
where Item_No=@Component_No
OPEN Bom_Product
FETCH NEXT FROM Bom_Product
INTO @1Item_No,@1Component_No,@1Qtyper,@1IsProduct,@1IsHalfProduct,@1IsMaterial
End
WHILE @@FETCH_STATUS = 0
BEGIN
if (@TheFirst=1) AND (@Item_No<>@1Item_No)
begin
Select @Item_No=@1Item_No
SELECT @IntLevel=1
Print ''
Print'-----------------------------------------------'+ cast(@1Item_No as varchar) +'-----'
end
if @1IsHalfProduct=1
Begin
Print @TempStr+'| +'+cast(@1Item_No as varchar) + cast(@1Qtyper as varchar) + '->'+@1Component_No
End
Else
begin
Print @TempStr+'|-'+cast(@1Item_No as varchar) + cast(@1Qtyper as varchar) + '***' + cast(@ComponentQty*@1Qtyper as varchar) +'->'+@1Component_No
insert into Mrp_bomdetail_EXP (item_no,COMPONENT_NO,QTYPER) values (@Item_No,@1Component_No,@ComponentQty*@1Qtyper)
end
FETCH NEXT FROM Bom_Product
INTO @1Item_No,@1Component_No,@1Qtyper,@1IsProduct,@1IsHalfProduct,@1IsMaterial