P_BillingDocProcFlow10

DDL: P_BILLINGDOCPROCFLOW10 SQL: PBILLGDOCPROCF10 Type: view CONSUMPTION

P_BillingDocProcFlow10 is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (P_BillingDocProcFlow0, I_SDDocumentProcessFlow) and exposes 6 fields with key fields Level1Document, Level1DocumentItem.

Data Sources (2)

SourceAliasJoin Type
P_BillingDocProcFlow0 Level0 from
I_SDDocumentProcessFlow Level1 inner

Annotations (9)

NameValueLevelField
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.sizeCategory #XL view
VDM.private true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #CONSUMPTION view
AbapCatalog.sqlViewName PBILLGDOCPROCF10 view
AbapCatalog.preserveKey true view

Fields (6)

KeyFieldSource TableSource FieldDescription
KEY Level1Document I_SDDocumentProcessFlow SubsequentDocument
KEY Level1DocumentItem I_SDDocumentProcessFlow SubsequentDocumentItem
BillingDocument P_BillingDocProcFlow0 BillingDocument
BillingDocumentType P_BillingDocProcFlow0 BillingDocumentType
SDDocumentCategory P_BillingDocProcFlow0 SDDocumentCategory
SalesOrganization P_BillingDocProcFlow0 SalesOrganization
@ClientHandling.algorithm: #SESSION_VARIABLE 
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.sizeCategory: #XL

@VDM.private: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #CONSUMPTION
@AbapCatalog.sqlViewName: 'PBILLGDOCPROCF10'
@AbapCatalog.preserveKey:true

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'      --> Credit Memo 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 Cancelation
          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 Cancelation
          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
 }