金蝶K3 WISE BOM多级展开_BOM成本表
/****** Object: StoredProcedure [dbo].[pro_bobang_BOMCost] Script Date: 07/29/2015 16:09:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
drop proc pro_bobang_BOMCost
GO
create PROC [dbo].[pro_bobang_BOMCost]
@FBomNumber1 varchar(50), --bom单号
@FBomNumber2 varchar(50) --bom单号
as
begin
SET ANSI_WARNINGS OFF
set nocount on --1.--业务员查找某个BOM单,包含所有BOM(已使用,未使用,已审核,未审核)
with cte as (
select convert(varchar(100),'') as cen,Finterid,FBOMNumber as fppbomnumber,convert(varchar(50),'') as fpbomnumber,Fbomnumber AS FCbomnumber,fitemid,fitemid as fpitemid,0 as fpinterid,convert(decimal(18,4),1) as FBomQty,convert(varchar(500),RIGHT(''+CONVERT(varchar(10),Finterid),6)) as code from ICBOM
where (1=1)
and FBOMNumber >= @FBomNumber1
and FBOMNumber <= case when @FBomNumber2='' then (select MAX(FBOMNumber) from ICBOM) else @FBomNumber2 end
union all
select convert(varchar(100),cen+'------'),a.finterid,c.fppbomnumber,convert(varchar(50),c.FCbomnumber) as fpbomnumber,a.fbomnumber as fcbomnumber,a.fitemid,c.fpitemid,a.fpinterid,convert(decimal(18,4),a.FAuxQty) as FBomQty,convert(varchar(500),c.code+RIGHT(''+convert(varchar(10),a.finterid),6)) as code
from (
select t1.finterid as fpinterid,t2.FInterID,t1.FItemID,t2.FBOMNumber,t1.FAuxQty
from ICBOMChild t1 inner join ICBOM t2 on t1.FItemID=t2.FItemID
where FParentID=1038
union all
select t1.finterid as fpinterid,0,t1.fitemid,'',t1.FAuxQty from ICBOMChild t1 where not exists (select * from ICBOM where FItemID=t1.FItemID)) a
inner join cte c on a.fpinterid=c.FInterID
)
select cen,finterid,fppbomnumber,fpbomnumber,fcbomnumber,fitemid,fpitemid,fpinterid,FBomQty,code into #tmp1 from cte order by code
OPTION (MAXRECURSION 0) --2.--取采购价格管理物料最新日期的价格(已审核,可使用)
SELECT distinct u1.FSupID,u1.FItemID,case when u1.fcyid=1 then u1.FPrice*t3.FExchangeRate/(1+v1.FValueAddRate/100) else u1.FPrice*t3.FExchangeRate end as FPrice,
t3.FName AS FCyName,u1.FQuoteTime,u1.FDisableDate
into #tmp2 FROM t_SupplyEntry u1
INNER JOIN t_ICItem t1 ON u1.FItemID=t1.FItemID
INNER JOIN t_Supply u2 ON u1.FSupID=u2.FSupID AND u1.FItemID=u2.FItemID AND u1.FPType=u2.FPType
INNER JOIN t_Currency t3 ON t3.FCurrencyID=u1.FCyID
INNER JOIN t_Currency u3 ON u3.FCurrencyID=u2.FCurrencyID
INNER JOIN t_Supplier v1 ON u1.FSupID=v1.FItemID
inner join
(
select MAX(fquotetime) as fquotetime,FItemID from t_SupplyEntry where FCheckerID>0 group by FItemID
) bb on bb.FItemID=u1.FItemID and bb.fquotetime=u1.FQuoteTime
WHERE t1.FErpClsID not in (6,8) and u1.FCheckerID>0 and u1.FUsed=1 --3.--列出BOM明细成本,取采购价格的最新价格
select t1.cen+t1.code as FTree,t1.cen,t1.code,t1.fppbomnumber,t1.fpbomnumber,t1.fcbomnumber,t1.FItemID,t1.FBomQty,
t2.FSupID,t2.FPrice as FAuxPrice,t1.FBomQty*t2.FPrice as FAmount,case when FCbomnumber<>'' then t1.FBomQty*t2.FPrice end as FJGAmount
into #tmp3 from #tmp1 t1
left join #tmp2 t2 on t1.FItemID=t2.FItemID
left join t_ICItem t3 on t1.FItemID=t3.FItemID
order by t1.code,t3.FNumber --4.--循环计算中间件成本
---这部分部署会出错,先注释,部署成功,再解除注释更新存储过程
declare @cb decimal(18,4),@fbom varchar(50),@fppbom varchar(50)
declare auth_cur cursor for
select fppbomnumber,fcbomnumber from #tmp3 where FAuxPrice is null and fcbomnumber<>'' and cen<>'' order by cen desc
open auth_cur
fetch next from auth_cur into @fppbom,@fbom
while(@@fetch_status=0)
begin
set @cb=0
select @cb=isnull(SUM(FAmount),0) from #tmp3 where fpbomnumber=@fbom and fppbomnumber=@fppbom
UPDATE #tmp3 set FAmount=isnull(FAmount,0)+@cb,FAuxPrice=isnull(FAuxPrice,0)+@cb/FBomQty where FCbomnumber=@fbom and fppbomnumber=@fppbom
fetch next from auth_cur into @fppbom,@fbom
end
close auth_cur
deallocate auth_cur
----这部分部署会出错,先注释,部署成功,再解除注释更新存储过程 --5.--循环计算成品件成本
---这部分部署会出错,先注释,部署成功,再解除注释更新存储过程
declare @cb1 decimal(18,4),@fbom1 varchar(50),@fppbom1 varchar(50)
declare auth_cur cursor for
select fppbomnumber,fcbomnumber from #tmp3 where fcbomnumber<>'' and cen='' order by cen desc
open auth_cur
fetch next from auth_cur into @fppbom1,@fbom1
while(@@fetch_status=0)
begin
set @cb1=0
select @cb1=isnull(SUM(FAmount),0) from #tmp3 where fpbomnumber=@fbom1 and fppbomnumber=@fppbom1
UPDATE #tmp3 set FAmount=isnull(FAmount,0)+@cb1,FAuxPrice=isnull(FAmount,0)+@cb1/FBomQty where FCbomnumber=@fbom1 and fppbomnumber=@fppbom1
fetch next from auth_cur into @fppbom1,@fbom1
end
close auth_cur
deallocate auth_cur
----这部分部署会出错,先注释,部署成功,再解除注释更新存储过程 select t1.FTree,case when t1.fpbomnumber='' then t1.FCbomnumber end as fpbomnumber,t2.FNumber,t2.FName,t2.FModel,t3.FName as FUnitName,t1.FBomQty,t1.FAuxPrice,t1.FAmount,t1.FJGAmount,t4.FName as FSupName from #tmp3 t1
inner join t_ICItem t2 on t2.FItemID=t1.FItemID
inner join t_MeasureUnit t3 on t2.FUnitID=t3.FItemID
left join t_Supplier t4 on t1.FSupID=t4.FItemID
order by t1.code drop table #tmp1
drop table #tmp2
drop table #tmp3
set nocount off end --exec pro_bobang_BOMCost 'BOM000032','BOM000032'
--exec pro_bobang_BOMCost '*FBomNumber*','#FBomNumber#'
金蝶K3 WISE BOM多级展开_BOM成本表的更多相关文章
- 金蝶K3 WISE BOM多级展开_销售成本表
/****** Object: StoredProcedure [dbo].[pro_bobang_SaleCost] Script Date: 07/29/2015 16:13:43 ******/ ...
- 金蝶K3 WISE BOM多级展开_物料齐套表
/****** Object: StoredProcedure [dbo].[pro_bobang_ICItemQiTao] Script Date: 07/29/2015 16:12:10 **** ...
- 金蝶K3 wise 插件二次开发与配置
金蝶K3 wise 插件二次开发与配置 开发环境:K/3 Wise 13.0.K/3 Bos开发平台.Visual Basic 6.0 目录 一.二次开发插件编程二.代码演示三.配置插件四.测试插件五 ...
- 金蝶K3 WISE 快速登录
金蝶K3 WISE 快速登录 "C:\Program Files (x86)\Kingdee\K3ERP\k3main.exe" -LoginUser|账套号|账套密码|用户账号| ...
- 关于金蝶k3 wise供应生门户登陆界面屏蔽业务账套多余功能模块设置方法
关于金蝶k3 wise供应生门户登陆界面屏蔽业务账套多余功能模块设置方法 1. 找到以下路径 ...\Kingdee\K3ERP\KDHR\SITEFILE\WEBUI\ 找到“Login.aspx” ...
- 金蝶K3 WISE 13.1版本服务器虚拟机环境部署
闲来无事,整个13.1版本的金蝶玩玩. 系统环境:WIN2008 R2,x64位 数据库:MSSQL 2008 R2,X64位 记录下操作步骤: 1.准备安装软件,见图: 2.安装资源包,.net3. ...
- 金蝶 K3 WISE 服务器必须登陆到桌面以后用户才能正常使用解决!
我们单位K3的系统,由当地的服务商安装完以后就出现各种蛋疼的问题.做技术支持的小伙他总是会给一个小工具来解决,问他是什么原因要么说我的网络有问题,要么说我们的服务器有问题. K3所有客户端无法登陆一键 ...
- XP单机版安装金蝶K3的13.1版本号,金蝶K3Wise安装步骤,安装成功
在我们安装金蝶K3时往往会出现各种报错.主要是由于我们的Windows Xp操作系统是Ghost版本号.或者是windows XP HOME或者是精简版,因此某些组件在系统里没有.导致我们安装金蝶K3 ...
- python办公自动化系列之金蝶K3自动登录(一)
做办公自动化的小伙伴都知道,驱动SAP GUI我们有SAP原生提供的[脚本录制与回放]以及SAP Scripting API可参考:驱动Office Excel等,我们有微软提供的[录制宏]功能:驱动 ...
随机推荐
- BZOJ4762 最小集合(动态规划+容斥原理)
https://www.cnblogs.com/AwD-/p/6600650.html #include<iostream> #include<cstdio> #include ...
- windows本地配置php(yii)+nginx+fastcgi
一. 配置nginx支持php 官网下载nginx. nginx.conf配置做如下更改: # yii框架 server { charset utf-8; client_max_body_size 1 ...
- codeforces 1077F2. Pictures with Kittens (hard version)单调队列+dp
被队友催着上(xun)分(lian),div3挑战一场蓝,大号给基佬紫了,结果从D开始他开始疯狂教我做人??表演如何AKdiv3???? 比赛场上:A 2 分钟,B题蜜汁乱计数,结果想得绕进去了20多 ...
- UOJ#348 州区划分
解:有一个很显然的状压...... 就设f[s]表示选的点集为s的时候所有方案的权值和. 于是有f[s] = f[s \ t] * (sum[t] / sum[s])P. 这枚举子集是3n的. 然后发 ...
- 字符串str的使用方法
参考:https://www.cnblogs.com/cookie1026/p/6048092.html #!/usr/bin/env python # -*- coding:utf- -*- s = ...
- Prometheus-配置解析
1.Prometheus整体架构图 2.配置文件 # 全局配置 global: scrape_interval: 15s # 多久 收集 一次数据 evaluation_interval: 30s # ...
- I/O模型之三:两种高性能 I/O 设计模式 Reactor 和 Proactor
目录: <I/O模型之一:Unix的五种I/O模型> <I/O模型之二:Linux IO模式及 select.poll.epoll详解> <I/O模型之三:两种高性能 I ...
- LFYZ-OJ ID: 1028 背包问题
背包问题 题目描述 简单的背包问题.设有一个背包,可以放入的重量为s.现有n件物品,重量分别为w1,w2-,wn,(1≤i≤n)均为正整数,从n件物品中挑选若干件,使得放入背包的重量之和正好为s.找到 ...
- 第四节:SignalR灵魂所在Hub模型及再探聊天室样例
一. 整体介绍 本节:开始介绍SignalR另外一种通讯模型Hub(中心模型,或者叫集线器模型),它是一种RPC模式,允许客户端和服务器端各自自定义方法并且相互调用,对开发者来说相当友好. 该节包括的 ...
- 第六节:SignalR完结篇之依赖注入和分布式部署
一. SignalR中DI思想的应用 DI,即依赖注入,它是一种不负责创建其自己的依赖项对象的一种模式,通常用来降低代码之间的耦合性,广泛应用于架构设计,是必不可少的一种思想. 下面结合一个需求来说一 ...