美文网首页
TaiWan Vat Declarition refactor

TaiWan Vat Declarition refactor

作者: leon_bc28 | 来源:发表于2018-04-18 16:12 被阅读0次

1. 现状

由于收到一个ATC issue:


image

在ADT中查看该CDS view的dependency analyzer:


image

access的db table 多达220!


image

超出了VDM CDS Metadata Checks (POC_ANNOTA) rule:
“Consumption view selects from 224 used tables (max allowed 100)”。
不过根据经验,猜测只有当access db超过200时才会报atc issue。

2.分析

当前cds 的架构如图:


CDS architecture.PNG

P_TW_TaxItemReversal 由P_TW_TaxItemConsume 和I_TW_TaxItemCube join而来。而 I_TW_TaxItemCube 本身又是从P_TW_TaxItemConsume 推演出来的,P_TW_TaxItemConsume 的复杂度被放大了2倍。

仔细看下业务逻辑:

  • P_TW_TaxItemReversal是为了按document class汇总生成pdf提供数据。
  • I_TW_TaxItemCube经过底层的计算已经得到了比较准确的document class以及其它一些信息,故可以保留这个cds view。但此cds view里面的凭证可能是reversal凭证,并不知道对应的原始凭证
  • join 另一边的P_TW_TaxItemConsume其实只是为了拿到reversal凭证对应的原始凭证

因此可以看出,P_TW_TaxItemConsume的目的只是为了带出bset中行项目上的ReverseDocument。这完全可以从bset 和bkpf推演出来而不用再去重复一遍P_TW_TaxItemConsume繁杂的推演逻辑。

解决

新的架构如下:


new CDS architecture.PNG

修改P_TW_TaxItemConsume:

define view P_TW_TaxItemConsume
  as select from I_TaxItem

{

  key CompanyCode,
  key AccountingDocument,
  key FiscalYear,
  key AccountingDocumentItem,
      case _AccountingDocument.IsReversal
        when 'X'
        then _AccountingDocument.ReverseDocument
        else _AccountingDocument.AccountingDocument
        end                                                                                               as OriginalDocument,
      case _AccountingDocument.IsReversal
      when 'X' then cast((cast(_AccountingDocument.ReverseDocumentFiscalYear as abap.int4) - 1911) as sstring)
      else cast((cast(_AccountingDocument.FiscalYear as abap.int4) - 1911) as sstring)
      end
                                                                                                          as OriginalDocumentTWYear,
      cast(decimal_shift( amount => TaxAmountInCoCodeCrcy,
      currency => CompanyCodeCurrency  ) as  abap.dec(12, 0))                                             as TaxAmount, // 9. Tax Amount
      cast(decimal_shift( amount => TaxBaseAmountInCoCodeCrcy,
      currency => CompanyCodeCurrency  ) as  abap.dec(12, 0))                                             as TaxBaseAmount

}

修改P_TW_TaxItemReversal, 去掉P_TW_TaxItemConsume的参数

define view P_TW_TaxItemReversal
  with parameters
    P_StatryRptgEntity  : srf_reporting_entity,
    P_StatryRptCategory : srf_rep_cat_id,
    P_StatryRptRunID    : srf_report_run_id,
    P_StatryRptRunType  : srf_report_run_type
  as select from P_TW_TaxItemConsume as taxItem
    inner join I_TW_TaxItemCube(
                    P_StatryRptgEntity  :$parameters.P_StatryRptgEntity ,
                    P_StatryRptCategory :$parameters.P_StatryRptCategory,                 
                    P_StatryRptRunID    :$parameters.P_StatryRptRunID,
                    P_StatryRptRunType  :$parameters.P_StatryRptRunType
                                                     )
                                            as cube on taxItem.CompanyCode             = cube.CompanyCode
                                            and taxItem.OriginalDocumentTWYear                = cube.TaiwaneseCalendarYear
                                            and taxItem.OriginalDocument                      = cube.AccountingDocument
                                            and taxItem.AccountingDocumentItem                = cube.AccountingDocumentItem
{
...
}

经过此次修改,dependency analyzer中查看cds C_TW_VATDeclarationItem 复杂度从220降为了119,应该可以通过atc check了


dependency AFTER.png

相关文章

网友评论

      本文标题:TaiWan Vat Declarition refactor

      本文链接:https://www.haomeiwen.com/subject/jgvvkftx.html