I_TaxItemProcessFlow

DDL: I_TAXITEMPROCESSFLOW Type: view_entity COMPOSITE

Tax Item Process Flow

I_TaxItemProcessFlow is a Composite CDS View that provides data about "Tax Item Process Flow" in SAP S/4HANA. It reads from 32 data sources and exposes 170 fields with key fields SAPObjectType, TaxFlowNodeReference, TaxFlowNodeReference, TaxFlowNodeReference, TaxFlowNodeReference.

Data Sources (32)

SourceAliasJoin Type
I_StRpRunDetails ACR inner
I_BillingDocument Billing inner
I_JournalEntry JournalEntry inner
I_JournalEntry JournalEntry inner
I_OperationalAcctgDocItem OperationalAcctgDoc inner
I_OperationalAcctgDocItem OperationalAcctgDoc inner
I_OperationalAcctgDocItem OperationalAcctgDoc inner
I_OperationalAcctgDocItem OperationalAcctgDoc inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SAPObjectType SAPObjectType inner
I_SupplierInvoice SupplierInvoice inner
I_TransactionalTaxItem Taxitem from
I_TransactionalTaxItem Taxitem union_all
I_TransactionalTaxItem Taxitem union_all
I_TransactionalTaxItem TaxItem union_all
I_TransactionalTaxItem Taxitem union_all
I_TransactionalTaxItem Taxitem union_all
I_TransactionalTaxItem Taxitem union_all
I_TransactionalTaxItem Taxitem union_all
I_TransactionalTaxItem Taxitem union_all
I_TaxPayableDocument TaxPayableDocument inner
I_TaxPayableDocument TaxPayableDocument inner
I_TaxPayableDocument TaxPayableDocument inner
I_TaxPayableDocument TaxPayableDocument inner
I_TaxPayableDocument TaxPayableDocument inner

Annotations (9)

NameValueLevelField
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.dataClass #MIXED view
VDM.viewType #COMPOSITE view
VDM.lifecycle.contract.type #NONE view
EndUserText.label Tax Item Process Flow view
AccessControl.authorizationCheck #MANDATORY view
AccessControl.personalData.blocking #NOT_REQUIRED view

Fields (170)

KeyFieldSource TableSource FieldDescription
KEY SAPObjectType I_SAPObjectType SAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeStatus
TaxFlowNodeDate
TaxFlowNodeCompanyCode
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType I_BillingDocument BillingDocumentType
SalesOrganization I_BillingDocument SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeStatus
TaxFlowNodeDate
TaxFlowNodeCompanyCode
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked I_SupplierInvoice IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeDate
TaxFlowNodeCompanyCode
TaxFlowNodeDateTime I_TransactionalTaxItem CreationDateTime
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeStatus I_StRpRunDetails StatryRptRunStatus
TaxFlowNodeCompanyCode
TaxFlowNodeDateTime I_StRpRunDetails StatryRptSubmittedDateTime
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory I_StRpRunDetails StatryRptCategory
StatryRptActivityUUID I_StRpRunDetails StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeDate
TaxFlowNodeCompanyCode
TaxFlowNodeDateTime
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeDate
TaxFlowNodeCompanyCode
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType I_JournalEntry AccountingDocumentType
TaxFlowNodeDate
TaxFlowNodeCompanyCode
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction I_TaxPayableDocument IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeStatus
TaxFlowNodeDate
TaxFlowNodeCompanyCode
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
SAPObjectTypeasSAPObjectType
KEY TaxFlowNodeReference
TaxFlowNodeYear
AccountingDocumentType
TaxFlowNodeStatus
TaxFlowNodeDate
TaxFlowNodeCompanyCode
AccountingDocument I_TransactionalTaxItem AccountingDocument
FiscalYear I_TransactionalTaxItem FiscalYear
CompanyCode I_TransactionalTaxItem CompanyCode
TaxItemUUID I_TransactionalTaxItem TaxItemUUID
TaxCountry I_TransactionalTaxItem TaxCountry
TaxationType I_TransactionalTaxItem TaxationType
StatryRptCategory
StatryRptActivityUUID
IntercompanyTransaction I_TaxPayableDocument IntercompanyTransaction
BillingDocumentType
SalesOrganization
IsEndOfPurposeBlocked
TxPyblBizPurposeIsCompleted
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType: {
                         sizeCategory: #XXL,
                         serviceQuality: #C,
                         dataClass: #MIXED
                         }

