========================

目录:

1、直接SQL报表

========================

1、直接SQL报表

以BOM成本报表为例,在销售模块部署,需要购买【金蝶 K3 BOS集成开发工具】使用许可

I、本报表采用存储过程的形式编写,需要在数据库执行存储过程。

/****** Object:  StoredProcedure [dbo].[pro_bobang_BOMCost]    Script Date: 07/29/2015 16:09:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
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 'BOM000001','BOM000001'
--exec pro_bobang_BOMCost '*FBomNumber*','#FBomNumber#'

II、打开【金蝶K3 BOS集成开发工具】- - 【销售管理】- - 【直接SQL报表】,新建直接SQL报表。

III、打开报表向导。

IV、点击关键字维护,添加过滤条件关键字*FBomNumber*、#FBomNumber#。,并输入生成报表的SQL语句

V、报表标题默认显示,和字段名称一样,是英文名称,修改报表标题为中文名称显示。

技巧性:在存储过程最后显示结果集,可以直接给字段加上中文别名,这样此处就不需要再去修改报表标题。

VI、报表测试如下:

VII、发布到主控台,发布位置【销售管理】- - 【报表分析】。

VIII、在主控台查看发布结果。

六、K3 WISE 开发插件《直接SQL报表开发新手指导 - BOM成本报表》的更多相关文章

  1. 十、K3 WISE 开发插件《SQL Profiler跟踪单据操作时产生的SQL语句》

    =================================== 目录: 1.查询帐套的数据库DBID 2.配置需要跟踪数据库的DBID 3.配置跟踪参数 4.跟踪进行 5.分析跟踪语句 === ...

  2. K3 WISE 开发插件《SQL语句WHERE查询-范围查询/模糊查询》

    0.存储过程开头变量定义 @FBeginDate varchar(10), --单据起始日期 @FEndDate varchar(10), --单据截止日期. @FItemID varchar(50) ...

  3. 十三、K3 WISE 开发插件《SQL语句WHERE查询-范围查询/模糊查询》

    0.存储过程开头变量定义 ), --单据起始日期 ), --单据截止日期. ), ), ), ), ) @FType varchar(50),  --单据类型@FBillNo varchar(50), ...

  4. 四、K3 WISE 开发插件《工业单据老单插件开发新手指导》

    开发环境:K/3 Wise 13.0.K/3 Bos开发平台.Visual Basic 6.0 =============================================== 目录 一 ...

  5. 金蝶K3 wise 插件二次开发与配置

    金蝶K3 wise 插件二次开发与配置 开发环境:K/3 Wise 13.0.K/3 Bos开发平台.Visual Basic 6.0 目录 一.二次开发插件编程二.代码演示三.配置插件四.测试插件五 ...

  6. 五、K3 WISE 开发插件《K3 Wise 群发短信配置开发(二)之短信群发配置》

    开发环境:K/3 Wise 13.0.Sql Server 2005 目录 一.开启Sql Server Agent代理服务 二.短信发送原理 三.编写存储过程 四.开启Sql Server作业 一. ...

  7. 九、K3 WISE 开发插件《工业单据老单序时薄插件工具栏按钮开发实例》

    =============================== 目录: 1.添加工具栏按钮 2.查询被添加工具栏按钮的业务单据的FMenuID和FID 3.添加工具栏按钮和业务单据的映射关系 4.工具 ...

  8. 三、K3 Cloud 开发插件《K3 Cloud插件开发新手指导 + K3 Cloud插件开发代码调试》

    案例需求:在销售订单上新增一个按钮,在订单明细中新增一个字段,命名[即时库存]. 点击按钮,弹出“Hello World!”,并获取订单明细物料的即时库存,填入字段[即时库存]. 开发工具:Visua ...

  9. pl/sql developer开发工具的beautifier美化插件

    对于存储过程中需要编写大量的sql语句,这必然需要美化语句,使得程序可读性更高. pl/sql developer开发工具自带美化工具,不过美化的时候容易使得语句全部改变成大写格式,这样就需要一个插件 ...

随机推荐

  1. Python——signal

    该模块为在Python中使用信号处理句柄提供支持.下面是一些使用信号和他们的句柄时需要注意的事项: 除了信号 SIGCHLD 的句柄遵从底层的实现外,专门针对一个信号的句柄一旦设置,除非被明确地重置, ...

  2. 设计模式1-单例模式(Singletion)

    单例模式(Singletion):保证一个类仅有一个实例,并提供一个访问该实例的全局访问点. 单例模式主要作用是保证唯一的实例,可以严格地控制客户端怎样访问该实例以及何时访问它.可以简单的理解为对唯一 ...

  3. 学习TensorFlow的tf.concat使用

    https://www.tensorflow.org/api_docs/python/tf/concat

  4. Xming导致的SecureCRT远程登录的普通用户图形程序不能运行

    SecureCRT+Xming,用惯之后感觉特别方便,就是绘制效率稍差,不过可以忍受. 但是今天发生奇怪错误: 启动liteide后一切正常,但是选择打开目录菜单后就崩溃退出: 重新连接没用: 重新连 ...

  5. 安卓开发笔记——Menu菜单组件(选项菜单,上下文菜单,子菜单)

    菜单是用户界面中最常见的元素之一,使用非常频繁,在Android中,菜单被分为如下三种,选项菜单(OptionsMenu).上下文菜单(ContextMenu)和子菜单(SubMenu). 菜单的实现 ...

  6. linux cfs调度器_模型实现

    调度器真实模型的主要成员变量及与抽象模型的对应关系 I.cfs_rq结构体    a) struct sched_entity *curr        指向当前正在执行的可调度实体.调度器的调度单位 ...

  7. 在selenium中使用css选择器进行元素定位

    Sizzle Css3还提供一些直接选取form表单元素的伪类 :input: Finds all input elements (includes textareas, selects, and b ...

  8. 【VirtualBox】共享文件夹失效问题

    fix: sudo ln -f -s /opt/VBoxGuestAdditions-5.1.20/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vb ...

  9. UGUI之不规则按钮的响应区域

    比如一些不规则按钮最好可以设置它的响应区域.如下图所示,用Polygon Collider2D组件圈出精灵响应事件的区域. 注意 IsRaycastLocationValid 的判断区域是RectTr ...

  10. html 内联函数宽度设置

    width and/or height in tables are not standard anymore; as Ianzz says, they are depreciated. Instead ...