P_SlsOrdProcFlow20

DDL: P_SLSORDPROCFLOW20 SQL: PSLSORDPROCF20 Type: view CONSUMPTION

P_SlsOrdProcFlow20 is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (P_SlsOrdProcFlow10, I_SDDocumentProcessFlow) and exposes 10 fields with key fields Level2Document, Level2DocumentItem, Level1Document, Level1DocumentItem, SalesOrder.

Data Sources (2)

SourceAliasJoin Type
P_SlsOrdProcFlow10 Level1 from
I_SDDocumentProcessFlow Level2 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
VDM.viewType #CONSUMPTION view
AccessControl.authorizationCheck #NOT_REQUIRED view
AbapCatalog.sqlViewName PSLSORDPROCF20 view
AbapCatalog.preserveKey true view

Fields (10)

KeyFieldSource TableSource FieldDescription
KEY Level2Document I_SDDocumentProcessFlow SubsequentDocument
KEY Level2DocumentItem I_SDDocumentProcessFlow SubsequentDocumentItem
KEY Level1Document Level1Document
KEY Level1DocumentItem Level1DocumentItem
KEY SalesOrder SalesOrder
SalesOrderType SalesOrderType
Level1DocumentCategory Level1DocumentCategory
SalesOrganization P_SlsOrdProcFlow10 SalesOrganization
DistributionChannel P_SlsOrdProcFlow10 DistributionChannel
OrganizationDivision P_SlsOrdProcFlow10 OrganizationDivision
@ClientHandling.algorithm: #SESSION_VARIABLE 
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.sizeCategory: #XL

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

define view P_SlsOrdProcFlow20
 as select from   P_SlsOrdProcFlow10      as Level1
 inner join       I_SDDocumentProcessFlow as Level2
on 
     Level1.Level1Document         = Level2.PrecedingDocument
and  Level1.Level1DocumentCategory = Level2.PrecedingDocumentCategory
and  Level1.Level1DocumentItem     = Level2.PrecedingDocumentItem
and ( Level2.SubsequentDocumentCategory = 'J' or   --> Delivery
      Level2.SubsequentDocumentCategory = 'T' or   --> Returns Delivery 
      Level2.SubsequentDocumentCategory = 'M' or   --> Invoice
      Level2.SubsequentDocumentCategory = 'U' or   --> Pro Forma Invoice      
      Level2.SubsequentDocumentCategory = 'O' or   --> Credit Memo
      Level2.SubsequentDocumentCategory = 'P' or   --> Debit Memo
      Level2.SubsequentDocumentCategory = 'C' or   --> Order
      Level2.SubsequentDocumentCategory = 'I' or   --> Order w/o charge
      Level2.SubsequentDocumentCategory = 'K' or   --> Credit Memo Request  
      Level2.SubsequentDocumentCategory = 'L' or   --> Debit Memo Request  
      Level2.SubsequentDocumentCategory = '5' or   --> Intercompany Invoice
      Level2.SubsequentDocumentCategory = '6' or   --> Intercompany Credit Memo
      Level2.SubsequentDocumentCategory = 'H' or   --> Customer Return 
      Level2.SubsequentDocumentCategory = 'EBDR' ) --> Billing Document Request
      
left outer to one join 
I_SalesDocumentBasic as SalesDocument
  on Level2.SubsequentDocument         = SalesDocument.SalesDocument     
left outer to one join 
I_BillingDocument as BillingDocument
  on Level2.SubsequentDocument         = BillingDocument.BillingDocument           
{
   //Key

   key Level2.SubsequentDocument     as Level2Document,
   key Level2.SubsequentDocumentItem as Level2DocumentItem,
   key Level1Document,
   key Level1DocumentItem,
       
   //SalesOrder

   key SalesOrder,
   SalesOrderType,   
      
   //Category 

    case 
      when
     ( ( Level2.SubsequentDocumentCategory  = 'K' or   --> Credit Memo Request  
       Level2.SubsequentDocumentCategory  = 'L' ) and      --> Debit Memo Request 
       SalesDocument.SDDocumentCategory is not null ) --> not archived  
       then SalesDocument.SDDocumentCategory    --> from header for mixed documents
      when
     ( ( Level2.SubsequentDocumentCategory  = 'O' or   --> Credit Memo  
       Level2.SubsequentDocumentCategory  = 'P' ) and    --> Debit Memo
       BillingDocument.SDDocumentCategory is not null ) --> not archived    
       then BillingDocument.SDDocumentCategory    --> from header for mixed documents                   
      when       
      Level2.SubsequentDocumentCategory  = 'I' then 'ICON'
     else Level2.SubsequentDocumentCategory
    end as   Level2DocumentCategory,
   Level1DocumentCategory,
   
   //Organization

   Level1.SalesOrganization     as SalesOrganization, 
   Level1.DistributionChannel   as DistributionChannel,
   Level1.OrganizationDivision  as OrganizationDivision
       
 }
where (( SalesOrderIsProjectBased  = ' '    and 
        (Level1DocumentCategory    = 'J' or   --> Delivery
         Level1DocumentCategory    = 'M' or   --> Invoice
         Level1DocumentCategory    = '5' or   --> Intercompany Invoice
         Level1DocumentCategory    = 'O' or   --> Credit Memo
         Level1DocumentCategory    = '6' or   --> Intercompany Credit Memo
         Level1DocumentCategory    = 'P' or   --> Debit Memo   
         Level1DocumentCategory   = 'PBRQ' )) --> Project Billing Request    
       or
       ( SalesOrderIsProjectBased = 'X' and 
       ( Level1DocumentCategory   = 'J' or    --> Delivery
         Level1DocumentCategory   = 'M' or    --> Invoice
         Level1DocumentCategory   = '5' or    --> Intercompany Invoice
         Level1DocumentCategory   = 'O' or    --> Credit Memo         
         Level1DocumentCategory   = '6' or    --> Intercompany Credit Memo
         Level1DocumentCategory   = 'P' or    --> Debit Memo         
         Level1DocumentCategory   = 'L' or    --> Debit Memo Request 
         Level1DocumentCategory   = 'PBRQ' )) --> Project Billing Request  
)                                                 
  
  
  
  
  
 /*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BILLINGDOCUMENT",
"I_SALESDOCUMENTBASIC",
"I_SDDOCUMENTPROCESSFLOW",
"P_SLSORDPROCFLOW10"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/