P_Matval_Manage_Ckml

DDL: P_MATVAL_MANAGE_CKML SQL: PMATVALMGMCKML Type: view BASIC

P_Matval_Manage_Ckml is a Basic CDS View in SAP S/4HANA. It reads from 12 data sources and exposes 49 fields with key fields CostEstimate, LedgerValuationCurrencyRole, FiscalYear, FiscalPeriod, ValuationArea. It has 5 associations to related views.

Data Sources (12)

SourceAliasJoin Type
ckmlcr cr left_outer
ckmlhd hd left_outer
ckmlhd hd left_outer
I_MaterialLedgerPrice INVPR left_outer
I_MatlLedgerValnCrcyRoleName lvcr inner
I_MatlLedgerValnCrcyRoleName lvcr inner
mbew m left_outer
ckmlpr pr from
I_MaterialLedgerPrice price union_all
R_MatlPriceDataMigrationStatus tf inner
R_MatlPriceDataMigrationStatus tf inner
t001k tk inner

Associations (5)

CardinalityTargetAliasCondition
[0..1] I_WBSElementBasicData _WBSElementBasicData hd.pspnr = _WBSElementBasicData.WBSElementInternalID
[0..1] I_MaterialLedgerPrice _STDPR price.CostEstimate = _STDPR.CostEstimate and price.Ledger = _STDPR.Ledger and price.CurrencyRole = _STDPR.CurrencyRole and price.CompanyCode = _STDPR.CompanyCode and price.ValuationArea = _STDPR.ValuationArea and _STDPR.MaterialPriceType = 'STDPR' and _STDPR.MaterialPriceSubtype = '' and _STDPR.MatlPrcValdtyStrtFsclYearPerd <= INVPR.MatlPrcValdtyStrtFsclYearPerd and _STDPR.MatlPrcValdtyEndFsclYearPeriod >= INVPR.MatlPrcValdtyEndFsclYearPeriod
[0..1] I_MaterialLedgerPrice _ACT _ACT.CostEstimate = INVPR.CostEstimate and _ACT.CurrencyRole = INVPR.CurrencyRole and _ACT.Ledger = INVPR.Ledger and _ACT.CompanyCode = INVPR.CompanyCode and _ACT.ValuationArea = INVPR.ValuationArea and _ACT.MaterialPriceType = 'ACT' and _ACT.MaterialPriceSubtype = 'ACT' and _ACT.MatlPrcValdtyStrtFsclYearPerd <= INVPR.MatlPrcValdtyStrtFsclYearPerd and _ACT.MatlPrcValdtyEndFsclYearPeriod >= INVPR.MatlPrcValdtyEndFsclYearPeriod
[0..1] I_MaterialLedgerPrice _MAP _MAP.CostEstimate = INVPR.CostEstimate and _MAP.CurrencyRole = INVPR.CurrencyRole and _MAP.Ledger = INVPR.Ledger and _MAP.CompanyCode = INVPR.CompanyCode and _MAP.ValuationArea = INVPR.ValuationArea and _MAP.MaterialPriceType = 'MAP' and _MAP.MaterialPriceSubtype = '' and _MAP.MatlPrcValdtyStrtFsclYearPerd <= INVPR.MatlPrcValdtyStrtFsclYearPerd and _MAP.MatlPrcValdtyEndFsclYearPeriod >= INVPR.MatlPrcValdtyEndFsclYearPeriod
[0..1] I_MaterialLedgerPrice _FSTDCE _FSTDCE.CostEstimate = INVPR.CostEstimate and _FSTDCE.CurrencyRole = INVPR.CurrencyRole and _FSTDCE.Ledger = INVPR.Ledger and _FSTDCE.CompanyCode = INVPR.CompanyCode and _FSTDCE.ValuationArea = INVPR.ValuationArea and _FSTDCE.MaterialPriceType = 'FSTDCE' and _FSTDCE.MaterialPriceSubtype = '' and _FSTDCE.MatlPrcValdtyStrtFsclYearPerd = INVPR.MatlPrcValdtyStrtFsclYearPerd

Annotations (6)

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

Fields (49)

