0

我们有一个 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 很慢时甚至更糟。

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

4

1 回答 1

0

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

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

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

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 毫秒),现在在 Excel 中填写项目信息大约需要 1 分钟。

于 2016-12-01T15:19:52.783 回答