H_HU_StRpInvoiceChainNode

DDL: H_HU_STRPINVOICECHAINNODE SQL: HHUSTRPINVCHNN Type: view Package: GLO_FIN_IS_VAT_HU

Hungary VAT: Definition Of Parent-Child Relationship

H_HU_StRpInvoiceChainNode is a CDS View of category Dimension that provides data about "Hungary VAT: Definition Of Parent-Child Relationship" in SAP S/4HANA. It reads from 2 data sources (I_JournalEntry, P_HU_STRPINVOICECOUNTRY) and exposes 16 fields with key fields CompanyCode, FiscalYear, AccountingDocument. It has 1 association to related views. Part of development package GLO_FIN_IS_VAT_HU.

Data Sources (2)

SourceAliasJoin Type
I_JournalEntry JournalEntry from
P_HU_STRPINVOICECOUNTRY P_HU_STRPINVOICECOUNTRY inner

Parameters (1)

NameTypeDefault
p_CompanyCode bukrs

Associations (1)

CardinalityTargetAliasCondition
[0..*] H_HU_StRpInvoiceChainNode _Recursion $projection.PreceedingInvoice = _Recursion.InvoiceNumber and $projection.CompanyCode = _Recursion.CompanyCode

Annotations (12)

NameValueLevelField
EndUserText.label Hungary VAT: Definition Of Parent-Child Relationship view
AbapCatalog.sqlViewName HHUSTRPINVCHNN view
ClientHandling.algorithm #SESSION_VARIABLE view
Analytics.dataCategory #DIMENSION view
ObjectModel.representativeKey Invoice view
AccessControl.authorizationCheck #NOT_ALLOWED view
ObjectModel.dataCategory #HIERARCHY view
AbapCatalog.preserveKey true view
AbapCatalog.compiler.compareFilter true view
ObjectModel.usageType.sizeCategory #S view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.dataClass #MIXED view