KeyFieldSource TableSource FieldDescription
KEY CostEstimate ckmlpr kalnr
KEY LedgerValuationCurrencyRole I_MatlLedgerValnCrcyRoleName LedgerValuationCurrencyRole
KEY FiscalYear ckmlcr bdatj
KEY FiscalPeriod ckmlcr poper
KEY ValuationArea ckmlhd bwkey
KEY Material ckmlhd matnr
KEY InventoryValuationType ckmlhd bwtar
InvtryValnSpecialStockType ckmlhd sobkz
SalesOrder ckmlhd vbeln
SalesOrderItem ckmlhd posnr
Supplier ckmlhd lifnr
WBSElementInternalID ckmlhd pspnr
WBSElementExternalID _WBSElementBasicData WBSElementExternalID
FiscalYearPeriod
InventorySpecialStockValnType ckmlhd kzbws
PriceDeterminationControl
FuturePrice
FuturePriceValidityStartDate
FuturePlannedPrice ckmlpr zplpr
MaterialPriceControl
MaterialPriceUnitQty ckmlcr peinh
MovingAveragePrice ckmlcr pvprs
StandardPrice ckmlcr stprs
Currency ckmlcr waers
CostEstimate
KEY LedgerValuationCurrencyRole I_MatlLedgerValnCrcyRoleName LedgerValuationCurrencyRole
KEY FiscalYear I_MaterialLedgerPrice MatlPrcValidityStartFiscalYear
KEY FiscalPeriod I_MaterialLedgerPrice MatlPrcValdtyStartFiscalPeriod
KEY ValuationArea I_MaterialLedgerPrice ValuationArea
KEY Material I_MaterialLedgerPrice Material
KEY InventoryValuationType I_MaterialLedgerPrice InventoryValuationType
InvtryValnSpecialStockType I_MaterialLedgerPrice InvtryValnSpecialStockType
SalesOrder ckmlhd vbeln
SalesOrderItem ckmlhd posnr
Supplier ckmlhd lifnr
WBSElementInternalID ckmlhd pspnr
WBSElementExternalID _WBSElementBasicData WBSElementExternalID
FiscalYearPeriod I_MaterialLedgerPrice MatlPrcValdtyStrtFsclYearPerd
InventorySpecialStockValnType ckmlhd kzbws
PriceDeterminationControl
FuturePrice I_MaterialLedgerPrice MaterialPrice
FuturePriceValidityStartDate I_MaterialLedgerPrice MaterialPriceValidityStartDate
FuturePlannedPrice _FSTDCE MaterialPrice
MaterialPriceControl I_MaterialLedgerPrice MaterialPriceControl
MaterialPriceUnitQty I_MaterialLedgerPrice MaterialPriceUnitQty
MaterialPrice0endasMovingAveragePrice
MaterialPrice0endasStandardPrice
Currency I_MaterialLedgerPrice Currency
_WBSElementBasicData _WBSElementBasicData
@AbapCatalog.sqlViewName: 'PMATVALMGMCKML'
@VDM.private: true
@VDM.viewType: #BASIC
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view P_Matval_Manage_Ckml
  // use ckmlpr, because it exists also for header of split valuated material

  as select from    ckmlpr                         as pr
    inner join      R_MatlPriceDataMigrationStatus as tf   on(
        tf.MatlPriceDataMigrationStatus                                                      = 'X'
      )
                                                           or(
                                                             tf.MatlPriceDataMigrationStatus = 'R'
                                                           )
    left outer join ckmlhd                         as hd   on hd.kalnr = pr.kalnr
    left outer join mbew                           as m    on  m.kaln1 = pr.kalnr // for mother segment

                                                           and m.bwtar is initial
                                                           and m.bwtty is not initial
    inner join      t001k                          as tk   on tk.bwkey = hd.bwkey
                                                           or tk.bwkey = m.bwkey
    inner join      I_MatlLedgerValnCrcyRoleName   as lvcr on  lvcr.CompanyCode  = tk.bukrs // duplicate entries for additional ledgers

                                                           and lvcr.CurrencyRole = pr.curtp
    left outer join ckmlcr                         as cr   on  cr.kalnr  = pr.kalnr
                                                           and cr.curtp  = pr.curtp
                                                           and cr.untper = '000'
  association [0..1] to I_WBSElementBasicData as _WBSElementBasicData on hd.pspnr = _WBSElementBasicData.WBSElementInternalID
{
  key pr.kalnr                                      as CostEstimate,
  key lvcr.LedgerValuationCurrencyRole              as LedgerValuationCurrencyRole,
  key cr.bdatj                                      as FiscalYear,
  key cr.poper                                      as FiscalPeriod,
  key hd.bwkey                                      as ValuationArea,
  key hd.matnr                                      as Material,
  key hd.bwtar                                      as InventoryValuationType,

      hd.sobkz                                      as InvtryValnSpecialStockType,
      hd.vbeln                                      as SalesOrder,
      hd.posnr                                      as SalesOrderItem,
      hd.lifnr                                      as Supplier,
      hd.pspnr                                      as WBSElementInternalID,
      _WBSElementBasicData.WBSElementExternalID     as WBSElementExternalID,
      concat(cr.bdatj, cr.poper)                    as FiscalYearPeriod,

      hd.kzbws                                      as InventorySpecialStockValnType,
      cast(hd.mlast as fml_abst)                    as PriceDeterminationControl,

      cast(pr.zkprs as fml_dzkprs)                  as FuturePrice,
      cast(pr.zprsdat as fml_zprsdat)               as FuturePriceValidityStartDate,
      pr.zplpr                                      as FuturePlannedPrice,

      cast(cr.vprsv as inventoryvaluationprocedure) as MaterialPriceControl,
      cr.peinh                                      as MaterialPriceUnitQty,
      cr.pvprs                                      as MovingAveragePrice,
      cr.stprs                                      as StandardPrice,

      cr.waers                                      as Currency,

      _WBSElementBasicData
}
where
         pr.sdm_version                  is initial

  and(
         tf.MatlPriceDataMigrationStatus =                                              'X'

    or(
         hd.price_sdm_yearper            =                                              '0000000'

      or hd.price_sdm_yearper            >                                              concat(
                                cr.bdatj, cr.poper
                                )
    )
  )