@VDM: {
    viewType: #COMPOSITE,
    lifecycle.contract.type: #NONE
    }
@EndUserText.label: 'Tax Item Process Flow'
@AccessControl: {
    authorizationCheck: #MANDATORY,
    personalData.blocking: #NOT_REQUIRED
    }
define view entity I_TaxItemProcessFlow
  as select from I_TransactionalTaxItem as Taxitem
    inner join   I_BillingDocument      as Billing       on Taxitem.SourceReferenceDocument = Billing.BillingDocument
    inner join   I_SAPObjectType        as SAPObjectType on SAPObjectType.SAPObjectType = 'BillingDocument'

{

  key  SAPObjectType.SAPObjectType                                                            as SAPObjectType,
  key  cast( Taxitem.SourceReferenceDocument as txrg_taxflow_reference )                      as TaxFlowNodeReference,
       cast( Billing.FiscalYear as txrg_taxflow_year  preserving type )                       as TaxFlowNodeYear,
       cast( '' as farp_blart )                                                               as AccountingDocumentType,
       cast( 'PO' as txrg_taxflow_status )                                                    as TaxFlowNodeStatus,
       cast( Billing.BillingDocumentDate as txrg_taxflow_date  preserving type )              as TaxFlowNodeDate,
       cast( Billing.CompanyCode as txrg_taxflow_companycode  preserving type )               as TaxFlowNodeCompanyCode,
       cast( dats_tims_to_tstmp( Billing.CreationDate ,
                          Billing.CreationTime,
                          abap_system_timezone( $session.client,'NULL' ),
                          $session.client,
                         'NULL' ) as txrg_taxflow_timestamp  )                                as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                             as AccountingDocument,
       Taxitem.FiscalYear                                                                     as FiscalYear,
       Taxitem.CompanyCode                                                                    as CompanyCode,
       Taxitem.TaxItemUUID                                                                    as TaxItemUUID,
       Taxitem.TaxCountry                                                                     as TaxCountry,
       Taxitem.TaxationType                                                                   as TaxationType,
       cast( '' as srf_rep_cat_id )                                                           as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type ) as StatryRptActivityUUID,
       cast( '' as bvorg )                                                                    as IntercompanyTransaction,
       Billing.BillingDocumentType                                                            as BillingDocumentType,
       Billing.SalesOrganization                                                              as SalesOrganization,
       @Semantics.booleanIndicator : true
       cast( '' as eopblocked  )                                                              as IsEndOfPurposeBlocked,
       cast( '' as txrg_taxpybl_xblocked )                                                    as TxPyblBizPurposeIsCompleted
}
where
  Taxitem.SourceReferenceDocumentType = 'VBRK'


union all select from I_TransactionalTaxItem as Taxitem
  inner join          I_SupplierInvoice      as SupplierInvoice on  Taxitem.SourceReferenceDocument      = SupplierInvoice.SupplierInvoice
                                                                and Taxitem.SourceReferenceDocumentCntxt = SupplierInvoice.FiscalYear
  inner join          I_SAPObjectType        as SAPObjectType   on SAPObjectType.SAPObjectType = 'SupplierInvoice'