Fields (16)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_JournalEntry CompanyCode
KEY FiscalYear I_JournalEntry FiscalYear
KEY AccountingDocument I_JournalEntry AccountingDocument
ReferenceDocumentType I_JournalEntry ReferenceDocumentType
OriginalReferenceDocument I_JournalEntry OriginalReferenceDocument
LogicalSystem I_JournalEntry LogicalSystem
IssuedInvoiceGuid
InvoiceNumber
InvoiceDate I_JournalEntry JrnlEntryCntrySpecificDate4
TaxReportingDate I_JournalEntry TaxReportingDate
PostingDate I_JournalEntry PostingDate
DocumentDate I_JournalEntry DocumentDate
TaxFulfillmentDate I_JournalEntry TaxFulfillmentDate
RootNode
DocumentReferenceID I_JournalEntry DocumentReferenceID
_Recursion _Recursion
@EndUserText.label: 'Hungary VAT: Definition Of Parent-Child Relationship'
@AbapCatalog.sqlViewName: 'HHUSTRPINVCHNN'
@ClientHandling.algorithm: #SESSION_VARIABLE
--@Analytics.dataCategory: #DIMENSION
--@ObjectModel.representativeKey: 'Invoice'
@AccessControl.authorizationCheck: #NOT_ALLOWED
-- the hierarchy node view must have dataCategory #HIERARCHY
@ObjectModel.dataCategory: #HIERARCHY
--@AbapCatalog.preserveKey:true
@AbapCatalog.compiler.compareFilter:true
@ObjectModel.usageType.sizeCategory: #S
@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.dataClass: #MIXED
-- define the relation between parent and child
@Hierarchy.parentChild: { name: 'Recursion',
                          recurse : {
                                        parent:  [ 'preceedingInvoice' ],
                                        child:   [ 'invoiceNumber' ]
                                    },
                          siblingsOrder: {
                              by:     'invoiceNumber',
                              direction: 'ASC'
                           },
                          orphanedNode.handling: #ROOT_NODES,
                          rootNode.visibility: #DO_NOT_ADD_ROOT_NODE }

define view H_HU_StRpInvoiceChainNode with parameters p_CompanyCode : bukrs
  as select from I_JournalEntry as JournalEntry
  inner join P_HU_STRPINVOICECOUNTRY( p_CompanyCode: $parameters.p_CompanyCode ) as TaxItem on
    TaxItem.CompanyCode = JournalEntry.CompanyCode and
    TaxItem.FiscalYear = JournalEntry.FiscalYear and
    TaxItem.AccountingDocument = JournalEntry.AccountingDocument
  association [0..*] to H_HU_StRpInvoiceChainNode as _Recursion on $projection.PreceedingInvoice = _Recursion.InvoiceNumber and
                                                                   $projection.CompanyCode       = _Recursion.CompanyCode
{
  key JournalEntry.CompanyCode, //bukrs

  key JournalEntry.FiscalYear, //gjahr

  key JournalEntry.AccountingDocument, //belnr

      JournalEntry.ReferenceDocumentType, //awtyp

      JournalEntry.OriginalReferenceDocument, //awkey

      JournalEntry.LogicalSystem, //awsys

      concat(concat(JournalEntry.CompanyCode, JournalEntry.FiscalYear), JournalEntry.AccountingDocument) as IssuedInvoiceGuid,
//      JrnlEntryCntrySpecificRef4 as InvoiceNumber, // issued_invoice_id

      case when JournalEntry.JrnlEntryCntrySpecificRef4 = '' then JournalEntry.DocumentReferenceID else JrnlEntryCntrySpecificRef4 end as InvoiceNumber, // issued_invoice_id

      JournalEntry.JrnlEntryCntrySpecificDate4 as InvoiceDate,   //glodat4 - kontrola v badi

      //issued_invoice_type, - badi - da se do druhe aktivity?

      //previous_awkey

      //previous_awtyp

      //previous_awsys

      //?brfplus_rule

//      case when JrnlEntryCntrySpecificRef4 = JrnlEntryCntrySpecificRef5 then cast('' as fac_glo_ref5_hd) else JrnlEntryCntrySpecificRef5 end as PreceedingInvoice,

      case when JournalEntry.JrnlEntryCntrySpecificRef4 = ''
                then case when JournalEntry.DocumentReferenceID        = JournalEntry.JrnlEntryCntrySpecificRef5 then cast('' as fac_glo_ref5_hd) else JrnlEntryCntrySpecificRef5 end
                else case when JournalEntry.JrnlEntryCntrySpecificRef4 = JournalEntry.JrnlEntryCntrySpecificRef5 then cast('' as fac_glo_ref5_hd) else JrnlEntryCntrySpecificRef5 end
                end as PreceedingInvoice,
      JournalEntry.TaxReportingDate, //vatdate, in FIHUVAT_DCL = calc_vat_reporting_date

      JournalEntry.PostingDate,
      JournalEntry.DocumentDate,
      JournalEntry.TaxFulfillmentDate, //fulfillment_date

      ' '                                                         as RootNode,
      JournalEntry.DocumentReferenceID,
      _Recursion
}
 where
  ( JrnlEntryCntrySpecificRef4 is not initial or DocumentReferenceID is not initial )
  and
  ( ReferenceDocumentType = 'REACI' or
    ReferenceDocumentType like 'BKPF%' or
    ReferenceDocumentType like 'RM%' or
    ReferenceDocumentType like 'V%' or
    ReferenceDocumentType like 'IDOC%' or
    ReferenceDocumentType like 'CTE%' or
    ReferenceDocumentType like 'TRAVL%' or
    ReferenceDocumentType like 'CAJO%' or
    ReferenceDocumentType like 'FKK%' or
    ReferenceDocumentType like 'IBKPF%' or
    ReferenceDocumentType like 'WBRK'
  )
  and
    JournalEntry.CompanyCode = $parameters.p_CompanyCode
  and
  ( JournalEntry.TaxCountry = 'HU' or
    JournalEntry.TaxCountry is initial );
//  and

//  ReferenceDocumentType = 'VBRK';