@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%'
)
and
JournalEntry.CompanyCode = $parameters .p_CompanyCode
and
( JournalEntry.TaxCountry = 'HU' or
JournalEntry.TaxCountry is initial );
// and
// ReferenceDocumentType = 'VBRK';
/*+[internal] {
"BASEINFO":
{
"FROM ":
[
"I_JOURNALENTRY",
"P_HU_STRPINVOICECOUNTRY"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/
Depth:
1
2
3
4
5
All
Reload
H_HU_StRpInvoiceChainNode view