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.
@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 }
defineview H_HU_StRpInvoiceChainNode withparameters p_CompanyCode : bukrs
asselectfrom I_JournalEntry as JournalEntry
innerjoin 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
casewhen JournalEntry.JrnlEntryCntrySpecificRef4 = '' then JournalEntry.DocumentReferenceID else JrnlEntryCntrySpecificRef4 endas 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
// casewhen JrnlEntryCntrySpecificRef4 = JrnlEntryCntrySpecificRef5 thencast('' as fac_glo_ref5_hd) else JrnlEntryCntrySpecificRef5 endas PreceedingInvoice,
casewhen JournalEntry.JrnlEntryCntrySpecificRef4 = ''
thencasewhen JournalEntry.DocumentReferenceID = JournalEntry.JrnlEntryCntrySpecificRef5 thencast('' as fac_glo_ref5_hd) else JrnlEntryCntrySpecificRef5 endelsecasewhen JournalEntry.JrnlEntryCntrySpecificRef4 = JournalEntry.JrnlEntryCntrySpecificRef5 thencast('' as fac_glo_ref5_hd) else JrnlEntryCntrySpecificRef5 endendas 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 isnot initial or DocumentReferenceID isnot 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';