金蝶K/3 WISE 12.3訂單跟蹤SQL報表

金蝶K3一直缺少完整的跟蹤報表,所以我們開發了一張完整的跟蹤報表,通過查詢分析工具直接生成。

 

wKioL1j4TnPS3PaKAAAd42wgGPM295.png-wh_50

wKiom1j4TnPDtuiWAAAX7dv3-4s009.png-wh_50

wKiom1j4TnSB66oOAAC5PcEPrQI877.png-wh_50

 

 

代碼(WIN2008 R2+SQL 2008 R2環境,K3 WISE 12.3):

 

 

 

select t1.fname1 客戶,t1.fname2 業務員,t1.f_102 款號,t1.fbillno 訂單號,t1.fdate 訂單日期,t1.fqty 訂單數量,t5.fqty 生產數量,t10.fnumber BOM材料代碼,t10.fname BOM材料名稱,t6.fnumber 投料單材料代碼,t6.fqty 投料單數量,t7.fqty 領料單數量,t7.soutfprice 領料單價,t7.soutfamount 領料金額,
t2.fdate 申請日期,t2.SEEfbillno 申請單號,t2.fnumber 申請物料代碼,t2.fqty 申請數量,t3.fdate 採購日期,t3.sefbillno 採購訂單號,t3.fqty 採購訂單數量,t3.fprice 採購單價,t3.famount 採購金額,t4.fdate 入庫日期,t4.fbillno 入庫單號,t4.fqty 入庫數量,t8.cpfdate 成品入庫日期,t8.fqty 產品入庫數,t8.cpfprice 入庫單價,t8.cpfamount 入庫金額,
t9.fqty 出庫數量,t9.fqtyinvoice 開票數量 FROM
(select t5.f_102,t3.fname fname1,t4.fname fname2,t1.fbillno,sum(t2.fqty) fqty,t1.fdate,t1.finterid  from seorder t1
inner join seorderentry t2 on t1.finterid=t2.finterid
inner join t_organization t3 on t1.fcustid=t3.fitemid
inner join t_emp t4 on t1.fempid=t4.fitemid
inner join t_icitem t5 on t2.fitemid=t5.fitemid where t1.fcancellation=0
group by t5.f_102,t3.fname,t4.fname,t1.fbillno,t1.fdate,t1.finterid) t1
--生產任務單
left join (select t2.f_102,t1.forderinterid,sum(t1.fqty) fqty from icmo t1
inner join t_icitem t2 on t1.fitemid=t2.fitemid
group by t2.f_102,t1.forderinterid) t5 on t1.f_102=t5.f_102 and t1.finterid=t5.forderinterid
--產品入庫單
left join (select t3.f_102,t2.fentryselfa0240,sum(fqty) fqty,t1.fdate cpfdate,t2.fprice cpfprice,t2.famount cpfamount from icstockbill t1
inner join icstockbillentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t2.fitemid=t3.fitemid where t1.ftrantype=2
group by t3.f_102,t2.fentryselfa0240,t2.fprice,t2.famount,t1.fdate) t8 on t1.f_102=t8.f_102 and t1.fbillno=t8.fentryselfa0240
--銷售出庫
left join (select t3.f_102,t2.forderbillno,sum(fqty) fqty,sum(fqtyinvoice) fqtyinvoice from icstockbill t1
inner join icstockbillentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t2.fitemid=t3.fitemid where t1.ftrantype=21
group by t3.f_102,t2.forderbillno) t9 on t1.f_102=t9.f_102 and t1.fbillno=t9.forderbillno
--BOM單
left join (select distinct t3.f_102,t4.fnumber,t4.fname from icbom t1
inner join ICBOMCHILD t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t3.fitemid=t1.fitemid
inner join t_icitem t4 on t2.fitemid=t4.fitemid) t10 on t10.f_102=t1.f_102
--投料單
left join (select t3.f_102,t1.forderbillno,t4.fnumber,t4.fname,sum(t2.fqtymust) fqty from ppbom t1
inner join ppbomentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t1.fitemid=t3.fitemid
inner join t_icitem t4 on t2.fitemid=t4.fitemid
group by t3.f_102,t1.forderbillno,t4.fnumber,t4.fname) t6 on t1.f_102=t6.f_102 and t1.fbillno=t6.forderbillno and t6.fnumber=t10.fnumber
--領料單
left join (select fentryselfb0453,fentryselfb0454,t3.fnumber,sum(fqty) fqty,t2.fprice soutfprice,t2.famount soutfamount from icstockbill t1
inner join icstockbillentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t2.fitemid=t3.fitemid where t1.ftrantype=24
group by fentryselfb0453,fentryselfb0454,t3.fnumber,t2.fprice,t2.famount) t7 on t1.f_102=t7.fentryselfb0453 and t1.fbillno=t7.fentryselfb0454 and t6.fnumber=t7.fnumber
--採購申請
left join (select t1.fheadselfp0136,t2.fentryselfp0137,t3.fnumber,t3.fname,sum(t2.fqty) fqty,t1.fdate fdate,t1.fbillno SEEfbillno from porequest t1
inner join porequestentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t2.fitemid=t3.fitemid
group by t1.fheadselfp0136,t2.fentryselfp0137,t3.fnumber,t3.fname,t1.fdate,t1.fbillno) t2 on t1.fbillno=t2.fheadselfp0136 and t1.f_102=t2.fentryselfp0137 and t10.fnumber=t2.fnumber
--採購訂單
left join (select t2.fentryselfp0270,t2.fentryselfp0269,t3.fnumber,t3.fname,sum(t2.fqty) fqty,t2.fprice fprice,t2.famount famount,t2.fdate fdate,t1.fbillno sefbillno from poorder t1
inner join poorderentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t2.fitemid=t3.fitemid
group by t2.fentryselfp0270,t2.fentryselfp0269,t3.fnumber,t3.fname,t2.fprice,t2.famount,t2.fdate,t1.fbillno) t3 on t1.fbillno=t3.fentryselfp0270 and t1.f_102=t3.fentryselfp0269 and t10.fnumber=t3.fnumber
--外購入庫單
left join (select t2.fentryselfa0158,t2.fentryselfa0159,t1.fdate,t3.fnumber,t3.fname,t1.fdate fdate1,t1.fbillno fbillno,sum(t2.fqty) fqty from icstockbill t1
inner join icstockbillentry t2 on t1.finterid=t2.finterid
inner join t_icitem t3 on t3.fitemid=t2.fitemid
where t1.ftrantype=1
group by t2.fentryselfa0158,t2.fentryselfa0159,t1.fdate,t3.fnumber,t3.fname,t1.fdate,t1.fbillno) t4 on t1.fbillno=t4.fentryselfa0159 and t1.f_102=t4.fentryselfa0158 and t10.fnumber=t4.fnumber
where t1.f_102 like '%*kuanghao*%' and t1.fbillno like '%*FBillNoCommon*%'
order by t1.fdate

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章