臨時表方式,適用於單一產品產品。
alter proc [dbo].[bomselect_cw] @kkk varchar(80)
asset nocount on
if object_id('tempdb..hwbom')<>0
drop table hwbom
if object_id('tempdb..hwbomchild')<>0
drop table hwbomchild
create table hwbom
( fid int identity(1,1),
fitemid int
) create table hwbomchild
( fid int identity(1,1),
forgid int,
fparentid int,
flevel int,
fsn nvarchar(200),
fitemid int,
fqty decimal(28,19),
fbominterid int,
fentryid int
) insert into hwbom
(fitemid)
select t.fitemid from t_icitem t
inner join t_item t5 on t5.fitemid = t.fitemid
left join icbom t6 on t6.fitemid=t.fitemid
left join icbomgroup t7 on t7.finterid=t6.fparentid
where
t.ferpclsid in (2,3,5)--2代表自製件,代表委外件,代表虛擬件
and t5.fdeleted=0
--and t5.fnumber = '@kkk' --可根據需要限定bom範圍
and t6.fusestatus=1072
order by t.fnumber
insert into hwbomchild
(forgid,fparentid,fsn,fitemid,fqty,fbominterid,fentryid,flevel)
select
fid,-1 as fparentid,'001',u1.fitemid,1 as fqty,t1.finterid as fbominterid,-1 as fentryid,0
from hwbom u1
left join icbom t1 on u1.fitemid=t1.fitemid where t1.fusestatus=1072
declare @level int
set @level=1
while exists(
select 1 from
hwbomchild
where flevel=@level-1
and fitemid in
(select fitemid from icbom where fusestatus=1072 )
) and @level<20
begin
insert into hwbomchild
(forgid,fparentid,fsn,fitemid,fqty,fbominterid,fentryid,flevel)
select
u1.forgid,u1.fid,u1.fsn+'.'+right('000'+convert(nvarchar(50),t2.fentryid),3),t2.fitemid,u1.fqty*(t2.fqty/t1.fqty)/(1-t2.fscrap/100),
t2.finterid,t2.fentryid,@level
from hwbomchild u1
inner join icbom t1 on u1.fitemid=t1.fitemid
inner join icbomchild t2 on t2.finterid=t1.finterid
where u1.flevel=@level-1 and t1.fusestatus=1072
set @level=@level+1
end
select
t2.fnumber 產品**,t2.fname 產品名稱,t2.fmodel 產品規格,
t1.fsn 序號,
t3.fnumber 材料**,t3.fname 材料名稱,t3.fmodel 材料規格,t1.fqty 產品用量,yy.fname 材料屬性,
t5.fqty 單位用量,
t5.fscrap 損耗率,
t4.fbomnumber bom編號,
t6.fname as 是否跳層,
t5.fnote 備註,
t5.fpositionno 位置號
from hwbom u1
inner join hwbomchild t1 on u1.fid=t1.forgid
inner join t_icitem t2 on t2.fitemid=u1.fitemid
inner join t_icitem t3 on t3.fitemid=t1.fitemid
left join icbom t4 on t4.finterid=t1.fbominterid
left join icbomchild t5 on t5.finterid=t1.fbominterid and t5.fentryid=t1.fentryid
left join t_submessage t6 on t6.finterid=t4.fbomskip
inner join t_submessage yy on yy.finterid=t3.ferpclsid
where t2.fnumber like @kkk
order by u1.fid,t1.fsn
drop table hwbom
--刪除父表
drop table hwbomchild
--刪除子表
--set nocount off
--exec bomselect_cw 'hj9003a'
金蝶EAS GUI單據呼叫擴充套件報表
definereportinfo reportinfo exteasbillutil.showreportdialog if reportinfo null string reportid reportinfo.getid tostring 報表id string reportname report...
金蝶eas擴充套件報表平台開發教程
金蝶eas裡面本身就有很好的一套報表開發平台,也是很強大很完善的,基本是跟報表有關都可以在這裡展示。這裡報表開發一般分為三個步驟 1.資料庫檢視編寫 資料來源 2.sql結果集編輯 資料集 3.excel樣式編輯 報表 select t.from v tcbj invbal t where t.wh...
金蝶K3案例教程銷售報表
銷售毛利潤表 銷售毛利潤表是綜合反映一定時間銷售收入 銷售成本以及銷售利潤的情況,是針對銷售毛利的彙總查詢。可按客戶 產品 銷售部門分析。雙擊,進入下一介面 如上圖,設定日期範圍或期間範圍,成本依據選擇實際成本,勾選分級彙總,彙總依據客戶即按客戶分析,點確定,進入下一介面 可看到,按客戶顯示銷售毛利...