我是靠谱客的博主 生动老师,最近开发中收集的这篇文章主要介绍金蝶K3 SQL报表系列-生产在线材料查询,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1、创建存储过程,代码如下:

 

 
  1. create procedure [dbo].[rk_sp_wip_status]

  2. @enddate datetime

  3. as

  4.  
  5.  
  6. --declare @enddate datetime

  7.  
  8. --set @enddate='2012-06-30'

  9.  
  10. select

  11. u1.FBillNo 任务单号,

  12. u1.FCheckDate 下单日期,

  13. case when u1.FStatus=0 then '计划' when u1.FStatus=3 then '结案' when u1.FStatus in (1,2) then '下达' else '' end as 状态,

  14. u11.FNumber 产品代码,

  15. u11.FName 产品名称,

  16. u11.FModel 产品规格,

  17. u1.FQty 生产数量,

  18. t3.FBegStockInQty 截止入库数量,

  19. t3.FEndStockInQty 期后入库数量,

  20. t21.FNumber 材料代码,

  21. t21.FName 材料名称,

  22. t21.FModel 材料规格,

  23. t22.Fname 领料类型,

  24. t23.Fname 发料仓库,

  25. t2.FqtyScrap 标准用量,

  26. case when t2.FMaterielType=376 then -t2.FQtyMust else t2.FQtyMust end 需发料数量,

  27. t2.FDiscardQty 报废数量,

  28. t4.FBegStockOutQty 截止领料数量,

  29. t4.FEndStockOutQty 期后领料数量,

  30. t5.FBegScrapQty 报废数量,

  31. t5.FEndScrapQty 期末报废数量,

  32. isnull(t4.FBegStockOutQty,0)-((case when t2.FMaterielType=376 then -t2.FQtyMust else t2.FQtyMust end)/u1.FQty)*isnull(t3.FBegStockInQty,0)-isnull(t5.FBegScrapQty,0) 在线数量

  33. from icmo u1

  34. inner join t_icitem u11 on u11.FItemID=u1.FItemID

  35. inner join PPBOM t1 on u1.FInterID=t1.FICMOInterID

  36. inner join PPBOMEntry t2 on t1.FInterID=t2.FInterID

  37. inner join t_ICItem t21 on t21.FItemID=t2.FItemID

  38. left join t_submessage t22 on t22.Finterid=t2.FMaterielType

  39. left join t_stock t23 on t23.Fitemid=t2.Fstockid

  40. left join

  41. (

  42. select

  43. t1.FICMOInterID,

  44. sum(case when u1.FDate<@enddate then t1.FQty else 0 end) as FBegStockInQty,

  45. sum(case when u1.FDate>=@enddate then t1.FQty else 0 end) as FEndStockInQty

  46. from ICStockBill u1

  47. inner join ICStockBillEntry t1 on u1.FInterID=t1.FInterID

  48. where u1.FCancellation=0 and u1.FTranType=2

  49. group by FICMOInterID

  50. ) t3 on t3.FICMOInterID=u1.FInterID

  51. left join

  52. (

  53. select

  54. t1.FICMOInterID,

  55. t1.FPPBomEntryID,

  56. sum(case when u1.FDate<@enddate then t1.FQty else 0 end) as FBegStockOutQty,

  57. sum(case when u1.FDate>=@enddate then t1.FQty else 0 end) as FEndStockOutQty

  58. from ICStockBill u1

  59. inner join ICStockBillEntry t1 on u1.FInterID=t1.FInterID

  60. where u1.FCancellation=0 and u1.FTranType=24

  61. group by FICMOInterID,t1.FPPBomEntryID

  62. ) t4 on t4.FICMOInterID=t2.FICMOInterID and t4.FPPBomEntryID=t2.FEntryID

  63. left join

  64. (

  65. select

  66. t4_1.Fsourceinterid,

  67. sum(case when t4_2.FDate<@enddate then t4_1.FQty else 0 end) as FBegScrapQty,

  68. sum(case when t4_2.FDate>=@enddate then t4_1.FQty else 0 end) as FEndScrapQty,

  69. t4_1.FSourceEntryid,

  70. t4_1.FSourceTranType

  71. from

  72. ICItemScrapEntry t4_1

  73. inner join ICItemScrap t4_2 on t4_1.finterid=t4_2.finterid

  74. where t4_2.Fdate<@enddate and t4_2.Fstatus=1

  75. group by t4_1.Fsourceinterid,t4_1.FSourceEntryid,t4_1.FSourceTranType

  76.  
  77.  
  78.  
  79. ) t5 on t5.FSourceInterid=t1.FICMOInterid and t5.FSourceEntryid=t2.FEntryID

  80. where

  81. (

  82. (

  83. (

  84. u1.FCloseDate>=@enddate

  85. or u1.FInterID in (

  86. select FICMOInterID from ICStockBillEntry u1

  87. inner join ICStockBill t1 on u1.FInterID=t1.FInterID

  88. where t1.FCancellation=0

  89. and t1.FDate>=@enddate)

  90. )

  91. and u1.FStatus=3

  92. )

  93. or u1.FStatus in (1,2)

  94. ) and u1.FCheckDate<@enddate

  95. order by u1.FBillNo

 

 

2、K3调用存储视图:

 

exec rk_sp_wip_status '########'

最后

以上就是生动老师为你收集整理的金蝶K3 SQL报表系列-生产在线材料查询的全部内容,希望文章能够帮你解决金蝶K3 SQL报表系列-生产在线材料查询所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部