- SAP Business one里如果启用了永续盘存,并且使用的移动平均的成本计价方式,建议对库存科目冻结手动过账,方式库存明细账跟科目余额不一致。
- 在SAP里对每个库存科目,勾上【冻结手动过账】如下图所示:
- 然后为了防呆,建议再从存储过程里增加控制。
- HANA版本的SQL代码:
----库存科目不允许手动过账
IF :object_type = N'1' and :transaction_type IN ('A','U') THEN
SELECT COUNT(*) INTO error
FROM OACT T0
WHERE T0."AcctCode" IN (
--物料组里设置的【库存科目】
SELECT DISTINCT "BalInvntAc" FROM OITB
UNION ALL
--仓库里设置的【库存科目】
SELECT DISTINCT "BalInvntAc" FROM OWHS
UNION ALL
--物料主数据的物料级别里设置的【库存科目】
SELECT DISTINCT "BalInvntAc" FROM OITW
)
AND T0."BlocManPos" <> 'Y';
IF error > 0
THEN
error := 1;
error_message := '[SBO_SP_OACT_Control]_101.库存科目必需勾选【冻结手动过账】,请核实!';
END IF;
END IF;
----库存重估不允许选择【冻结手动过账】的科目
IF :object_type = N'162' and :transaction_type IN ('A','U') THEN
SELECT COUNT(*) INTO error
FROM MRV1 T0
WHERE T0."DocEntry" = :list_of_cols_val_tab_del
AND
(
T0."RIncmAcct" IN (SELECT "AcctCode" FROM OACT WHERE "BlocManPos" = 'Y')
OR
T0."RDcrmAcct" IN (SELECT "AcctCode" FROM OACT WHERE "BlocManPos" = 'Y')
);
IF error > 0
THEN
error := 1;
error_message := '[SBO_SP_OMRV_Control]_101.【总账增加科目】和【总账减少科目】不得选择库存科目,请核实!';
END IF;
END IF;
- SQL版本的SQL代码:
----库存科目不允许手动过账
IF @object_type = N'1' AND @transaction_type IN ('A','U')
BEGIN
IF EXISTS (
SELECT 1
FROM OACT T0
WHERE T0."AcctCode" IN (
--物料组里设置的【库存科目】
SELECT DISTINCT "BalInvntAc" FROM OITB
UNION ALL
--仓库里设置的【库存科目】
SELECT DISTINCT "BalInvntAc" FROM OWHS
UNION ALL
--物料主数据的物料级别里设置的【库存科目】
SELECT DISTINCT "BalInvntAc" FROM OITW
)
AND T0."BlocManPos" <> 'Y')
BEGIN
SET @error = 1;
SET @error_message = '[SBO_SP_OACT_Control]_101.库存科目必需勾选【冻结手动过账】,请核实!';
END;
END;
----库存重估不允许选择【冻结手动过账】的科目
IF @object_type = N'162' and @transaction_type IN ('A','U')
BEGIN
IF EXISTS (
SELECT 1
FROM MRV1 T0
WHERE T0."DocEntry" = @list_of_cols_val_tab_del
AND
(
T0."RIncmAcct" IN (SELECT "AcctCode" FROM OACT WHERE "BlocManPos" = 'Y')
OR
T0."RDcrmAcct" IN (SELECT "AcctCode" FROM OACT WHERE "BlocManPos" = 'Y')
))
BEGIN
SET @error = 1;
SET @error_message = '[SBO_SP_OMRV_Control]_101.【总账增加科目】和【总账减少科目】不得选择库存科目,请核实!';
END;
END;
以上代码仅提供一种思路,请以实际情况为准!
标签:库存,T0,过账,B1,error,SAP,SELECT,科目 From: https://blog.csdn.net/IT_XBNMG/article/details/143707773