P_MatVal_By_Period_Types

DDL: P_MATVAL_BY_PERIOD_TYPES SQL: PMTVLPERIODTYPES Type: view BASIC

P_MatVal_By_Period_Types is a Basic CDS View in SAP S/4HANA. It reads from 9 data sources and exposes 49 fields with key fields CostEstimate, FiscalYear, FiscalPeriod, LedgerValuationCurrencyRole, Ledger.

Data Sources (9)

Annotations (7)

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

Fields (49)

KeyFieldSource TableSource FieldDescription
KEY CostEstimate I_MaterialLedgerPrice CostEstimate
KEY FiscalYear P_CCLdgrShiftedPrevYearPer CurrentFiscalYear
KEY FiscalPeriod P_CCLdgrShiftedPrevYearPer CurrentFiscalPeriod
KEY LedgerValuationCurrencyRole P_MaterialLedger_Name_Curtp curtp
KEY Ledger P_MaterialLedger_Name_Curtp rldnr
KEY ValuationArea I_MaterialLedgerPrice ValuationArea
FiscalYearPer P_CCLdgrShiftedPrevYearPer CurrentFiscalYearPeriod
CurrencyRole P_MaterialLedger_Name_Curtp ext_curtype
CompanyCode I_MaterialLedgerPrice CompanyCode
Material I_MaterialLedgerPrice Material
MaterialPrice I_MaterialLedgerPrice MaterialPrice
MaterialPriceControl I_MaterialLedgerPrice MaterialPriceControl
MatlPrcValdtyStrtFsclYearPerd I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
MatlPrcValdtyEndFsclYearPeriod I_MaterialLedgerPrice MatlPrcValdtyEndFsclYearPeriod
MaxFiscPerCKMLPP I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
period_type
CostEstimate
KEY FiscalYear P_CCLdgrShiftedPrevYearPer PreviousFiscalPeriodFiscalYear
KEY FiscalPeriod P_CCLdgrShiftedPrevYearPer PreviousFiscalPeriod
KEY LedgerValuationCurrencyRole P_MaterialLedger_Name_Curtp curtp
KEY Ledger P_MaterialLedger_Name_Curtp rldnr
KEY ValuationArea I_MaterialLedgerPrice ValuationArea
FiscalYearPer P_CCLdgrShiftedPrevYearPer PreviousFiscalYearPeriod
CurrencyRole P_MaterialLedger_Name_Curtp ext_curtype
CompanyCode I_MaterialLedgerPrice CompanyCode
Material I_MaterialLedgerPrice Material
MaterialPrice I_MaterialLedgerPrice MaterialPrice
MaterialPriceControl I_MaterialLedgerPrice MaterialPriceControl
MatlPrcValdtyStrtFsclYearPerd I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
MatlPrcValdtyEndFsclYearPeriod I_MaterialLedgerPrice MatlPrcValdtyEndFsclYearPeriod
MaxFiscPerCKMLPP I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
period_type
CostEstimate
KEY FiscalYear P_CCLdgrShiftedPrevYearPer PreviousFiscalYear
KEY FiscalPeriod P_CCLdgrShiftedPrevYearPer PrevFiscalYearLastFiscalPeriod
KEY LedgerValuationCurrencyRole P_MaterialLedger_Name_Curtp curtp
KEY Ledger P_MaterialLedger_Name_Curtp rldnr
KEY ValuationArea I_MaterialLedgerPrice ValuationArea
FiscalYearPer P_CCLdgrShiftedPrevYearPer PrevFsclYearLastFsclYearPeriod
CurrencyRole P_MaterialLedger_Name_Curtp ext_curtype
CompanyCode I_MaterialLedgerPrice CompanyCode
Material I_MaterialLedgerPrice Material
MaterialPrice I_MaterialLedgerPrice MaterialPrice
MaterialPriceControl I_MaterialLedgerPrice MaterialPriceControl
MatlPrcValdtyStrtFsclYearPerd I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
MatlPrcValdtyEndFsclYearPeriod I_MaterialLedgerPrice MatlPrcValdtyEndFsclYearPeriod
MaxFiscPerCKMLPP I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
period_type
rcolumn P_MaterialLedger_Name_Curtp rcolumn
@VDM.private: true
@VDM.viewType: #BASIC
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #NOT_REQUIRED
@AbapCatalog.sqlViewName: 'PMTVLPERIODTYPES'
@AbapCatalog.compiler.compareFilter:true
@AbapCatalog.preserveKey:true
// Inventory prices - Period types definition 

// special logic: if VM and VJ are the same, only vm is selected

define view P_MatVal_By_Period_Types
  as
  // Current Period

  select from  I_MaterialLedgerPrice       as price
    inner join P_MaterialLedger_Name_Curtp as mlnc on  mlnc.bukrs       = price.CompanyCode
                                                   and mlnc.ext_curtype = price.CurrencyRole
                                                   and mlnc.rldnr       = price.Ledger

//    inner join marv                        as mv   on mv.bukrs = price.CompanyCode

    inner join P_MatlCtrlRecdLdgrFiscalPeriod as marvld on  marvld.CompanyCode = price.CompanyCode 
                                                        and marvld.Ledger = price.Ledger
    