{
  key  SAPObjectType.SAPObjectType                                                            as SAPObjectType,
  key  cast( Taxitem.SourceReferenceDocument as txrg_taxflow_reference )                      as TaxFlowNodeReference,
       cast( SupplierInvoice.FiscalYear  as txrg_taxflow_year  preserving type )              as TaxFlowNodeYear,
       cast( '' as farp_blart )                                                               as AccountingDocumentType,
       'PO'                                                                                   as TaxFlowNodeStatus,
       cast( SupplierInvoice.DocumentDate as txrg_taxflow_date  preserving type )             as TaxFlowNodeDate,
       cast( SupplierInvoice.CompanyCode as txrg_taxflow_companycode  preserving type )       as TaxFlowNodeCompanyCode,
       cast( dats_tims_to_tstmp( SupplierInvoice.CreationDate ,
                                 cast( '000000' as abap.tims ),
                                 abap_system_timezone( $session.client,'NULL' ),
                                 $session.client,
                                 'NULL'
                               ) as txrg_taxflow_timestamp )                                  as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                             as AccountingDocument,
       Taxitem.FiscalYear                                                                     as FiscalYear,
       Taxitem.CompanyCode                                                                    as CompanyCode,
       Taxitem.TaxItemUUID                                                                    as TaxItemUUID,
       Taxitem.TaxCountry                                                                     as TaxCountry,
       Taxitem.TaxationType                                                                   as TaxationType,
       ''                                                                                     as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type ) as StatryRptActivityUUID,
       ''                                                                                     as IntercompanyTransaction,
       ''                                                                                     as BillingDocumentType,
       ''                                                                                     as SalesOrganization,
       SupplierInvoice.IsEndOfPurposeBlocked                                                  as IsEndOfPurposeBlocked,
       ''                                                                                     as TxPyblBizPurposeIsCompleted
}
where
  Taxitem.SourceReferenceDocumentType = 'RMRP'

union all select from I_TransactionalTaxItem as Taxitem
  inner join          I_SAPObjectType        as SAPObjectType on SAPObjectType.SAPObjectType = 'TransactionalTaxItem'

{
  key  SAPObjectType.SAPObjectType                                                            as SAPObjectType,
  key  cast( Taxitem.AccountingDocument as txrg_taxflow_reference )                           as TaxFlowNodeReference,
       cast( Taxitem.FiscalYear as txrg_taxflow_year  preserving type  )                      as TaxFlowNodeYear,
       cast( '' as farp_blart )                                                               as AccountingDocumentType,
       case when Taxitem.TaxLineItemPayableStatus = 'O'
                then 'OP'
            when Taxitem.TaxLineItemPayableStatus = 'R'
                then 'RE'
            else 'CL'
       end                                                                                    as TaxFlowNodeStatus,
       cast( Taxitem.PostingDate as txrg_taxflow_date  preserving type )                      as TaxFlowNodeDate,
       cast( Taxitem.CompanyCode as txrg_taxflow_companycode  preserving type )               as TaxFlowNodeCompanyCode,
       Taxitem.CreationDateTime                                                               as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                             as AccountingDocument,
       Taxitem.FiscalYear                                                                     as FiscalYear,
       Taxitem.CompanyCode                                                                    as CompanyCode,
       Taxitem.TaxItemUUID                                                                    as TaxItemUUID,
       Taxitem.TaxCountry                                                                     as TaxCountry,
       Taxitem.TaxationType                                                                   as TaxationType,
       ''                                                                                     as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type ) as StatryRptActivityUUID,
       ''                                                                                     as IntercompanyTransaction,
       ''                                                                                     as BillingDocumentType,
       ''                                                                                     as SalesOrganization,
       ''                                                                                     as IsEndOfPurposeBlocked,
       ''                                                                                     as TxPyblBizPurposeIsCompleted
}