union all select from I_MaterialLedgerPrice          as price
  inner join          R_MatlPriceDataMigrationStatus as tf    on(
       tf.MatlPriceDataMigrationStatus                                                          = 'F'
     )
                                                              or(
                                                                tf.MatlPriceDataMigrationStatus = 'R'
                                                              )
// get unique CURTP

  inner join          I_MatlLedgerValnCrcyRoleName   as lvcr  on  lvcr.CompanyCode  = price.CompanyCode
                                                              and lvcr.Ledger       = price.Ledger
                                                              and lvcr.CurrencyRole = price.CurrencyRole
// price_type = INVPR

  left outer join     I_MaterialLedgerPrice          as INVPR on  price.CostEstimate         = INVPR.CostEstimate
                                                              and price.Ledger               = INVPR.Ledger
                                                              and price.CurrencyRole         = INVPR.CurrencyRole
                                                              and price.CompanyCode          = INVPR.CompanyCode
                                                              and price.ValuationArea        = INVPR.ValuationArea
                                                              and INVPR.MaterialPriceType    = 'INVPR'
                                                              and INVPR.MaterialPriceSubtype = ''

  left outer join     ckmlhd                         as hd    on price.CostEstimate = hd.kalnr

association [0..1] to I_WBSElementBasicData as _WBSElementBasicData on  hd.pspnr = _WBSElementBasicData.WBSElementInternalID
association [0..1] to I_MaterialLedgerPrice as _STDPR               on  price.CostEstimate                    =  _STDPR.CostEstimate
                                                                    and price.Ledger                          =  _STDPR.Ledger
                                                                    and price.CurrencyRole                    =  _STDPR.CurrencyRole
                                                                    and price.CompanyCode                     =  _STDPR.CompanyCode
                                                                    and price.ValuationArea                   =  _STDPR.ValuationArea
                                                                    and _STDPR.MaterialPriceType              =  'STDPR'
                                                                    and _STDPR.MaterialPriceSubtype           =  ''
                                                                    and _STDPR.MatlPrcValdtyStrtFsclYearPerd  <= INVPR.MatlPrcValdtyStrtFsclYearPerd
                                                                    and _STDPR.MatlPrcValdtyEndFsclYearPeriod >= INVPR.MatlPrcValdtyEndFsclYearPeriod
association [0..1] to I_MaterialLedgerPrice as _ACT                 on  _ACT.CostEstimate                   =  INVPR.CostEstimate
                                                                    and _ACT.CurrencyRole                   =  INVPR.CurrencyRole
                                                                    and _ACT.Ledger                         =  INVPR.Ledger
                                                                    and _ACT.CompanyCode                    =  INVPR.CompanyCode
                                                                    and _ACT.ValuationArea                  =  INVPR.ValuationArea
                                                                    and _ACT.MaterialPriceType              =  'ACT'
                                                                    and _ACT.MaterialPriceSubtype           =  'ACT'
                                                                    and _ACT.MatlPrcValdtyStrtFsclYearPerd  <= INVPR.MatlPrcValdtyStrtFsclYearPerd
                                                                    and _ACT.MatlPrcValdtyEndFsclYearPeriod >= INVPR.MatlPrcValdtyEndFsclYearPeriod
