P_CanclnBillingDocProcFlowM3

DDL: P_CANCLNBILLINGDOCPROCFLOWM3 SQL: PCBILLDOCPROCFM3 Type: view CONSUMPTION

P_CanclnBillingDocProcFlowM3 is a Consumption CDS View in SAP S/4HANA. It reads from 1 data source (I_SDDocumentProcessFlow) and exposes 8 fields with key fields LevelM3Document, LevelM3DocumentItem, LevelM2Document, LevelM2DocumentItem, LevelM2DocumentCategory.

Data Sources (1)

SourceAliasJoin Type
I_SDDocumentProcessFlow LevelM3 inner

Annotations (10)

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 PCBILLDOCPROCFM3 view
AbapCatalog.preserveKey true view
AbapCatalog.compiler.compareFilter true view

Fields (8)

KeyFieldSource TableSource FieldDescription
KEY LevelM3Document PrecedingDocument
KEY LevelM3DocumentItem PrecedingDocumentItem
KEY LevelM2Document LevelM2Document
KEY LevelM2DocumentItem LevelM2DocumentItem
KEY LevelM2DocumentCategory LevelM2DocumentCategory
KEY BillingDocument BillingDocument
BillingDocumentType BillingDocumentType
SalesOrganization LevelM2 SalesOrganization
@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: 'PCBILLDOCPROCFM3'
@AbapCatalog.preserveKey:true
@AbapCatalog.compiler.compareFilter:true

define view P_CanclnBillingDocProcFlowM3
  as select distinct from  P_CanclnBillingDocProcFlowM2 as LevelM2 --> Level -2
    inner join             I_SDDocumentProcessFlow      as LevelM3 --> Level Minus3
                                                                         on  LevelM3.SubsequentDocument          = LevelM2.LevelM2Document
                                                                         and LevelM3.SubsequentDocumentItem      = LevelM2.LevelM2DocumentItem
                                                                         and (
                                                                            LevelM3.PrecedingDocumentCategory    = 'C' --> Order
                                                                            or LevelM3.PrecedingDocumentCategory = 'E' --> Scheduling Agreement
                                                                            or LevelM3.PrecedingDocumentCategory = 'I' --> Order w/o charge
                                                                            or LevelM3.PrecedingDocumentCategory = 'H' --> Return
                                                                            or LevelM3.PrecedingDocumentCategory = 'L' --> Debit Memo Request
                                                                            or LevelM3.PrecedingDocumentCategory = 'L' --> Debit Memo Request
                                                                            or LevelM3.PrecedingDocumentCategory = 'M' --> Invoice
                                                                            or LevelM3.PrecedingDocumentCategory = '2' --> External Transaction
                                                                            or LevelM3.PrecedingDocumentCategory = 'CSVO' --> CM Service Order
                                                                            or LevelM3.PrecedingDocumentCategory = 'CSCO' --> CM Service Confirmation
                                                                            or LevelM3.PrecedingDocumentCategory = 'CSCT' --> CM Service Contract

                                                                          )
    left outer to one join I_SalesDocumentBasic         as SalesDocument on LevelM3.PrecedingDocument = SalesDocument.SalesDocument
{
      //Key

  key PrecedingDocument     as LevelM3Document,
  key PrecedingDocumentItem as LevelM3DocumentItem,

  key case
    when PrecedingDocumentCategory = 'M'
        then 'MREF'   --> allow assignmet to 'Reference' lane
    else
      PrecedingDocumentCategory
    end                     as LevelM3DocumentCategory,

  key LevelM2Document,
  key LevelM2DocumentItem,
  key LevelM2DocumentCategory,

      //Billing Document

  key BillingDocument,
      BillingDocumentType,

      //Order relevant for Project e.g Professional Service

      case when
       (
        SalesDocument._SalesDocumentType.OrderTypeForBillingRequest != ' ' or
        SalesDocument._SalesDocumentType.SalesDocumentProcessingType = 'P'   --> Professional Service
         )
       then
       'X'
       else
       ''
       end                  as SalesOrderIsProjectBased,

      case when
       (
        SalesDocument._SalesDocumentType.OrderTypeForBillingRequest   = ' ' and
        SalesDocument._SalesDocumentType.SalesDocumentProcessingType != 'P' and
       (  (    LevelM3.PrecedingDocumentCategory      = 'C'  --> Order
          and  LevelM3.SubsequentDocumentCategory     = 'L' )  --> --> Debit Memo Request
       or (    LevelM3.PrecedingDocumentCategory      = 'M'  --> Invoice
          and  LevelM3.SubsequentDocumentCategory     = 'L' )  --> --> Debit Memo Request
       )  )
       then
       ' '
       else
       ''
       end                  as IsReferenceDocument,

      //Organization

      LevelM2.SalesOrganization
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_SALESDOCUMENTBASIC",
"I_SALESDOCUMENTTYPE",
"I_SDDOCUMENTPROCESSFLOW",
"P_CANCLNBILLINGDOCPROCFLOWM2"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/