偷-classic
控制不允许超量转储方案
1.
2.
3.
4.
整理允许物料超量转储的物料
MPQ
的
excel
表
物料主数据
OITM
,新建字段
U_T022
是否允许超量转储,
Y
代表允许,
N
代表不允许
在数据库中导入临时表
MPQ
,即:将
Excel
表按照固定格式导入数据库 ,形成数据表
在数据库中,将
OITM
中将所有物料的的
U_T022,update
为
Y
,默认不允许超量转储
先查询
OITM
中对应物料的
U_T022
的值
Select de, t0.U_T022 ,de, from oitm t0 inner
join mpq t1 on de =de
再将
OITM
中对应物料的
U_T022
字段更新为
Y
Update
t0
set
t0.U_T022='Y'
from
oitm
t0
inner
join
mpq
t1
on
de=de
where de=de
5.
控制不允许超量发货的物料,若超量或超过指定的值不允许保存(合并)
--------------------
库存转储的数量不能大于对应转储请求的数量!( 合并控制)
-------------------------
IF
@object_type
=
'67'
and
@transaction_type
=
'A'
begin
declare
@linenum4
int
declare
@N
int
select
@linenum4
=
max
(
linenum
)
from
WTR1
where
docentry
=
@list_of_cols_val_tab_del
set
@N
=
0
while
@N
<
=
@linenum4
begin
declare
@baseentry2
int
declare
@baseline2
int
declare
@totalqtytr1
numeric
(
19
,2
)
---
转储总数量
declare
@quantitytq1
numeric
(
19
,2
)
---
库存转储请求数量
declare
@csb3
numeric
(
19
,
2
)
declare
@MPQ
int
-------
取转储单行表,基础凭证号,基础行号
select
@baseentry2
=
baseentry
,
@baseline2
=
baseline
from
WTR1
where
docentry
=
@list_of_cols_val_tab_del
and
linenum
=
@N
---
取相同基础凭证号,基础凭证行号的该物料的转储总计数量
select
@totalqtytr1
=
sum
(
t0
.
Quantity
)
from
WTR1
t0
INNER
JOIN
oitm
T1
ON
T0
.
itemcode
=
T1
.
itemcode
where
t0
.
BaseEntry
=
@baseentry2
and
t0
.
BaseLine
=
@baseline2
and
t0
.
LineStatus
=
'O'
and
t0
.
Quantity
>
'0'
----
取库存转储请求行中,该行物料的请求数量
select
@quantitytq1
=
T0
.
quantity
from
WTQ1
T0
INNER
JOIN
oitm
T1
ON
T0
.
itemcode
=
T1
.
itemcode
where
T0
.
docentry
=
@baseentry2
and
T0
.
linenum
=
@baseline2
----
取库存转储请求行中,该行物料的
MPQ
select
@MPQ
=
t4
.
MPQ
from
WTR1
t0
INNER
JOIN
oitm
T1
ON
T0
.
itemcode
=
T1
.
itemcode
inner
join
MPQ
T4
on
t0
.
ItemCode
=
t4
.
itemcode
where
t0
.
BaseEntry
=
@baseentry2
and
t0
.
BaseLine
=
@baseline2
if
isnull
(
@MPQ
,
0
)>
0
begin
if
ISNULL
(
@quantitytq1
,
0
)%
@MPQ
>=
1
begin
if
(
isnull
(
@totalqtytr1
,
0
)
>
isnull
(((
cast
(
I SNULL
(
@quantitytq1
,
0
)/
@MPQ
as
int
)+
1
)*
@MPQ
),
0
)
)
begin
select
@error
=
1
select
@error_message
=
N'
第
'< br>+
cast
((
@N
+
1
)
as
varchar
(
3
))+
N'
行
'
+
N'--'
+
N'
物料的 累计转储数量
'
+
convert
(
varchar
(20
),
@totalqtytr1
)+
'
,不能超过该物料的
MPQ
数量
'
+
convert(
varchar
(
20
),
@MPQ
)+
' !'
end
end
if
ISNULL
(
@quantitytq1
,
0
)%
@MPQ
<
1
begin
if
(
isnull
(
@totalqtytr1
,
0
)
>
isnull
(((
cast
(
I SNULL
(
@quantitytq1
,
0
)/
@MPQ
as
int
))*
@MPQ
),
0
)
)
begin
select
@error
=
1
select
@error_message
=
N'
第
'< br>+
cast
((
@N
+
1
)
as
varchar
(
3
))+
N'
行
'
+
N'--'
+
N'
物料的 累计转储数量
'
+
convert
(
varchar
(20
),
@totalqtytr1
)+
'
,不能超过该物料的
MPQ
数量
'
+
convert(
varchar
(
20
),
@MPQ
)+
' !'
end
end
end
if
isnull
(
@MPQ
,
0
)<=
0
begin
if
isnull
(
@totalqtytr1
,
0
)>
ISNULL
(
@quantitytq1
,
0
)
begin
select
@error
=
1
select
@error_message
=
N'
第
'
+
cast
((
@N
+
1< br>)
as
varchar
(
3
))+N'
行
'
+
N'--'
+
N'
物料的累计转储数量
'
+
convert
(
varc har
(
20
),
@totalqtytr1
)+
'
不能大于该物料行的库存转储请求数量
'
+
con vert
(
varchar
(
20
),
@quantity tq1
)+
'!'
end
end
set
@N
=
@N
+
1
end
end
不合并,分开控制
-------------- -
库存转储的数量不能大于对应转储请求的数量
IF
(
@object_type
=
'67'
AND
@transaction_type
IN
(
'A'
))
BEGIN
if
EXISTS(
select
1
from
WTR1
t0
inner
join
(
select
WTQ1
.DocEntry
,
WTQ1
.
LineNum
,
SU M
(
WTQ1
.
Quantity
)
请求数量
from
WTQ1
group
by
WTQ1
.
Doc Entry
,
WTQ1
.
LineNum
)
t1
on
t0
.
BaseEntry
=
t1
.
DocEntry
and
t0
.
BaseL ine
=
t1
.
LineNum
left
join
(
select
< br>WTR1
.
BaseEntry
,
WTR1
.
Bas eLine
,
SUM
(
WTR1
.
Quantity
)
已转数量
from
WTR1
where
WTR1
.
DocE ntry
<>
@list_of_cols_val_tab_del
and
WTR1
.
LineStatus
=
'O'
and
WTR1
.
Quantity
>
'0'
group
by
WTR1
.
BaseEntr y
,
WTR1
.
BaseLine
)
T2
on
t0
.
BaseEntry
=
T2
.
BaseEntry
and
t0
.
BaseLine
=
T2
.
BaseLine
inner
join
OITM
t3
on
t0
.
ItemCode
=
t3
.
ItemCode
where
t0
.
LineStatus
=
'O'
/* and ty >'0' */
and
t0
.
Doc Entry
=
@list_of_cols_val_tab_del
and
t0
.
Quantity
+
isnull
(
t2
.
已转数
量
,
0
)>
t1
.
请求数量
and
(
t3
.
U_T022
=
'N'
or
isnull
(
t3
.
U_T022,
''
)
=
''
)
)
begin
SET
@error
=
1
SET
@error_ message
=
'
库存转储的数量不能大于对应转储请求的数量!
'
SELECT
@error
,
@error_message
end
偷-classic
偷-classic
偷-classic
偷-classic
偷-classic
偷-classic
偷-classic
偷-classic
本文更新与2021-01-21 14:54,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/544625.html
-
上一篇:听英语讲座心得体会
下一篇:听英语歌有利于英语学习