Sales Order Process Flow: Level +1 Sales & Distribution
P_SlsOrdProcFlow10 is a Consumption CDS View that provides data about "Sales Order Process Flow: Level +1 Sales & Distribution" in SAP S/4HANA. It reads from 2 data sources (P_SlsOrdProcFlow0, I_SDDocumentProcessFlow) and exposes 19 fields with key fields Level1Document, Level1DocumentItem, Level1DocumentItem, Level1DocumentCategory. Part of development package ODATA_SD_SO_PROCESSFLOW.
@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: 'PSLSORDPROCF10'
@AbapCatalog.preserveKey:truedefineview P_SlsOrdProcFlow10
asselectfrom P_SlsOrdProcFlow0 as Level0 --> Level 0
innerjoin I_SDDocumentProcessFlow as Level1 --> Level 1
on Level0.SalesOrder = Level1.PrecedingDocument
and (
Level1.SubsequentDocumentCategory = 'J' or --> Delivery
Level1.SubsequentDocumentCategory = 'T' or --> Returns Delivery
Level1.SubsequentDocumentCategory = 'M' or --> Invoice
Level1.SubsequentDocumentCategory = 'U' or --> Pro Forma Invoice
Level1.SubsequentDocumentCategory = 'O' or --> Credit Memo
Level1.SubsequentDocumentCategory = 'P' or --> Debit Memo
Level1.SubsequentDocumentCategory = 'C' or --> Order
Level1.SubsequentDocumentCategory = 'I' or --> Order w/o charge
Level1.SubsequentDocumentCategory = 'K' or --> Credit Memo Request
Level1.SubsequentDocumentCategory = 'L' or --> Debit Memo Request
Level1.SubsequentDocumentCategory = '5' or --> Intercompany Invoice
Level1.SubsequentDocumentCategory = '6' or --> Intercompany Credit Memo
Level1.SubsequentDocumentCategory = 'H' or --> Customer Return
Level1.SubsequentDocumentCategory = 'V' or --> Purchase Order
Level1.SubsequentDocumentCategory = 'PBRQ' or --> Project Billing Request
Level1.SubsequentDocumentCategory = 'DPRQ' --> Advanced Down Payment Request
)
leftouter to one join
I_DeliveryDocument as DeliveryDocument
on
Level1.SubsequentDocument = DeliveryDocument.DeliveryDocument
and Level1.SubsequentDocumentCategory = DeliveryDocument.SDDocumentCategory
leftouter to one join
I_SalesDocumentBasic as SalesDocument
on Level1.SubsequentDocument = SalesDocument.SalesDocument
leftouter to one join
I_BillingDocument as BillingDocument
on Level1.SubsequentDocument = BillingDocument.BillingDocument
leftouter to one join
P_SlsOrdProcFlowPrjBlgReq as ProjBillgReq
on Level1.SubsequentDocument = ProjBillgReq.ProjectBillingRequest
{
//Keykey Level1.SubsequentDocument as Level1Document,
key Level1.SubsequentDocumentItem as Level1DocumentItem,
//Category //
keycasewhen
( ( Level1.SubsequentDocumentCategory = 'K' or --> Credit Memo Request
Level1.SubsequentDocumentCategory = 'L' ) and --> Debit Memo Request
SalesDocument.SDDocumentCategory isnotnull ) --> 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 isnotnull ) --> not archived
then BillingDocument.SDDocumentCategory --> from header for mixed documents
else Level1.SubsequentDocumentCategory
endas Level1DocumentCategory,
//SalesOrder
SalesOrder,
SalesOrderType,
SalesOrderCategory,
//Order relevant for Project e.g Professional Service
SalesOrderIsProjectBased,
//Organization
Level0.SalesOrganization,
Level0.DistributionChannel,
Level0.OrganizationDivision,
//Status
casewhen
(
( DeliveryDocument.OverallDelivReltdBillgStatus = 'A' or
DeliveryDocument.OverallDelivReltdBillgStatus = 'B' )
or//Planned document for Professional Service Scernario
( Level0.SalesOrderIsProjectBased = 'X' and
SalesDocument.SDDocumentCategory = 'L' and ---> Debit Memo Request
(SalesDocument.OverallOrdReltdBillgStatus = 'A' or
SalesDocument.OverallOrdReltdBillgStatus = 'B' ) )
)
then
'X'
else
''
endas BillingDocumentIsRequired
}
where (Level0.SalesOrderCategory = 'C' --> Orderor Level0.SalesOrderCategory = 'I' ) --> Order w/o charge
and (ProjBillgReq.ProjBillgReqCreatedAtDte isnullor ProjBillgReq.ProjBillgReqCreatedAtDte > ProjBillgReq.ValidOnDate)
unionallselectdistinctfrom P_SlsOrdProcFlow12 //Level1 Purchase Orderfrom EKKN
{
//Keykey PurchaseOrder as Level1Document,
key '000000' as Level1DocumentItem,
key 'V' as Level1DocumentCategory,
//SalesOrder
SalesOrder,
SalesOrderType,
SalesOrderCategory,
//Order relevant for Project e.g Professional Service
'' as SalesOrderIsProjectBased,
//Organization
SalesOrganization,
DistributionChannel,
OrganizationDivision,
'' as BillingDocumentIsRequired
}