union all select from I_TransactionalTaxItem as TaxItem
  inner join          I_StRpRunDetails       as ACR           on  TaxItem.AccountingDocument = ACR.AccountingDocument
                                                              and TaxItem.CompanyCode        = ACR.CompanyCode
                                                              and TaxItem.FiscalYear         = ACR.FiscalYear
  inner join          I_SAPObjectType        as SAPObjectType on SAPObjectType.SAPObjectType = 'StatutoryReportingTask'
{
  key  SAPObjectType.SAPObjectType                                             as SAPObjectType, //Temporary / to be confirmed

  key  cast( bintohex( ACR.StatryRptRunUUID ) as txrg_taxflow_reference )      as TaxFlowNodeReference, //StatryRptRunUUID

       cast( ACR.ReportingYear as txrg_taxflow_year preserving type )          as TaxFlowNodeYear,
       cast( '' as farp_blart )                                                as AccountingDocumentType,
       ACR.StatryRptRunStatus                                                  as TaxFlowNodeStatus,
       cast( tstmp_to_dats( ACR.StatryRptSubmittedDateTime,
                            abap_system_timezone( $session.client,'NULL' ),
                            $session.client,
                            'NULL' ) as txrg_taxflow_date preserving type)     as TaxFlowNodeDate,
       cast( TaxItem.CompanyCode as txrg_taxflow_companycode preserving type ) as TaxFlowNodeCompanyCode,
       ACR.StatryRptSubmittedDateTime                                          as TaxFlowNodeDateTime,
       TaxItem.AccountingDocument                                              as AccountingDocument,
       TaxItem.FiscalYear                                                      as FiscalYear,
       TaxItem.CompanyCode                                                     as CompanyCode,
       TaxItem.TaxItemUUID                                                     as TaxItemUUID,
       TaxItem.TaxCountry                                                      as TaxCountry,
       TaxItem.TaxationType                                                    as TaxationType,
       ACR.StatryRptCategory                                                   as StatryRptCategory,
       ACR.StatryRptActivityUUID                                               as StatryRptActivityUUID,
       ''                                                                      as IntercompanyTransaction,
       ''                                                                      as BillingDocumentType,
       ''                                                                      as SalesOrganization,
       ''                                                                      as IsEndOfPurposeBlocked,
       ''                                                                      as TxPyblBizPurposeIsCompleted
}
where
     ACR.StatryRptRunStatus = 'STG' //Submitted to Govt

  or ACR.StatryRptRunStatus = 'SOK' //Accepted by Govt

  or ACR.StatryRptRunStatus = 'SDE' //Declined by Govt



union all select from I_TransactionalTaxItem as Taxitem
  inner join          I_TaxPayableDocument   as TaxPayableDocument on  Taxitem.TaxPayableDocument     = TaxPayableDocument.TaxPayableDocument
                                                                   and Taxitem.TaxPayableDocumentYear = TaxPayableDocument.TaxPayableDocumentYear
  inner join          I_SAPObjectType        as SAPObjectType      on SAPObjectType.SAPObjectType = 'TransactionalTaxPayableDoc'

{
  key  SAPObjectType.SAPObjectType                                                            as SAPObjectType,
  key  cast( Taxitem.TaxPayableDocument as txrg_taxflow_reference )                           as TaxFlowNodeReference,
       cast( Taxitem.TaxPayableDocumentYear as txrg_taxflow_year preserving type )            as TaxFlowNodeYear,
       cast( '' as farp_blart )                                                               as AccountingDocumentType,
       case when Taxitem.TaxLineItemPayableStatus <> 'O'
                          then 'PO'
                          else 'PN'
                      end                                                                     as TaxFlowNodeStatus,
       cast( TaxPayableDocument.TaxPaymentDueDate as txrg_taxflow_date preserving type)       as TaxFlowNodeDate,
       cast( TaxPayableDocument.CompanyCode as txrg_taxflow_companycode preserving type )     as TaxFlowNodeCompanyCode,
       cast( TaxPayableDocument.CreationDateTime as txrg_taxflow_timestamp )                  as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                             as AccountingDocument,
       Taxitem.FiscalYear                                                                     as FiscalYear,
       Taxitem.CompanyCode                                                                    as CompanyCode,
       Taxitem.TaxItemUUID                                                                    as TaxItemUUID,
       Taxitem.TaxCountry                                                                     as TaxCountry,
       Taxitem.TaxationType                                                                   as TaxationType,
       ''                                                                                     as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type ) as StatryRptActivityUUID,
       ''                                                                                     as IntercompanyTransaction,
       ''                                                                                     as BillingDocumentType,
       ''                                                                                     as SalesOrganization,
       ''                                                                                     as IsEndOfPurposeBlocked,
       TaxPayableDocument.TxPyblBizPurposeIsCompleted                                         as TxPyblBizPurposeIsCompleted
}
where
  Taxitem.TaxPayableDocument is not initial