association [0..1] to I_MaterialLedgerPrice as _MAP                 on  _MAP.CostEstimate                   =  INVPR.CostEstimate
                                                                    and _MAP.CurrencyRole                   =  INVPR.CurrencyRole
                                                                    and _MAP.Ledger                         =  INVPR.Ledger
                                                                    and _MAP.CompanyCode                    =  INVPR.CompanyCode
                                                                    and _MAP.ValuationArea                  =  INVPR.ValuationArea
                                                                    and _MAP.MaterialPriceType              =  'MAP'
                                                                    and _MAP.MaterialPriceSubtype           =  ''
                                                                    and _MAP.MatlPrcValdtyStrtFsclYearPerd  <= INVPR.MatlPrcValdtyStrtFsclYearPerd
                                                                    and _MAP.MatlPrcValdtyEndFsclYearPeriod >= INVPR.MatlPrcValdtyEndFsclYearPeriod
association [0..1] to I_MaterialLedgerPrice as _FSTDCE              on  _FSTDCE.CostEstimate                  = INVPR.CostEstimate
                                                                    and _FSTDCE.CurrencyRole                  = INVPR.CurrencyRole
                                                                    and _FSTDCE.Ledger                        = INVPR.Ledger
                                                                    and _FSTDCE.CompanyCode                   = INVPR.CompanyCode
                                                                    and _FSTDCE.ValuationArea                 = INVPR.ValuationArea
                                                                    and _FSTDCE.MaterialPriceType             = 'FSTDCE'
                                                                    and _FSTDCE.MaterialPriceSubtype          = ''
                                                                    and _FSTDCE.MatlPrcValdtyStrtFsclYearPerd = INVPR.MatlPrcValdtyStrtFsclYearPerd


{
  key price.CostEstimate,
  key lvcr.LedgerValuationCurrencyRole          as LedgerValuationCurrencyRole,
  key INVPR.MatlPrcValidityStartFiscalYear      as FiscalYear,
  key INVPR.MatlPrcValdtyStartFiscalPeriod      as FiscalPeriod,
  key price.ValuationArea,
  key price.Material,
  key price.InventoryValuationType,

      price.InvtryValnSpecialStockType,
      hd.vbeln                                  as SalesOrder,
      hd.posnr                                  as SalesOrderItem,
      hd.lifnr                                  as Supplier,
      hd.pspnr                                  as WBSElementInternalID,
      _WBSElementBasicData.WBSElementExternalID as WBSElementExternalID,

      INVPR.MatlPrcValdtyStrtFsclYearPerd       as FiscalYearPeriod,

      hd.kzbws                                  as InventorySpecialStockValnType,
      cast(hd.mlast as fml_abst)                as PriceDeterminationControl,

      price.MaterialPrice                       as FuturePrice,
      price.MaterialPriceValidityStartDate      as FuturePriceValidityStartDate,
      _FSTDCE.MaterialPrice                     as FuturePlannedPrice,

      INVPR.MaterialPriceControl                as MaterialPriceControl,
      price.MaterialPriceUnitQty                as MaterialPriceUnitQty,


      case INVPR.MaterialPriceControl
        when 'S'
            then case hd.mlast
                when '2' then coalesce(_MAP.MaterialPrice,0)
                when '3' then coalesce(_ACT.MaterialPrice,0)
            end
        when 'V'
            then coalesce(INVPR.MaterialPrice,0)
        end                                     as MovingAveragePrice,

      case INVPR.MaterialPriceControl
        when 'S' then coalesce(INVPR.MaterialPrice,0)
        else coalesce(_STDPR.MaterialPrice,0)
        end                                     as StandardPrice,

      price.Currency                            as Currency,

      _WBSElementBasicData
}

where
           price.MaterialPriceType              =  'FUTURE'

  and(
           tf.MatlPriceDataMigrationStatus      =  'F'

    or(
           hd.price_sdm_yearper                 <> '0000000'
      and(
           hd.price_sdm_yearper                 <= INVPR.MatlPrcValdtyStrtFsclYearPerd
        or INVPR.MatlPrcValidityStartFiscalYear is null
      )
    )
  )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_MATERIALLEDGERPRICE",
"I_MATLLEDGERVALNCRCYROLENAME",
"I_WBSELEMENTBASICDATA",
"R_MATLPRICEDATAMIGRATIONSTATUS",
"CKMLCR",
"CKMLHD",
"CKMLPR",
"MBEW",
"T001K"
],
"ASSOCIATED":
[
"I_WBSELEMENTBASICDATA"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/