不能使用重复的表名ct_fact_data

2020-09-24 12:51发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)您好,团队, 我正在尝试运行 ...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


您好,团队,


我正在尝试运行" CALL" MY_FC10_PROD"。" FC_CREATE_FACT_DATA"('ACTUAL','2017.01','MYCORP',' %','EUR',0)'并出现此问题:

无法执行'CALL" MY_FC10_PROD"。" FC_CREATE_FACT_DATA"('ACTUAL','2017.01','MYCORP','%', 'EUR',0)'在6.302秒内。
[129]:事务因内部错误而回滚:[129]" MY_FC10_PROD"。" FC_CREATE_FACT_DATA":第185行第3行(在pos 5846处):[129] (范围3):事务因内部错误而回滚:无法使用重复的表名:CT_FACT_DATA:第1行第56行(在pos 55)

您能帮忙吗?
谢谢

7条回答
亦是此间程序员
2020-09-24 13:32
执行"立即执行sQuery"时代码行接近结尾。  :

 其他
 sQuery:='重命名表'||  sWorkTable ||  'TO'||  :sTBL;
 立即执行查询;
 万一;



 所有过程在这里:



 建立程序FC_CREATE_FACT_DATA
 (
 在sCA NVARCHAR(12)默认值'%'中,
 在sDP NVARCHAR(12)默认值'%'中,
 在sSC NVARCHAR(12)默认值'%'中,
 在sVE NVARCHAR(12)默认值'%'中,
 在sCC NVARCHAR(12)默认值'%'中,
 IN nMode INT默认值0
 )
 语言SQLSCRIPT SQL安全定义AS
 开始
 DECLARE nCount INT:= 0;
 DECLARE nIndex1 INT:= 0;
 DECLARE nIndex2 INT:= 0;
 宣告nBound1 INT:= 0;
 宣告nBound2 INT:= 0;
 声明sWorkTable NVARCHAR(1024):='';
 DECLARE sColumn NVARCHAR(1024):='';
 DECLARE sColumns NVARCHAR(1024):='';
 声明sSQLStr1 NVARCHAR(1024):='';
 声明sSQLStr2 NVARCHAR(1024):='';
 DECLARE sQuery NCLOB:='';
 十进制sTBL NVARCHAR(128):='CT_FACT_DATA';

 如果nMode = 2 THEN
 从表中选择COUNT(table_name)INTO nCount where table_name = UPPER(:sTBL)AND schema_name = CURRENT_SCHEMA;
 如果nCount> 0 THEN
 立即执行'DROP TABLE'||  :sTBL;
 万一;
 从ct_fact_data_copy_log删除;
 万一;

 tbl_DetDimension =
 选择
 ROW_NUMBER()OVER(ORDER BY ct_order)AS row_id,
 UPPER(phys_name)AS物理名称
 从
 ct_datasource_dim
 哪里
 数据源= -524285 AND
 可选<> 0 AND
 尺寸不在(
 -524279,
 -524278,
 -524234,
 -524226)
 ORDER BY ct_order;


 tbl_Period =
 选择地区
 updper AS ID,
 TO_NVARCHAR(1900 + ROUND(updper/262144))||'。'|| LPAD(TO_NVARCHAR(TO_INT(MOD(updper,262144)/8192)),2,0)AS名称
 从
 ct_coref;


 tbl_ConsoRef =
 选择
 ROW_NUMBER()OVER(ORDER BY T01.phase,T01.updper)AS row_id,
 T01相
 T01.updper,
 T01.scope,
 T01.variant,
 T01.currency,
 'CT_CO'|| 案件
 当T01.id <= 999时LPAD(TO_NVARCHAR(T01.id),4,'0')
 否则TO_NVARCHAR(T01.id)
 END AS table_name,
 T02.task_date
 从
 ct_coref T01
 内联接ct_conso_def T02开
 T01.phase = T02.phase AND
 T01.updper = T02.updper与
 T01.variant = T02.variante AND
 T01.currency = T02.currency
 内联接ct_conso_def_per T03开启
 T01.scope = T03.scope_code与
 T02.main_period = T03.id
 左外连接ct_fact_data_copy_log T04开
 T01.phase = T04.phase AND
 T01.updper = T04.updper与
 T01.scope = T04.scope AND
 T01.variant = T04.variant AND
 T01.currency = T04.currency
 哪里
 T01.phase IN(从ct_phase的名称(如sCA)中选择SELECT ID)和
 T01.updper IN(SELECT id FROM:tbl_Period WHERE name like sDP)AND
 T01.scope IN(从ct_scope_code中选择的ID,名称类似于sSC)并且
 T01.variant IN(从ct_variant名称类似sVE的SELECT ID)和
 T01.currency IN(从ct_curncy的名称(类似于sCC)中选择SELECT)和
 (T02.task_date> T04.copy_date或T04.copy_date为NULL);


 SELECT COUNT(row_id)INTO nCount FROM:tbl_ConsoRef;
 如果nCount = 0,则
 返回;
 万一;


 从:tbl_DetDimension选择COUNT(row_id)到nBound1;
 FOR nIndex1 IN 1..nBound1 DO
 SELECT sColumns ||  phys_name ||  '#'INTO sColumns FROM:tbl_DetDimension WHERE row_id = nIndex1;
 结束于;


 sWorkTable:='TFACT_'||  SYSUUID;
 sQuery:=
 '创建列表[1]('||
 "相位INT,UPDPER INT,SCOPE INT,VARIANT INT,CONSCUR INT,PERIOD INT,实体INT,ENTORIG INT,ACCNT INT,FLOW INT,NATURE INT,CURNCY INT,
 " PARTNER INT,CTSHARE INT,[2] AMOUNT DOUBLE,CONVAMOUNT DOUBLE,CONSAMOUNT DOUBLE)分区(哈希(UPDPER,SCOPE,VARIANT)分区120);
 sQuery:=
 REPLACE(REPLACE(sQuery,
 '[1]',sWorkTable),
 '[2]',REPLACE(sColumns,'#','INT,'));
 立即执行查询;


 选择COUNT(row_id)INTO nBound1 FROM:tbl_ConsoRef;
 FOR nIndex1 IN 1..nBound1 DO
 tbl_Column =
 选择
 ROW_NUMBER()OVER()AS row_id,
 T01.column_name
 从
 table_columns T01
 内部联接:tbl_DetDimension T02 ON
 T01.column_name = T02.phys_name
 内部联接:tbl_ConsoRef T03 ON
 T01.table_name = T03.table_name
 哪里
 T03.row_id = nIndex1 AND
 T01.schema_name = CURRENT_SCHEMA;


 sQuery:=
 'INSERT INTO [1]'||
 '选择[2],期限,实体,ENTORIG,ACCNT,流程,自然,货币,合作伙伴,CTSHARE [3],SUM(AMOUNT),SUM(CONVAMOUNT),SUM(CONSAMOUNT)'||
 '从时间,实体,兴趣,ACCNT,流量,货币,自然,合作伙伴,共享份额[5]分组[5]';


 sSQLStr1:='';
 sSQLStr2:='';
 从:tbl_DetDimension选择COUNT(row_id)到nBound2;
 FOR nIndex2 IN 1..nBound2 DO


 SELECT phys_name INTO sColumn FROM:tbl_DetDimension WHERE row_id = nIndex2;
 SELECT COUNT(row_id)INTO nCount FROM:tbl_Column WHERE column_name = sColumn;
 如果nCount = 0,则
 sSQLStr1:= sSQLStr1 ||  ',0';
 其他
 sSQLStr1:= sSQLStr1 ||  ','||  sColumn;
 sSQLStr2:= sSQLStr2 ||  ','||  sColumn;
 万一;
 结束于;


 开始
 声明nPhase,nUpdper,nScope,nVariant,nConscur INT;
 DECLARE sTable NVARCHAR(128);

 SELECT阶段,updper,范围,变体,货币,table_name INTO nPhase,nUpdper,nScope,nVariant,nConscur,sTable
 来自:tbl_ConsoRef
 在哪里row_id = nIndex1;


 sQuery:= REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(sQuery,
 '[1]',sWorkTable),
 '[2]',TO_NVARCHAR(nPhase)||','|| TO_NVARCHAR(nUpdper)||','|| TO_NVARCHAR(nScope)||','|| TO_NVARCHAR(nVariant)||','||  TO_NVARCHAR(nConscur)),
 '[3]',sSQLStr1),
 '[4]',sTable),
 '[5]',sSQLStr2);

 立即执行查询;
 结束;
 结束于;


 从表中选择COUNT(table_name)INTO nCount where table_name = UPPER(:sTBL)AND schema_name = CURRENT_SCHEMA;


 如果:nCount> 0 THEN
 sQuery:='从'||删除 :sTBL ||'  WHERE(阶段,更新,范围,变体,同意)IN(SELECT DISTINCT阶段,更新,范围,变体,同意从'|| sWorkTable ||')';
 立即执行查询;


 sQuery:='插入到'||  :sTBL ||  'SELECT * FROM'||  sWorkTable;
 立即执行查询;

 sQuery:='DROP TABLE'||  sWorkTable;
 立即执行查询;

 其他
 sQuery:='重命名表'||  sWorkTable ||  'TO'||  :sTBL;
 立即执行查询;
 万一;


 从ct_fact_data_copy_log删除
 哪里
 (阶段,更新,范围,变体,货币)IN
 (SELECT阶段,更新,范围,变体,货币FROM:tbl_ConsoRef);
 插入ct_fact_data_copy_log(阶段,更新,范围,变体,货币,copy_date)
 选择
 相,
 updper,
 范围,
 变体
 货币,
 CURRENT_UTCTIMESTAMP
 从
 :tbl_ConsoRef;


 结束;
 

一周热门 更多>