@AccessControl.authorizationCheck: #NOT_REQUIRED
@AccessControl.privilegedAssociations: ['_MRPController', '_ProductionSup']
@VDM.viewType: #CONSUMPTION
@VDM.private: true
@EndUserText.label: 'Private view for Material pop over'
define view entity P_MPEMaterial
with parameters
@Consumption.hidden: true
@Environment.systemField: #SYSTEM_LANGUAGE
P_Language : sylangu
as select from I_ProductPlant as _ProductPlant
left outer join P_MPE_MaterialStorageLocation as _StgLoc on _ProductPlant.Product = _StgLoc.Product
and _ProductPlant.Plant = _StgLoc.Plant
association [1..1] to I_Product as _Product on $projection.Material = _Product.Product
association [1..1] to I_ProductDescription as _ProductDS on _ProductDS.Product = $projection.Material
and _ProductDS.Language = $parameters.P_Language
association [1..1] to I_MRPController as _MRPController on _MRPController.Plant = $projection.Plant //1
and _MRPController.MRPController = _ProductPlant.MRPResponsible
association [1..1] to I_MatlProcurementCategoryText as _ProcurementText on _ProcurementText.MaterialProcurementCategory = _ProductPlant.ProcurementType
and _ProcurementText.Language = $parameters.P_Language
association [1..1] to P_MPE_MaterialStockQuantity as _ProductStock on _ProductStock.Material = $projection.Material
and _ProductStock.Plant = $projection.Plant
and _ProductStock.StorageLocation = $projection.StorageLocation
association [1..1] to I_Plant as _Plant on _Plant.Plant = $projection.Plant
association [1..1] to I_MPESrlNmbPrfText as _SerialNumberText on _SerialNumberText.SerialNumberProfile = _ProductPlant.SerialNumberProfile
and _SerialNumberText.Language = $parameters.P_Language
association [1..1] to I_MRPTypeText as _MRPText on _MRPText.MRPType = _ProductPlant.MRPType
and _MRPText.Language = $parameters.P_Language
association [1..1] to I_ProductionSupervisor as _ProductionSup on _ProductionSup.Plant = $projection.Plant
and _ProductionSup.ProductionSupervisor = _ProductPlant.ProductionSupervisor //2
association[1..1] to P_MPE_MaterialPlantStkQty as _PlantStock on $projection.Material = _PlantStock.Material
and $projection.Plant = _PlantStock.Plant
and $projection.StorageLocation = ''
association[1..1] to P_MPE_MaterialPlantSalesStkQty as _PlantSalesStock on $projection.Material = _PlantSalesStock.Material
and $projection.Plant = _PlantSalesStock.Plant
and $projection.StorageLocation = ''
association[1..1] to P_MPE_MaterialPlantWBSStkQty as _PlantWBSSTock on $projection.Material = _PlantWBSSTock.Material
and $projection.Plant = _PlantWBSSTock.Plant
and $projection.StorageLocation = ''
{
// "Material"
// Material Number
key _ProductPlant.Product as Material,
key _ProductPlant.Plant as Plant,
key _StgLoc.StorageLocation,
_StgLoc.StorageLocationName,
// Plant Description
_Plant.PlantName as ProductionPlant,
_ProductPlant.Plant as MRPPlant,
// MRPArea
// case when _MRPArea.Material = _ProductPlant.Product then _MRPArea.MRPArea else _ProductPlant.Plant end as MRPArea,
// Material Description
_ProductDS.ProductDescription,
_MRPController.MRPController,
_MRPController.MRPControllerName,
_MRPController.MRPControllerPhoneNumber,
_ProductPlant.ProductionSupervisor,
_ProductionSup.ProductionSupervisorName,
// MRP Type
_ProductPlant.MRPType,
_MRPText.MRPTypeName,
// Current Stock in PLant
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantStock.UnrestrinctedStock
else _ProductStock.UnrestrinctedStock
end as nsdm_stock_qty) as VltdUnrestrictedUseStkQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantStock.QualityInspectionStock
else _ProductStock.QualityInspectionStock
end as insme) as QualityInspectionStockQuantity,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantStock.StockInTrsferrStgeLoc
else _ProductStock.StockInTrsferrStgeLoc
end as stockintransferquantity) as TransferStockStorageLocQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantStock.StockInTrsferrPlant
else _ProductStock.StockInTrsferrPlant
end as stockintransferquantity) as StockInTransferQuantity,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantStock.RestricktedUserStock
else _ProductStock.RestricktedUserStock
end as einme) as RestrictedStockQuantity,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
case when _StgLoc.StorageLocation = ''
then _PlantStock.BlockedStock
else _ProductStock.BlockedStock
end as BlockedStockQuantity,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantSalesStock.UnrestrinctedStock
else _ProductStock.SalesUnrestrictedStock
end as nsdm_stock_qty) as SalesUnrestrictedStockQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantSalesStock.QualityInspectionStock
else _ProductStock.SalesQualityInspectionStock
end as insme) as SalesQualityInspectionStockQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantSalesStock.StockInTrsferrStgeLoc
else _ProductStock.SalesStockInTrsferrStgeLoc
end as stockintransferquantity) as SlsStkInTransfStorLocStockQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantSalesStock.StockInTrsferrPlant
else _ProductStock.SalesStockInTrsferrPlant
end as stockintransferquantity) as SalesStockInTransfPlntStockQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantSalesStock.RestricktedUserStock
else _ProductStock.SalesRestricktedUserStock
end as einme) as SalesRestrictedUserStockQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
case when _StgLoc.StorageLocation = ''
then _PlantSalesStock.BlockedStock
else _ProductStock.SalesBlockedStock
end as SalesBlockedStockQuantity,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantWBSSTock.UnrestrinctedStock
else _ProductStock.WBSUnrestrictedStock
end as nsdm_stock_qty) as ProjStkUnrestrictedUseStkQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantWBSSTock.QualityInspectionStock
else _ProductStock.WBSQualityInspectionStock
end as insme) as ProjectQualityInspectionStkQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantWBSSTock.StockInTrsferrStgeLoc
else _ProductStock.WBSStockInTrsferrStgeLoc
end as stockintransferquantity) as ProjStkInTransfStorLocStkQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantWBSSTock.StockInTrsferrPlant
else _ProductStock.WBSStockInTrsferrPlant
end as stockintransferquantity) as ProjectStockInTransfPlntStkQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
cast(case when _StgLoc.StorageLocation = ''
then _PlantWBSSTock.RestricktedUserStock
else _ProductStock.WBSRestricktedUserStock
end as einme) as ProjectRestrictedUserStockQty,
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@DefaultAggregation : #SUM
case when _StgLoc.StorageLocation = ''
then _PlantWBSSTock.BlockedStock
else _ProductStock.WBSBlockedStock
end as ProjectBlockedStockQuantity,
// "Material Master Data"
// Production Scheduling Profile
_ProductPlant.ProductionSchedulingProfile,
// Serial Number Profile
_ProductPlant.SerialNumberProfile,
_SerialNumberText.SerialNumberProfileName,
// Batch Management Required (Indicator)
_Product.IsApprovedBatchRecordReqd,
// Tolerance Data (under-/Over delivery)
@Semantics.quantity.unitOfMeasure: 'DeliveryToleranceUnit'
_ProductPlant.UnderDelivToleranceLimit,
@Semantics.quantity.unitOfMeasure: 'DeliveryToleranceUnit'
_ProductPlant.OverDelivToleranceLimit,
// Procurement Type
_ProcurementText.MaterialProcurementCatName,
// Special Procurement Key
_ProductPlant.SpecialProcurementType,
// Safety Stock
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
_ProductPlant.SafetyStockQuantity,
cast('%' as unit) as DeliveryToleranceUnit,
_Product.BaseUnit,
_ProductPlant.MRPResponsible,
_ProductPlant.ProcurementType,
_Product,
_MRPController,
_ProductionSup
}
where _ProductPlant.Product != ''