union all select from I_TransactionalTaxItem    as Taxitem
  inner join          I_TaxPayableDocument      as TaxPayableDocument  on  Taxitem.TaxPayableDocument     = TaxPayableDocument.TaxPayableDocument
                                                                       and Taxitem.TaxPayableDocumentYear = TaxPayableDocument.TaxPayableDocumentYear
  inner join          I_OperationalAcctgDocItem as OperationalAcctgDoc on  TaxPayableDocument.CompanyCode           = OperationalAcctgDoc.CompanyCode
                                                                       and TaxPayableDocument.AccountingDocument    = OperationalAcctgDoc.AccountingDocument
                                                                       and TaxPayableDocument.FiscalYear            = OperationalAcctgDoc.FiscalYear
                                                                       and OperationalAcctgDoc.FinancialAccountType = 'K'
  inner join          I_SAPObjectType           as SAPObjectType       on SAPObjectType.SAPObjectType = 'JournalEntry'

{

  key  SAPObjectType.SAPObjectType                                                                   as SAPObjectType,
  key  cast( TaxPayableDocument.AccountingDocument as txrg_taxflow_reference )                       as TaxFlowNodeReference,
       cast( TaxPayableDocument.FiscalYear as txrg_taxflow_year preserving type )                    as TaxFlowNodeYear,
       OperationalAcctgDoc._JournalEntry.AccountingDocumentType                                      as AccountingDocumentType,
       case when OperationalAcctgDoc.ClearingJournalEntry is initial
                   then 'OP'
                   else 'CL'
               end                                                                                   as TaxFlowNodeStatus,
       cast( OperationalAcctgDoc._JournalEntry.AccountingDocumentCreationDate as txrg_taxflow_date ) as TaxFlowNodeDate,
       cast( TaxPayableDocument.CompanyCode as txrg_taxflow_companycode preserving type )            as TaxFlowNodeCompanyCode,
       cast( dats_tims_to_tstmp( OperationalAcctgDoc._JournalEntry.AccountingDocumentCreationDate ,
                                 OperationalAcctgDoc._JournalEntry.CreationTime ,
                                 abap_system_timezone( $session.client,'NULL' ),
                                 $session.client,
                                 'NULL'
                               )  as txrg_taxflow_timestamp )                                        as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                                    as AccountingDocument,
       Taxitem.FiscalYear                                                                            as FiscalYear,
       Taxitem.CompanyCode                                                                           as CompanyCode,
       Taxitem.TaxItemUUID                                                                           as TaxItemUUID,
       Taxitem.TaxCountry                                                                            as TaxCountry,
       Taxitem.TaxationType                                                                          as TaxationType,
       ''                                                                                            as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type )        as StatryRptActivityUUID,
       ''                                                                                            as IntercompanyTransaction,
       ''                                                                                            as BillingDocumentType,
       ''                                                                                            as SalesOrganization,
       ''                                                                                            as IsEndOfPurposeBlocked,
       ''                                                                                            as TxPyblBizPurposeIsCompleted
}
where
  Taxitem.TaxPayableDocument is not initial

union all select from I_TransactionalTaxItem    as Taxitem
  inner join          I_TaxPayableDocument      as TaxPayableDocument  on  Taxitem.TaxPayableDocument     = TaxPayableDocument.TaxPayableDocument
                                                                       and Taxitem.TaxPayableDocumentYear = TaxPayableDocument.TaxPayableDocumentYear
  inner join          I_JournalEntry            as JournalEntry        on  Taxitem.CompanyCode                        = JournalEntry.CompanyCode
                                                                       and TaxPayableDocument.IntercompanyTransaction = JournalEntry.IntercompanyTransaction
  inner join          I_OperationalAcctgDocItem as OperationalAcctgDoc on  Taxitem.CompanyCode                      = OperationalAcctgDoc.CompanyCode
                                                                       and JournalEntry.AccountingDocument          = OperationalAcctgDoc.AccountingDocument
                                                                       and JournalEntry.FiscalYear                  = OperationalAcctgDoc.FiscalYear
                                                                       and OperationalAcctgDoc.FinancialAccountType = 'K'
  inner join          I_SAPObjectType           as SAPObjectType       on SAPObjectType.SAPObjectType = 'JournalEntry'

