@AbapCatalog.sqlViewName: 'PPLSAFTBILLDOCB'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@VDM.private: true
@VDM.viewType: #COMPOSITE
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #P
@ClientHandling.algorithm: #SESSION_VARIABLE
define view P_PL_SAFTBillingDocumentBasic
as select from I_BillingDocument as a
inner join I_PL_SAFTBillingDocTypeMap as BillingDocTypeMap on BillingDocTypeMap.BillingDocumentType = a.BillingDocumentType
and BillingDocTypeMap.BillingSDDocumentCategory = a.SDDocumentCategory
and BillingDocTypeMap.StartDate <= a.BillingDocumentDate
and BillingDocTypeMap.EndDate >= a.BillingDocumentDate
left outer to one join I_BillingDocument as CancelledBillingDocument on CancelledBillingDocument.BillingDocument = a.CancelledBillingDocument
left outer to one join I_PL_SAFTBillingDocTypeMap as CancelBillingDocTypeMap on CancelBillingDocTypeMap.BillingDocumentType = CancelledBillingDocument.BillingDocumentType
and CancelBillingDocTypeMap.BillingSDDocumentCategory = CancelledBillingDocument.SDDocumentCategory
and CancelBillingDocTypeMap.StartDate <= CancelledBillingDocument.BillingDocumentDate
and CancelBillingDocTypeMap.EndDate >= CancelledBillingDocument.BillingDocumentDate
{
key a.BillingDocument,
a.BillingDocumentCategory,
a.BillingDocumentType,
a.BillingDocumentDate,
a.CancelledBillingDocument,
a.SDDocumentCategory,
case
when (BillingDocTypeMap.PL_SAFTInvoiceType = 'VAT' and BillingDocTypeMap.TransactionGroup = '8')
or (a.CancelledBillingDocument is not initial and CancelBillingDocTypeMap.PL_SAFTInvoiceType = 'VAT' and CancelBillingDocTypeMap.TransactionGroup = '8')
then 'ZAL'
else
BillingDocTypeMap.PL_SAFTInvoiceType
end as PL_SAFTInvoiceType
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BILLINGDOCUMENT",
"I_PL_SAFTBILLINGDOCTYPEMAP"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/