39的天空
===========================================================
===========================================================

客户的要求:按销售订单统计这张单是否赚了。

怎么做哪?做报表吧


关于B1的两个功能(一)按BOM清单展开

适用环境:
人工的去展开BOM
CREATE function f_pcode1(@code varchar(20))
returns @re1 table(code varchar(20),father varchar(20),uom varchar(5),quantity float,level1 int)
as
begin
declare @l int
declare @father varchar(20)
declare @uom varchar(5)
declare @quantity float
set @l=0
insert @re1 select @code,@father,@uom,@quantity,@l
while @@rowcount>0
begin
set @l=@l+1
insert @re1(code,father,uom,quantity,level1) select a.code,a.father,a.uom,a.quantity,@l
from itt1 a,@re1 b
where a.father=b.code collate database_default
and b.level1=@l-1
end
return
end


用这个SQL我实现了这样一种功能:按销售订单查询成品的标准BOM清单,并计算需求。
输入成品的料号
输出父料号、子料号、单位、用量、BOM级别

关于B1的两个功能(二)按销售订单展开生产订单的用料清单

简单的说:就是输出一个销售订单销售物料的生产订单用料清单
CREATE function f_wo(@code_a varchar(20),@code_b varchar(20))
returns @re1 table(DocEntry int,code varchar(20),father varchar(20),uom varchar(5), PlannedQty float,IssuedQty float,level1 int)
as
begin
declare @l int
DECLARE @DocEntry INT
declare @father varchar(20)
declare @code varchar(20)
declare @IssuedQty float
declare @PlannedQty float
declare @re2 TABLE (DocEntry int,code varchar(20),father varchar(20), PlannedQty float,IssuedQty float,OriginNum int)

insert @re2(DocEntry,code,father,PlannedQty,IssuedQty,OriginNum) SELECT DiSTinct T1.DocEntry,T1.ItemCode, T0.ItemCode,T1.PlannedQty, T1.IssuedQty ,T0.OriginNum from OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry where t0.OriginNum = @code_a

set @l=0
insert @re1(code,father,PlannedQty,IssuedQty,level1) select @code_b,@father,@PlannedQty,@IssuedQty,@l
while @@rowcount>0
begin
set @l=@l+1
insert @re1(DocEntry,code,father,IssuedQty,PlannedQty,level1) select DiSTinct a.DocEntry,a.code,a.father,a.IssuedQty,a.PlannedQty,@l
from @re2 a,@re1 b
where a.father=b.code collate database_default
and b.level1=@l-1
end
return
end
--------------
这个就是按单生产的SQL。
输入项目:销售订单号、销售订单销售的成品料号。
输出:
生产订单号
料号
父料号
发出数量
计划数量
BOM级别


由以上的两个功能可以开发出:按销售订单生产、计划的功能。

W39 发表于:2007.01.26 20:31 ::分类: ( W39的原创集 ) ::阅读:(668次) :: 评论 (2)
re: 两个B1相关的SQL,订单查询 [回复]

弱弱的问一句,B1有没有类似于R/3的获利能力分析(CO-PA)?

wangyuzhen 评论于: 2007.01.28 01:03
re: 两个B1相关的SQL,订单查询 [回复]

B1不是R3,没有这部分的功能。
当然,要是简单分析原料成本啥的,可以做报表。
别把B1想的那么强大

W39 评论于: 2007.01.30 11:05

发表评论
标题

在此添加评论
表情符号: smile laughing tongue angry crying sad wassat wink

称呼

邮箱地址(可选)

个人主页(可选)

 authimage


自我介绍
切换风格
新闻聚合
博客日历
文章归档...
最新发表...
博客统计...
Blog信息
网站链接...