P_PurOrdMaintainHeaderStatus is a Consumption CDS View in SAP S/4HANA. It reads from 1 data source (I_PurchaseOrder) and exposes 1 field with key field PurchaseOrder.
// =========================================================================
// "Simple" Status of Purchase Order Header
// =========================================================================
// The following "simple" status values are supported:
// 01 Draft
// 02 In Approval
// 10 Deleted
// 38 Rejected
//
// The "simple" Status viewis used e.g. in "Manage Purchase Order" list,
// the "complex" (i.e. performance intensive) status values are not// considered here and are calculated in ABAP.
// All status values are calculated in "I_PurchaseOrderStatus".
// =========================================================================
@ClientHandling.algorithm: #SESSION_VARIABLE@AbapCatalog.sqlViewName: 'PPOMAINTHDRSTAT'
@VDM.private: true@AccessControl.authorizationCheck: #PRIVILEGED_ONLY@VDM.viewType: #CONSUMPTIONdefineview P_PurOrdMaintainHeaderStatus
asselectfrom I_PurchaseOrder as header
{
key header.PurchaseOrder as PurchaseOrder,
case header.PurchasingDocumentDeletionCode
when 'X' thencast('10' asabap.char(2))
when 'L' thencast('10' asabap.char(2))
elsecase header.PurchasingCompletenessStatus
when 'X' thencast('01' asabap.char(2))
elsecase header.PurchasingProcessingStatus
when '08' thencast('38' asabap.char(2))
elsecase header.ReleaseIsNotCompleted
when 'X' thencast('02' asabap.char(2))
else ''
endendendendas PurchasingDocumentStatus
}