P_BillingDocProcFlowM2

DDL: P_BILLINGDOCPROCFLOWM2 SQL: PBILLGDOCPROCFM2 Type: view CONSUMPTION Package: ODATA_SD_BIL_PROCESSFLOW

Billing Doc Process Flow: : Level -2 Sales & Distribution

P_BillingDocProcFlowM2 is a Consumption CDS View that provides data about "Billing Doc Process Flow: : Level -2 Sales & Distribution" in SAP S/4HANA. It reads from 1 data source (I_SDDocumentProcessFlow) and exposes 8 fields with key fields LevelM2Document, LevelM2DocumentItem, LevelM1Document, LevelM1DocumentItem, LevelM1DocumentCategory. Part of development package ODATA_SD_BIL_PROCESSFLOW.

Data Sources (1)

SourceAliasJoin Type
I_SDDocumentProcessFlow LevelM2 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 PBILLGDOCPROCFM2 view
AbapCatalog.preserveKey true view

Fields (8)

KeyFieldSource TableSource FieldDescription
KEY LevelM2Document PrecedingDocument
KEY LevelM2DocumentItem PrecedingDocumentItem
KEY LevelM1Document LevelM1Document
KEY LevelM1DocumentItem LevelM1DocumentItem
KEY LevelM1DocumentCategory LevelM1DocumentCategory
KEY BillingDocument BillingDocument
BillingDocumentType BillingDocumentType
SalesOrganization LevelM1 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: 'PBILLGDOCPROCFM2'
@AbapCatalog.preserveKey:true

define view P_BillingDocProcFlowM2
  as select distinct from  P_BillingDocProcFlowM1  as LevelM1 --> Level -1
    inner join             I_SDDocumentProcessFlow as LevelM2 --> Level Minus2
                                                                    on  LevelM2.SubsequentDocument          = LevelM1.LevelM1Document
                                                                    and LevelM2.SubsequentDocumentItem      = LevelM1.LevelM1DocumentItem
                                                                    and LevelM2.SubsequentDocumentCategory  = LevelM1.LevelM1DocumentCategory
                                                                    and (
                                                                       LevelM2.PrecedingDocumentCategory    = 'C' --> Order
                                                                       or LevelM2.PrecedingDocumentCategory = 'E' --> Scheduling Agreement
                                                                       or LevelM2.PrecedingDocumentCategory = 'I' --> Order w/o charge
                                                                       or LevelM2.PrecedingDocumentCategory = 'H' --> Return
                                                                       or LevelM2.PrecedingDocumentCategory = 'L' --> Debit Memo Request
                                                                       or LevelM2.PrecedingDocumentCategory = 'L' --> Debit Memo Request
                                                                       or LevelM2.PrecedingDocumentCategory = 'M' --> Invoice
                                                                       or LevelM2.PrecedingDocumentCategory = '2' --> External Transaction
                                                                       or LevelM2.PrecedingDocumentCategory = 'CSVO' --> CM Service Order
                                                                       or LevelM2.PrecedingDocumentCategory = 'CSCO' --> CM Service Confirmation
                                                                       or LevelM2.PrecedingDocumentCategory = 'CSCT' --> CM Service Contract
                                                                       or LevelM2.PrecedingDocumentCategory = 'PBRQ' --> Project Billing Request

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

  key PrecedingDocument     as LevelM2Document,
  key PrecedingDocumentItem as LevelM2DocumentItem,

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

  key LevelM1Document,
  key LevelM1DocumentItem,
  key LevelM1DocumentCategory,

      //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
       (  (    LevelM2.PrecedingDocumentCategory      = 'C'  --> Order
          and  LevelM2.SubsequentDocumentCategory     = 'L' )  --> --> Debit Memo Request
       or (    LevelM2.PrecedingDocumentCategory      = 'M'  --> Invoice
          and  LevelM2.SubsequentDocumentCategory     = 'L' )  --> --> Debit Memo Request
       )  )
       then
       ' '
       else
       ''
       end                  as IsReferenceDocument,

      //Organization

      LevelM1.SalesOrganization
}