P_EBPC_MaxOrderStatusByPeriod

DDL: P_EBPC_MAXORDERSTATUSBYPERIOD SQL: PEBPCMAXORDSTAT Type: view COMPOSITE

P_EBPC_MaxOrderStatusByPeriod is a Composite CDS View in SAP S/4HANA. It reads from 3 data sources (I_FiscalYearPeriodForLedger, I_StatusObjectStatusChange_2, I_SystemStatus) and exposes 5 fields with key fields Ledger, CompanyCode, StatusObject, StatusCode.

Data Sources (3)

SourceAliasJoin Type
I_FiscalYearPeriodForLedger FiscalYearPeriodForLedger inner
I_StatusObjectStatusChange_2 StatusChange from
I_SystemStatus SystemStatus inner

Parameters (1)

NameTypeDefault
P_ToFiscalYearPeriod fins_fyearperiod

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PEBPCMAXORDSTAT view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.private true view
VDM.viewType #COMPOSITE view

Fields (5)

KeyFieldSource TableSource FieldDescription
KEY Ledger I_FiscalYearPeriodForLedger Ledger
KEY CompanyCode I_FiscalYearPeriodForLedger CompanyCode
KEY StatusObject I_StatusObjectStatusChange_2 StatusObject
KEY StatusCode I_StatusObjectStatusChange_2 StatusCode
MaxObjectStatusChangeNumber
@AbapCatalog.sqlViewName: 'PEBPCMAXORDSTAT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE

@VDM.private: true
@VDM.viewType: #COMPOSITE

define view P_EBPC_MaxOrderStatusByPeriod
  with parameters
    @Semantics.fiscal.yearPeriod: true
    P_ToFiscalYearPeriod : fins_fyearperiod
  as select from I_StatusObjectStatusChange_2 as StatusChange
    inner join   I_SystemStatus               as SystemStatus              on SystemStatus.SystemStatus = StatusChange.StatusCode
    inner join   I_FiscalYearPeriodForLedger  as FiscalYearPeriodForLedger on FiscalYearPeriodForLedger.FiscalYearPeriod = :P_ToFiscalYearPeriod
{
  key FiscalYearPeriodForLedger.Ledger,
  key FiscalYearPeriodForLedger.CompanyCode,
  key StatusChange.StatusObject,
  key StatusChange.StatusCode,
      
      max(StatusChange.StatusObjectStatusChangeNumber) as MaxObjectStatusChangeNumber // Get the highest Change Number per Object and Code

}
where
      StatusChange.LastChangeDate <= FiscalYearPeriodForLedger.FiscalPeriodEndDate
  and SystemStatus.StatusIsHidden =  '' // Exclude hidden statuses

group by
  FiscalYearPeriodForLedger.Ledger,
  FiscalYearPeriodForLedger.CompanyCode,
  StatusChange.StatusObject,
  StatusChange.StatusCode