销售交易的许多Exact Online excel公式的性能

时间:2016-12-01 15:17:03

标签: sql exact-online invantive-sql invantive-control

我们有一张Excel电子表格,其中包含所有财务期间(13年,一年加一个月),并垂直列出商品代码。使用Exact Online中的总帐交易,交叉单元格包含文章该期间的已售数量。

通过以下查询填写商品代码,库存数量和销售清单:

select code_attr
,      '=i_eol_itm_description(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' rownum
,      '=I_EOL_ITM_SALES_PRICE_VALUE(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' dateend
,      '=I_EOL_ITM_COSTS_PRICE_VALUE(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' datestart
,      '=I_EOL_ITM_SALES_UNIT_DESCRIPTION(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' assortment_glrevenue_code_attr
,      '=$C{D,.,.,.+2,.}-$C{D,.,.,.+1,.}'                             assortment_glrevenue_type_attr
,      '=0' assortment_glrevenue_balanceside_attr
,      '=I_EOL_STOCK_CURRENT_QUANTITY(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")'   ispurchaseitem
,      '=I_EOL_STOCK_PLANNING_IN(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")'        issalesitem
,      '=I_EOL_STOCK_PLANNING_OUT(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")'       isstockitem
,      '=I_EOL_STOCK_PROJECTED_QUANTITY(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")' assortment_glrevenue_balancetype_attr
,      '=$C{D,.,.,.-1,.}*$C{D,.,.,.-5,.}' assortment_glrevenue_description
...
from   exactonlinexml..items
order
by     code_attr

有750篇文章和13个期间,总帐交易被访问了数千次。在查找文章交易时,通过XML API检索Exact Online中的总帐交易信息的速度很慢,因为您需要首先下载销售日记帐的所有交易,然后过滤掉那些没有文章代码(50%)的交易,并将它们相加销售数量。

运行时间为45分钟,甚至在Exact Online API缓慢时更糟。

如何缩短填写电子表格所需的时间?

1 个答案:

答案 0 :(得分:0)

通过在模型级别使用触发器,指示数据量的运行时间减少到几分钟。此触发器触发SQL语句,该语句使用Exact Online REST API来检索总计GL事务信息的数量:

create or replace table itmrev@inmemorystorage 
as
select itemcode
,      mnd
,      sum(qty) qty
from   ( select itemcode
         ,      year(date) * 12 + month(date) mnd
         ,      quantity qty
         from   TransactionLines
         where  journalcode = '70'
         and    itemcode is not null
         and    date > to_date('20160101', 'yyyymmdd')
       )
group 
by     itemcode
,      mnd

然后,我没有使用Excel I_EOL_GLTXN公式,而是使用了以下公式:

select code_attr
,      '=i_eol_itm_description(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' rownum
,      '=I_EOL_ITM_SALES_PRICE_VALUE(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' dateend
,      '=I_EOL_ITM_COSTS_PRICE_VALUE(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' datestart
,      '=I_EOL_ITM_SALES_UNIT_DESCRIPTION(eoldivision,$C{D,.,.,^,.},"ALL_ROWS")' assortment_glrevenue_code_attr
,      '=$C{D,.,.,.+2,.}-$C{D,.,.,.+1,.}'                             assortment_glrevenue_type_attr
,      '=0' assortment_glrevenue_balanceside_attr
,      '=I_EOL_STOCK_CURRENT_QUANTITY(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")'   ispurchaseitem
,      '=I_EOL_STOCK_PLANNING_IN(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")'        issalesitem
,      '=I_EOL_STOCK_PLANNING_OUT(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")'       isstockitem
,      '=I_EOL_STOCK_PROJECTED_QUANTITY(eoldivision,$C{D,.,.,^,.},,"ALL_ROWS")' assortment_glrevenue_balancetype_attr
,      '=$C{D,.,.,.-1,.}*$C{D,.,.,.-5,.}' assortment_glrevenue_description
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & m$11)' assortment_glcosts_code_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & n$11)' assortment_glcosts_type_att
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & o$11)' assortment_glcosts_balanceside_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & p$11)' assortment_glcosts_balancetype_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & q$11)' assortment_glcosts_description
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & r$11)' assortment_glpurchase_code_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & s$11)' assortment_glpurchase_type_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & t$11)' assortment_glpurchase_balanceside_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & u$11)' assortment_glpurchase_balancetype_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & v$11)' assortment_glpurchase_description
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & w$11)' assortment_glpurchasepricedifference_code_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & x$11)' assortment_glpurchasepricedifference_type_attr
,      '=SUM($C{D,.,.,.-12,.}:$C{D,.,.,.-1,.})' assortment_glpurchasepricedifference_balanceside_attr
,      '=$C{D,.,.,.-1,.}/12' assortment_glpurchasepricedifference_balancetype_attr
from   exactonlinexml..items
order
by     code_attr

i_sql_select_scalar从小表中检索具有总计的精确在线销售数量。

添加all_rows作为I_EOL_STOCK_CURRENT_QUANTITY等公式的执行提示,强制所有项目作为评估的第一个公式上的一个大批量加载到内存中。虽然计算第一个公式需要更长的时间,但它在所有公式上都要快得多。而不是750个单独项目的检索(XML API有时需要600毫秒),现在大约需要1分钟才能在Excel中填写项目信息。