@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:true
define view P_SlsOrdProcFlow10
as select from P_SlsOrdProcFlow0 as Level0 --> Level 0
inner join 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' --> Project Billing Request
)
left outer to one join
I_DeliveryDocument as DeliveryDocument
on
Level1.SubsequentDocument = DeliveryDocument.DeliveryDocument
and Level1.SubsequentDocumentCategory = DeliveryDocument.SDDocumentCategory
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
left outer to one join
P_SlsOrdProcFlowPrjBlgReq as ProjBillgReq
on Level1.SubsequentDocument = ProjBillgReq.ProjectBillingRequest
{
//Key
key Level1.SubsequentDocument as Level1Document,
key Level1.SubsequentDocumentItem as Level1DocumentItem,
//Category //
key 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
else Level1.SubsequentDocumentCategory
end as Level1DocumentCategory,
//SalesOrder
SalesOrder,
SalesOrderType,
SalesOrderCategory,
//Order relevant for Project e.g Professional Service
SalesOrderIsProjectBased,
//Organization
Level0.SalesOrganization,
Level0.DistributionChannel,
Level0.OrganizationDivision,
//Status
case when
(
( 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
''
end as BillingDocumentIsRequired
}
where (Level0.SalesOrderCategory = 'C' --> Order
or Level0.SalesOrderCategory = 'I' ) --> Order w/o charge
and (ProjBillgReq.ProjBillgReqCreatedAtDte is null or ProjBillgReq.ProjBillgReqCreatedAtDte > ProjBillgReq.ValidOnDate)
union all select distinct from P_SlsOrdProcFlow12 //Level1 Purchase Order from EKKN
{
//Key
key 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
}
/*+[internal] {
"BASEINFO":
{
"FROM ":
[
"I_BILLINGDOCUMENT",
"I_DELIVERYDOCUMENT",
"I_SALESDOCUMENTBASIC",
"I_SDDOCUMENTPROCESSFLOW",
"P_SLSORDPROCFLOW0",
"P_SLSORDPROCFLOW12",
"P_SLSORDPROCFLOWPRJBLGREQ"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/
Depth:
1
2
3
4
5
All
Reload