Pir_Keyfigures_Read_For_Sum is a CDS View that provides data about "Read PIR Keyfigures" in SAP S/4HANA. It reads from 4 data sources (mara, marc, Pir_All_Attributes, sdm_aor) and exposes 26 fields with key fields uname, matnr, werks, berid, bedae.
@AbapCatalog.sqlViewName: 'PIR_V_RD_SUM'
@AccessControl.authorizationCheck: #NOT_REQUIRED@ClientHandling.algorithm: #AUTOMATED@ObjectModel.usageType: {serviceQuality: #X, sizeCategory: #L, dataClass: #MIXED}@AbapCatalog.compiler.compareFilter: true@EndUserText.label: 'Read PIR Keyfigures'
defineview Pir_Keyfigures_Read_For_Sum asselectfrom marc
innerjoin mara on marc.matnr = mara.matnr
innerjoin sdm_aor on sdm_aor.werks = marc.werks
and sdm_aor.dispo = marc.dispo
leftouterjoin Pir_All_Attributes as pir
on pir.matnr = marc.matnr
and pir.werks = marc.werks
leftouter to one join Pir_Item_Calc_Att as pir_calc
on pir.bdzei = pir_calc.bdzei
leftouter to one join t141 as t141_marc on t141_marc.mmsta = marc.mmsta
leftouter to one join t141 as t141_mara on t141_mara.mmsta = mara.mstae
leftouter to one join t461p on t461p.strgr = marc.strgr
leftouter to one join t461s on t461s.stra1 = t461p.hptst
{
key sdm_aor.uname,
key marc.matnr,
key marc.werks,
key coalesce(pir.berid, cast( marc.werks as berid)) as berid,
key coalesce(pir.bedae, t461s.bedvp) as bedae,
key coalesce(pir.versb, '00') as versb, -- Default for Version is '00' if not yet existing
key coalesce(cast(pir.per_sdat as pph_per_sdat),'00010101') as per_sdat,
casewhen pir.released = '' or pir.plan_qty isnullthen '00010101'
else pir.per_edat
endas start_date_for_max, -- for later determination of reach we only want the dates where we have released planned quantity
casewhen ( marc.strgr = '' or mara.lvorm = 'X' or marc.lvorm = 'X' or t141_marc.dpbed = 'B' or t141_mara.dpbed = 'B' )
and ( pir.plan_qty > pir.withdr_qty )
then 'X'
else ''
endas forecast_is_superfluous, -- forecast open quantity should not exist if no strgr or material is deleted ornot released for forecast maintainence
casewhen marc.strgr <> '' and mara.lvorm = '' and marc.lvorm = ''
and ( t141_marc.dpbed <> 'B' or t141_marc.dpbed isnull) and ( t141_mara.dpbed <> 'B' or t141_mara.dpbed isnull )
and (pir.bedae isnotnullor t461s.bedvp isnotnull)
then 'X'
else ''
endas forecast_is_needed, -- forecast needed if strgr <> '' and released for maintenance and a requirements type is found via strategy group
pir.bdzei,
marc.perkz as perkz_master,
coalesce(pir.perkz_item,'') as perkz_item,
cast(pir.per_edat as pph_per_edat) as per_edat,
casewhen pir_calc.period_is_invalid <> 0 then pir_calc.period_is_invalid
elsecasewhen marc.perkz <> 'M' and marc.perkz <> 'W' then 1
else 0
endendas period_is_invalid,
pir.loevr,
pir.acc_past,
pir.draft_qty,
pir.plan_qty,
pir.withdr_qty,
pir.open_qty,
pir.meins as item_meins,
pir.pdatu,
marc.lvorm as marc_lvorm,
mara.lvorm as mara_lvorm,
mara.meins as mara_meins,
t141_marc.dpbed as marc_dpbed,
t141_mara.dpbed as mara_dpbed,
0 as lastchange,
pir.laeda as last_change_dats,
pir.aenam,
marc.dispo
}