{

  key  SAPObjectType.SAPObjectType                                                            as SAPObjectType,
  key  cast( TaxPayableDocument.IntercompanyTransaction as txrg_taxflow_reference )           as TaxFlowNodeReference,
       cast( JournalEntry.FiscalYear as txrg_taxflow_year preserving type )                   as TaxFlowNodeYear,
       JournalEntry.AccountingDocumentType                                                    as AccountingDocumentType,
       case when OperationalAcctgDoc.ClearingJournalEntry is initial
                   then 'OP'
                   else 'CL'
               end                                                                            as TaxFlowNodeStatus,
       cast( JournalEntry.AccountingDocumentCreationDate as txrg_taxflow_date )               as TaxFlowNodeDate,
       cast( TaxPayableDocument.CompanyCode as txrg_taxflow_companycode preserving type )     as TaxFlowNodeCompanyCode,
       cast( dats_tims_to_tstmp( JournalEntry.AccountingDocumentCreationDate ,
                                 JournalEntry.CreationTime ,
                                 abap_system_timezone( $session.client,'NULL' ),
                                 $session.client,
                                 'NULL'
                               )  as txrg_taxflow_timestamp )                                 as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                             as AccountingDocument,
       Taxitem.FiscalYear                                                                     as FiscalYear,
       Taxitem.CompanyCode                                                                    as CompanyCode,
       Taxitem.TaxItemUUID                                                                    as TaxItemUUID,
       Taxitem.TaxCountry                                                                     as TaxCountry,
       Taxitem.TaxationType                                                                   as TaxationType,
       ''                                                                                     as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type ) as StatryRptActivityUUID,
       TaxPayableDocument.IntercompanyTransaction                                             as IntercompanyTransaction,
       ''                                                                                     as BillingDocumentType,
       ''                                                                                     as SalesOrganization,
       ''                                                                                     as IsEndOfPurposeBlocked,
       ''                                                                                     as TxPyblBizPurposeIsCompleted
}
where
      Taxitem.TaxPayableDocument                 is not initial
  and TaxPayableDocument.IntercompanyTransaction is not initial

union all select from I_TransactionalTaxItem    as Taxitem
  inner join          I_TaxPayableDocument      as TaxPayableDocument  on  Taxitem.TaxPayableDocument     = TaxPayableDocument.TaxPayableDocument
                                                                       and Taxitem.TaxPayableDocumentYear = TaxPayableDocument.TaxPayableDocumentYear
  inner join          I_OperationalAcctgDocItem as OperationalAcctgDoc on  TaxPayableDocument.CompanyCode           = OperationalAcctgDoc.CompanyCode
                                                                       and TaxPayableDocument.AccountingDocument    = OperationalAcctgDoc.AccountingDocument
                                                                       and TaxPayableDocument.FiscalYear            = OperationalAcctgDoc.FiscalYear
                                                                       and OperationalAcctgDoc.FinancialAccountType = 'K'
  inner join          I_SAPObjectType           as SAPObjectType       on SAPObjectType.SAPObjectType = 'JournalEntry'

{
  key  SAPObjectType.SAPObjectType                                                                     as SAPObjectType,
  key  cast( OperationalAcctgDoc.ClearingJournalEntry as txrg_taxflow_reference )                      as TaxFlowNodeReference,
       cast( OperationalAcctgDoc.ClearingJournalEntryFiscalYear as txrg_taxflow_year preserving type ) as TaxFlowNodeYear,
       OperationalAcctgDoc._ClearingJournalEntry.AccountingDocumentType                                as AccountingDocumentType,
       'CL'                                                                                            as TaxFlowNodeStatus,
       cast( OperationalAcctgDoc.ClearingDate as txrg_taxflow_date preserving type)                    as TaxFlowNodeDate,
       cast( OperationalAcctgDoc.CompanyCode as txrg_taxflow_companycode preserving type )             as TaxFlowNodeCompanyCode,
       cast( dats_tims_to_tstmp( OperationalAcctgDoc._ClearingJournalEntry.AccountingDocumentCreationDate ,
                          OperationalAcctgDoc._ClearingJournalEntry.CreationTime ,
                          abap_system_timezone( $session.client,'NULL' ),
                          $session.client,
                         'NULL' )  as txrg_taxflow_timestamp )                                         as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                                      as AccountingDocument,
       Taxitem.FiscalYear                                                                              as FiscalYear,
       Taxitem.CompanyCode                                                                             as CompanyCode,
       Taxitem.TaxItemUUID                                                                             as TaxItemUUID,
       Taxitem.TaxCountry                                                                              as TaxCountry,
       Taxitem.TaxationType                                                                            as TaxationType,
       ''                                                                                              as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type )          as StatryRptActivityUUID,
       ''                                                                                              as IntercompanyTransaction,
       ''                                                                                              as BillingDocumentType,
       ''                                                                                              as SalesOrganization,
       ''                                                                                              as IsEndOfPurposeBlocked,
       ''                                                                                              as TxPyblBizPurposeIsCompleted
}
where
      Taxitem.TaxPayableDocument               is not initial
  and OperationalAcctgDoc.ClearingJournalEntry is not initial