{
  key price.CostEstimate,
  key marvld.CurrentFiscalYear              as FiscalYear,
  key marvld.CurrentFiscalPeriod            as FiscalPeriod,
  key mlnc.curtp                            as LedgerValuationCurrencyRole,
  key mlnc.rldnr                            as Ledger,
  key price.ValuationArea,


      marvld.CurrentFiscalYearPeriod        as FiscalYearPer,
      mlnc.ext_curtype                      as CurrencyRole,
      price.CompanyCode,
      price.Material,
      price.MaterialPrice,
      price.MaterialPriceControl,
      price.MatlPrcValdtyStrtFsclYearPerd,
      price.MatlPrcValdtyEndFsclYearPeriod,
//      price.MaterialPriceUnitQty,

//      price.ValuationQuantityUnit           as BaseUnit,

//      price.InventoryValuationType,


      price.MatlPrcValdtyStrtFsclYearPerd   as MaxFiscPerCKMLPP,
      'LF'                                  as period_type,
      mlnc.rcolumn

}
where
      price.MaterialPriceType              = 'INVPR'
  and price.MaterialPriceSubtype           = ' '
  and price.MatlPrcValdtyEndFsclYearPeriod = '9999012'

// Previous period

union all select from I_MaterialLedgerPrice       as price
  inner join          P_MaterialLedger_Name_Curtp as mlnc on  mlnc.bukrs       = price.CompanyCode
                                                          and mlnc.ext_curtype = price.CurrencyRole
                                                          and mlnc.rldnr       = price.Ledger

//  inner join          marv                        as mv   on mv.bukrs = price.CompanyCode

  inner join P_MatlCtrlRecdLdgrFiscalPeriod as marvld on  marvld.CompanyCode = price.CompanyCode 
                                                      and marvld.Ledger = price.Ledger

{
  key price.CostEstimate,
  key marvld.PreviousFiscalPeriodFiscalYear as FiscalYear,
  key marvld.PreviousFiscalPeriod           as FiscalPeriod,
  key mlnc.curtp                            as LedgerValuationCurrencyRole,
  key mlnc.rldnr                            as Ledger,
  key price.ValuationArea,

      marvld.PreviousFiscalYearPeriod       as FiscalYearPer,
      mlnc.ext_curtype                      as CurrencyRole,
      price.CompanyCode,
      price.Material,
      price.MaterialPrice,
      price.MaterialPriceControl,
      price.MatlPrcValdtyStrtFsclYearPerd,
      price.MatlPrcValdtyEndFsclYearPeriod,
//      price.MaterialPriceUnitQty,

//      price.ValuationQuantityUnit           as BaseUnit,

//      price.InventoryValuationType,


      price.MatlPrcValdtyStrtFsclYearPerd   as MaxFiscPerCKMLPP,
      'VM'                                  as period_type,
      mlnc.rcolumn

}
where
      price.MaterialPriceType              =                                                  'INVPR'
  and price.MaterialPriceSubtype           =                                                  ' '
  and price.MatlPrcValdtyStrtFsclYearPerd  <= marvld.PreviousFiscalYearPeriod
  and price.MatlPrcValdtyEndFsclYearPeriod >= marvld.PreviousFiscalYearPeriod

// Last period of previous fiscal year

union all select from I_MaterialLedgerPrice       as price
  inner join          P_MaterialLedger_Name_Curtp as mlnc on  mlnc.bukrs       = price.CompanyCode
                                                          and mlnc.ext_curtype = price.CurrencyRole
                                                          and mlnc.rldnr       = price.Ledger

//  inner join          marv                        as mv   on mv.bukrs = price.CompanyCode

  inner join P_CCLdgrShiftedPrevYearPer as marvld on  marvld.CompanyCode = price.CompanyCode 
                                                  and marvld.Ledger = price.Ledger

{
  key price.CostEstimate,
  key marvld.PreviousFiscalYear             as FiscalYear,
  key marvld.PrevFiscalYearLastFiscalPeriod as FiscalPeriod,
  key mlnc.curtp                            as LedgerValuationCurrencyRole,
  key mlnc.rldnr                            as Ledger,
  key price.ValuationArea,

      marvld.PrevFsclYearLastFsclYearPeriod as FiscalYearPer,
      mlnc.ext_curtype                      as CurrencyRole,
      price.CompanyCode,
      price.Material,
      price.MaterialPrice,
      price.MaterialPriceControl,
      price.MatlPrcValdtyStrtFsclYearPerd,
      price.MatlPrcValdtyEndFsclYearPeriod,
//      price.MaterialPriceUnitQty,

//      price.ValuationQuantityUnit           as BaseUnit,

//      price.InventoryValuationType,


      price.MatlPrcValdtyStrtFsclYearPerd   as MaxFiscPerCKMLPP,
      'VJ'                                  as period_type,
      mlnc.rcolumn

}
where
        price.MaterialPriceType              =                                                    'INVPR'
  and   price.MaterialPriceSubtype           =                                                    ' '
  and   price.MatlPrcValdtyStrtFsclYearPerd  <= marvld.PrevFsclYearLastFsclYearPeriod
  and   price.MatlPrcValdtyEndFsclYearPeriod >= marvld.PrevFsclYearLastFsclYearPeriod

  // special logic: if VM and VJ are the same, only vm is selected

  and   not(
      marvld.PreviousFiscalPeriodFiscalYear   = marvld.PreviousFiscalYear 
      and marvld.PreviousFiscalPeriod         = marvld.PrevFiscalYearLastFiscalPeriod
    )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_MATERIALLEDGERPRICE",
"P_CCLDGRSHIFTEDPREVYEARPER",
"P_MATERIALLEDGER_NAME_CURTP",
"P_MATLCTRLRECDLDGRFISCALPERIOD"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/