@AbapCatalog.preserveKey: true
@AbapCatalog.sqlViewName : 'PBILLGDOCPROCF10'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType: { dataClass: #MIXED, serviceQuality: #C, sizeCategory: #XL }
@VDM.private: true
@VDM.viewType: #CONSUMPTION
define view P_BillingDocProcFlow10
as select from P_BillingDocProcFlow0 as Level0 -- > Level 0
inner join I_SDDocumentProcessFlow as Level1 -- > Level 1
on Level0.BillingDocument = Level1.PrecedingDocument
and (Level1.SubsequentDocumentCategory = 'O' or -- > Credit Memo
Level1.SubsequentDocumentCategory = 'P' or -- > Debit Memo
Level1.SubsequentDocumentCategory = 'K' or -- > Credit Memo Request
Level1.SubsequentDocumentCategory = 'L' or -- > Debit Memo Request
Level1.SubsequentDocumentCategory = 'H' or -- > Returns
Level1.SubsequentDocumentCategory = '6' or -- > Intercompany Credit Memo
Level1.SubsequentDocumentCategory = 'N' or -- > Invoice Cancellatiom
Level1.SubsequentDocumentCategory = 'S' or -- > Credit Memo Cancellation
Level1.SubsequentDocumentCategory = 'DPCC' -- > Down Payment Cancellation
)
left outer to one join I_SalesDocumentBasic as SalesDocument
on Level1.SubsequentDocument = SalesDocument.SalesDocument
left outer to one join I_BillingDocument as BillingDocument
on Level1.SubsequentDocument = BillingDocument.BillingDocument
{
// Key
key Level1.SubsequentDocument as Level1Document,
key Level1.SubsequentDocumentItem as Level1DocumentItem,
key
// Category
case when
((Level1.SubsequentDocumentCategory = 'K' or -- > Credit Memo Request
Level1.SubsequentDocumentCategory = 'L') and -- > Debit Memo Request
SalesDocument.SDDocumentCategory is not null ) -- > not archived
then SalesDocument.SDDocumentCategory -- > from header for mixed documents
when
((Level1.SubsequentDocumentCategory = 'O' or -- > Credit Memo
Level1.SubsequentDocumentCategory = 'P') and -- > Debit Memo
BillingDocument.SDDocumentCategory is not null ) -- > not archived
then BillingDocument.SDDocumentCategory -- > from header for mixed documents
when
(((Level0.SDDocumentCategory = 'M' or Level0.SDDocumentCategory = 'P') and -- > Level 0 is an Invoice/Debit Memo
Level1.PrecedingDocumentCategory = 'K' and -- > Level 1 PrecedingDocument is a Credit Memo Request
Level1.SubsequentDocumentCategory = 'S') and -- > Level 1 SubsequentDocument is a Credit Memo Cancellation
BillingDocument.SDDocumentCategory is not null ) -- > Level 1 Header SDDocumentCategory must not be empty
then BillingDocument.SDDocumentCategory -- > Use Level 1 Header SDDocumentCategory for Level 1 Item SDDocumentCategory
when
((Level0.SDDocumentCategory = 'O' and -- > Level 0 PrecedingDocument is a Credit Memo
Level1.PrecedingDocumentCategory = 'L' and -- > Level 1 PrecedingDocument is a Debit Memo Request
Level1.SubsequentDocumentCategory = 'N') and -- > Level 1 SubsequentDocument is an Invoice Cancellation
BillingDocument.SDDocumentCategory is not null ) -- > Level 1 Header SDDocumentCategory must not be empty
then BillingDocument.SDDocumentCategory -- > Use Level 1 Header SDDocumentCategory for Level 1 Item SDDocumentCategory
else Level1.SubsequentDocumentCategory
end as Level1DocumentCategory,
Level0.BillingDocument,
Level0.BillingDocumentType,
Level0.SDDocumentCategory,
// Organizatio
Level0.SalesOrganization
}
Depth:
1
2
3
4
5
All
Reload
P_BillingDocProcFlow10 view