@AbapCatalog.sqlViewName: 'V_MRP_PROD_DEM'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType: {serviceQuality: #C, sizeCategory: #L, dataClass: #MIXED}
define view e_mrp_prod_demands as
select from v_mrp_plan_segments as seg
inner join pph_cache_mat as mat
on seg.mandt = mat.mandt and
seg.mrpplant = mat.mrpplant and
seg.material = mat.material and
seg.mrparea = mat.mrparea
left outer join ( pph_cache_item as sdi
inner join v_mrp_reserv as res
on sdi.mandt = res.mandt and
sdi.mrpelement = res.reservation and
sdi.mrpelementitem = res.reservationitem6 and
sdi.material = res.material )
on seg.mandt = sdi.mandt and
seg.mrpplant = sdi.mrpplant and
seg.material = sdi.material and
seg.mrparea = sdi.mrparea and
seg.mrpplanningsegmenttype = sdi.mrpplanningsegmenttype and
seg.mrpplanningsegmentnumber = sdi.mrpplanningsegmentnumber and
seg.materialshortageprofile = sdi.materialshortageprofile and
( sdi.mrpelementcategory = 'AR' or
sdi.mrpelementcategory = 'SB' or
sdi.mrpelementcategory = 'SM' or
sdi.mrpelementcategory = 'SU' ) and
( sdi.sourcemrpelementcategory = 'BR' or
sdi.sourcemrpelementcategory = 'FE' or
sdi.sourcemrpelementcategory = 'IH' or
sdi.sourcemrpelementcategory = 'NE' )
left outer join ( aufk as auk
inner join afko as afk
on auk.mandt = afk.mandt and
auk.aufnr = afk.aufnr )
on sdi.mandt = auk.mandt and
sdi.sourcemrpelement = auk.aufnr
left outer join afpo as afp
on sdi.mandt = afp.mandt and
sdi.sourcemrpelement = afp.aufnr and
afp.posnr = '0001'
left outer join (mkal as prv
left outer join crhd as wkc
on wkc.mandt = prv.mandt and
wkc.objty = 'A' and
wkc.arbpl = prv.mdv01 and
wkc.werks = prv.werks and
wkc.arbpl <> ' ')
on afp.mandt = prv.mandt and
afp.matnr = prv.matnr and
afp.pwerk = prv.werks and
afp.verid = prv.verid
left outer join mdlv as mdl
on seg.mandt = mdl.mandt and
seg.mrparea = mdl.berid
left outer join v_mrp_plan_plant as pln
on seg.mandt = pln.mandt and
seg.mrpplant = pln.werks
left outer join t006 as uom
on mat.mandt = uom.mandt and
mat.materialbaseunit = uom.msehi
left outer join t024d as dis
on mat.mandt = dis.mandt and
mat.mrpplant = dis.werks and
mat.mrpcontroller = dis.dispo
left outer join t024f as fev
on afp.mandt = fev.mandt and
afp.dwerk = fev.werks and
afk.fevor = fev.fevor
{ seg.mandt,
seg.mrpplanningsegmenttype,
seg.mrpplanningsegmentnumber,
seg.mrpplanningsegmentID,
seg.mrpplanningsegmentitem,
mat.material,
mat.mrparea,
mdl.bertx as mrpareatext,
mat.mrpplant,
pln.name1 as mrpplantname,
mat.mrpcontroller,
dis.dsnam as mrpcontrollername,
mat.materialsafetystockqty,
mat.materialbaseunit,
uom.andec as quantityprecision,
uom.decan as targetquantityunitdisplaydcmls,
mat.materialprocurementcategory,
mat.materialreplnmtleaddurnenddate,
mat.totalreplnmtleaddurnenddate,
mat.manualplanninghorizonenddate,
mat.mrpsafetydurationenddate,
sdi.mrpelementcategory,
sdi.mrpelement,
sdi.mrpelementitem,
sdi.mrpelementscheduleline,
sdi.materialshortageprofile,
sdi.materialshortageprof_cnt,
sdi.mrpelementavailyorrqmtdate,
sdi.mrpelementopenquantity,
sdi.sourcemrpelementcategory,
sdi.sourcemrpelement,
sdi.sourcemrpelementitem,
sdi.mrpelementtypeimportance,
sdi.mrpelementuncoveredquantity,
sdi.mrpelementdelayedquantity,
sdi.maximumdelaydate as maximumdelay,
sdi.maximumdelayindays,
sdi.maximumdelayinworkdays,
sdi.procurementprogressindicator,
sdi.storagelocation,
sdi.issuingorreceivingplant as productionplant,
4 as demandtype,
auk.auart as ordertype,
res.requiredquantity as orderquantity,
coalesce(afp.matnr, '') as producedmaterial,
coalesce(afk.fevor, '') as productionsupervisor,
coalesce(fev.txt, '') as productionsupervisorname,
coalesce(afp.verid, '') as productionversion,
coalesce(prv.text1, '') as productionversiontext,
coalesce(prv.mdv01, '') as productionline,
// coalesce(wkc.objid, '') as productionlineinternalid
'' as productionlineinternalid
};