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

Performance of many Exact Online excel formulas for sales transactions

我们有一个 Excel 价差 sheet,它在横向上考虑了所有财务周期(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 速度慢时更糟。

如何缩短填充价差所需的时间sheet?

通过在模型级别使用触发器,指定数据量的 运行 时间缩短为几分钟。此触发器触发 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)' assortment_glcosts_code_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & n)' assortment_glcosts_type_att
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & o)' assortment_glcosts_balanceside_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & p)' assortment_glcosts_balancetype_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & q)' assortment_glcosts_description
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & r)' assortment_glpurchase_code_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & s)' assortment_glpurchase_type_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & t)' assortment_glpurchase_balanceside_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & u)' assortment_glpurchase_balancetype_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & v)' assortment_glpurchase_description
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & w)' assortment_glpurchasepricedifference_code_attr
,      '=i_sql_select_scalar("qty", "itmrev@inmemorystorage", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & x)' 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 从带有总计的小 table 中检索准确的在线销售数量。

添加 all_rows 作为公式的执行提示,例如 I_EOL_STOCK_CURRENT_QUANTITY 强制所有项目作为第一个计算公式的一个大批量加载到内存中。虽然这需要更长的时间来计算第一个公式,但它比所有公式都要快得多。不再对单个项目进行 750 次检索(XML API 有时每次检索需要 600 毫秒),现在在 Excel 中填写项目信息大约需要 1 分钟。