@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 : 'PSLSORDPROCF30'
@AbapCatalog.preserveKey:true
define view P_SlsOrdProcFlow30
as select from P_SlsOrdProcFlow20 as Level2
inner join I_SDDocumentProcessFlow as Level3
on
Level2.Level2Document = Level3.PrecedingDocument
and Level2.Level2DocumentCategory = Level3.PrecedingDocumentCategory
and Level2.Level2DocumentItem = Level3.PrecedingDocumentItem
and (
Level3.SubsequentDocumentCategory = 'M' or --> Invoice
Level3.SubsequentDocumentCategory = 'U' or --> Pro Forma Invoice
Level3.SubsequentDocumentCategory = 'O' or --> Credit Memo
Level3.SubsequentDocumentCategory = 'P' or --> Debit Memo
Level3.SubsequentDocumentCategory = 'I' or --> Order w/o charge
Level3.SubsequentDocumentCategory = 'K' or --> Credit Memo Request
Level3.SubsequentDocumentCategory = 'L' or --> Debit Memo Request
Level3.SubsequentDocumentCategory = '5' or --> Intercompany Invoice
Level3.SubsequentDocumentCategory = '6' or --> Intercompany Credit Memo
Level3.SubsequentDocumentCategory = 'H' --> Customer Return
)
left outer to one join
I_SalesDocumentBasic as SalesDocument
on Level3.SubsequentDocument = SalesDocument.SalesDocument
{
//Key
key Level3.SubsequentDocument as Level3Document,
key Level3.SubsequentDocumentItem as Level3DocumentItem,
key Level2Document,
key Level2DocumentItem,
//SalesOrder
key SalesOrder,
SalesOrderType,
//Category
case
when
( ( Level3.SubsequentDocumentCategory = 'K' or --> Credit Memo Request
Level3.SubsequentDocumentCategory = 'L' ) and --> Debit Memo Request
SalesDocument.SDDocumentCategory is not null ) --> not archived
then SalesDocument.SDDocumentCategory --> from header for mixed documents
when
Level3.SubsequentDocumentCategory = 'I' then 'ICON'
else Level3.SubsequentDocumentCategory
end as Level3DocumentCategory,
Level2DocumentCategory,
//Organization
Level2.SalesOrganization as SalesOrganization,
Level2.DistributionChannel as DistributionChannel,
Level2.OrganizationDivision as OrganizationDivision
}
where ( Level2DocumentCategory = 'M' or --> Invoice
Level2DocumentCategory = '5' or --> Intercompany Invoice
Level2DocumentCategory = 'O' or --> Credit Memo
Level2DocumentCategory = '6' or --> Intercompany Credit Memo
Level2DocumentCategory = 'P' or --> Debit Memo
Level2DocumentCategory = 'EBDR' ) --> Billing Document Request
Depth:
1
2
3
4
5
All
Reload