union all select from I_TransactionalTaxItem    as Taxitem
  inner join          I_TaxPayableDocument      as TaxPayableDocument  on  Taxitem.TaxPayableDocument     = TaxPayableDocument.TaxPayableDocument
                                                                       and Taxitem.TaxPayableDocumentYear = TaxPayableDocument.TaxPayableDocumentYear
  inner join          I_JournalEntry            as JournalEntry        on  Taxitem.CompanyCode                        = JournalEntry.CompanyCode
                                                                       and TaxPayableDocument.IntercompanyTransaction = JournalEntry.IntercompanyTransaction
  inner join          I_OperationalAcctgDocItem as OperationalAcctgDoc on  Taxitem.CompanyCode                      = OperationalAcctgDoc.CompanyCode
                                                                       and JournalEntry.AccountingDocument          = OperationalAcctgDoc.AccountingDocument
                                                                       and JournalEntry.FiscalYear                  = OperationalAcctgDoc.FiscalYear
                                                                       and OperationalAcctgDoc.FinancialAccountType = 'K'
  inner join          I_SAPObjectType           as SAPObjectType       on SAPObjectType.SAPObjectType = 'JournalEntry'

{
  key  SAPObjectType.SAPObjectType                                                                     as SAPObjectType,
  key  cast( OperationalAcctgDoc.ClearingJournalEntry as txrg_taxflow_reference )                      as TaxFlowNodeReference,
       cast( OperationalAcctgDoc.ClearingJournalEntryFiscalYear as txrg_taxflow_year preserving type ) as TaxFlowNodeYear,
       OperationalAcctgDoc._ClearingJournalEntry.AccountingDocumentType                                as AccountingDocumentType,
       'CL'                                                                                            as TaxFlowNodeStatus,
       cast( OperationalAcctgDoc.ClearingDate as txrg_taxflow_date preserving type)                    as TaxFlowNodeDate,
       cast( OperationalAcctgDoc.CompanyCode as txrg_taxflow_companycode preserving type )             as TaxFlowNodeCompanyCode,
       cast( dats_tims_to_tstmp( OperationalAcctgDoc._ClearingJournalEntry.AccountingDocumentCreationDate ,
                          OperationalAcctgDoc._ClearingJournalEntry.CreationTime ,
                          abap_system_timezone( $session.client,'NULL' ),
                          $session.client,
                         'NULL' )  as txrg_taxflow_timestamp )                                         as TaxFlowNodeDateTime,
       Taxitem.AccountingDocument                                                                      as AccountingDocument,
       Taxitem.FiscalYear                                                                              as FiscalYear,
       Taxitem.CompanyCode                                                                             as CompanyCode,
       Taxitem.TaxItemUUID                                                                             as TaxItemUUID,
       Taxitem.TaxCountry                                                                              as TaxCountry,
       Taxitem.TaxationType                                                                            as TaxationType,
       ''                                                                                              as StatryRptCategory,
       cast( hextobin('00000000000000000000000000000000') as /bobf/conf_key preserving type )          as StatryRptActivityUUID,
       TaxPayableDocument.IntercompanyTransaction                                                      as IntercompanyTransaction,
       ''                                                                                              as BillingDocumentType,
       ''                                                                                              as SalesOrganization,
       ''                                                                                              as IsEndOfPurposeBlocked,
       ''                                                                                              as TxPyblBizPurposeIsCompleted
}
where
      Taxitem.TaxPayableDocument                 is not initial
  and TaxPayableDocument.IntercompanyTransaction is not initial
  and OperationalAcctgDoc.ClearingJournalEntry   is not initial