通過在模型級別使用觸發器,對於指示的數據量,運行時間減少到幾分鐘。該觸發器觸發使用了精確的在線REST API來檢索的GL交易信息總結數量SQL語句:
create or replace table [email protected]
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", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & m$11)' assortment_glcosts_code_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & n$11)' assortment_glcosts_type_att
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & o$11)' assortment_glcosts_balanceside_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & p$11)' assortment_glcosts_balancetype_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & q$11)' assortment_glcosts_description
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & r$11)' assortment_glpurchase_code_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & s$11)' assortment_glpurchase_type_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & t$11)' assortment_glpurchase_balanceside_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & u$11)' assortment_glpurchase_balancetype_attr
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & v$11)' assortment_glpurchase_description
, '=i_sql_select_scalar("qty", "[email protected]", "itemcode=' || chr(39) || '" & $C{D,.,.,^,.} & "' || chr(39) || ' and mnd = " & w$11)' assortment_glpurchasepricedifference_code_attr
, '=i_sql_select_scalar("qty", "[email protected]", "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
之類的公式中,強制將所有項目作爲評估的第一個公式中的一個大批次加載到內存中。儘管計算第一個公式需要更長的時間,但它的速度要快得多。現在大約需要1分鐘時間才能在Excel中填寫項目信息,而不是每個項目750個檢索項目(XML API有時每個項目最多需要600 ms)。