@AbapCatalog.sqlViewName: 'IBATCHVH'
@AbapCatalog.preserveKey: true
@AbapCatalog.compiler.compareFilter: true
@EndUserText.label: 'Batch'
@AccessControl.authorizationCheck: #CHECK
@ObjectModel.dataCategory: #VALUE_HELP
@ObjectModel.usageType.sizeCategory: #L
@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.dataClass:#MASTER
@ObjectModel.representativeKey: 'Batch'
@ClientHandling.algorithm: #SESSION_VARIABLE
@Search.searchable: true
@Consumption.ranked: true
@VDM.private: false
@VDM.viewType: #COMPOSITE
@VDM.lifecycle.contract.type: #PUBLIC_LOCAL_API
define view I_BatchVH as select from I_BatchCrossPlant
inner join I_BatchConfiguration on DefinitionOfBatchLevel <> '0'
association [0..1] to I_Plant as _Plant on $projection.Plant = _Plant.Plant
association [1..1] to I_Product as _Product on $projection.Material = _Product.Product
association [0..1] to I_ClfnObjectClassForKeyDate as _ClfnObjectClassForKeyDate on $projection.ClfnObjectInternalID = _ClfnObjectClassForKeyDate.ClfnObjectInternalID
association [0..*] to I_ClfnObjectCharcValForKeyDate as _ClfnObjectCharcValForKeyDate on $projection.ClfnObjectInternalID = _ClfnObjectCharcValForKeyDate.ClfnObjectInternalID
{
@ObjectModel.foreignKey.association: '_Plant'
--cannot be added to search (BC_CDSSRCH/021)
--reason: defaulting by empty literal (in case of MCH1)
--@Search.defaultSearchElement: true
--@Search.fuzzinessThreshold: 0.8
--@Search.ranking: #LOW
key cast(' ' as werks_d preserving type) as Plant,
@ObjectModel.foreignKey.association: '_Product'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
key Material,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #HIGH
key Batch,
BatchIsMarkedForDeletion,
MatlBatchIsInRstrcdUseStock,
@ObjectModel.foreignKey.association: '_Supplier'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
Supplier,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
BatchBySupplier,
@ObjectModel.foreignKey.association: '_CountryOfOrigin'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
CountryOfOrigin,
@ObjectModel.foreignKey.association: '_RegionOfOrigin'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
RegionOfOrigin,
MatlBatchAvailabilityDate,
ShelfLifeExpirationDate,
ManufactureDate,
FreeDefinedDate1,
FreeDefinedDate2,
FreeDefinedDate3,
FreeDefinedDate4,
FreeDefinedDate5,
FreeDefinedDate6,
DefinitionOfBatchLevel,
@Semantics.systemDateTime.createdAt: true
CreationDateTime,
@Semantics.systemDateTime.lastChangedAt: true
LastChangeDateTime,
ClfnObjectInternalID,
BatchExtWhseMgmtInternalId,
_Plant,
_Material,
_Supplier,
_CountryOfOrigin,
_RegionOfOrigin,
_Product,
_ClfnObjectClassForKeyDate,
_ClfnObjectCharcValForKeyDate
}
union all
// Perform an inner join with I_BatchConfiguration to ensure that data is only returned of the customer
// has customized the batch configuration to not use I_BatchCrossPlant. (Only possible in OnPremise)
select from I_BatchPlant
inner join I_BatchConfiguration on DefinitionOfBatchLevel = '0'
inner join I_MaterialPlant on I_BatchPlant.Plant = I_MaterialPlant.Plant
and I_BatchPlant.Material = I_MaterialPlant.Material
association [1..1] to I_Product as _Product on $projection.Material = _Product.Product
association [0..1] to I_ClfnObjectClassForKeyDate as _ClfnObjectClassForKeyDate on $projection.ClfnObjectInternalID = _ClfnObjectClassForKeyDate.ClfnObjectInternalID
association [0..*] to I_ClfnObjectCharcValForKeyDate as _ClfnObjectCharcValForKeyDate on $projection.ClfnObjectInternalID = _ClfnObjectCharcValForKeyDate.ClfnObjectInternalID
{
@ObjectModel.foreignKey.association: '_Plant'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
key I_BatchPlant.Plant,
@ObjectModel.foreignKey.association: '_Product'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
key I_BatchPlant.Material,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #HIGH
key Batch,
BatchIsMarkedForDeletion,
MatlBatchIsInRstrcdUseStock,
@ObjectModel.foreignKey.association: '_Supplier'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
Supplier,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
BatchBySupplier,
@ObjectModel.foreignKey.association: '_CountryOfOrigin'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
I_BatchPlant.CountryOfOrigin,
@ObjectModel.foreignKey.association: '_RegionOfOrigin'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
I_BatchPlant.RegionOfOrigin,
MatlBatchAvailabilityDate,
ShelfLifeExpirationDate,
ManufactureDate,
FreeDefinedDate1,
FreeDefinedDate2,
FreeDefinedDate3,
FreeDefinedDate4,
FreeDefinedDate5,
FreeDefinedDate6,
DefinitionOfBatchLevel,
@Semantics.systemDateTime.createdAt: true
CreationDateTime,
@Semantics.systemDateTime.lastChangedAt: true
LastChangeDateTime,
ClfnObjectInternalID,
BatchExtWhseMgmtInternalId,
I_BatchPlant._Plant,
I_BatchPlant._Material,
_Supplier,
_CountryOfOrigin,
_RegionOfOrigin,
_Product,
_ClfnObjectClassForKeyDate,
_ClfnObjectCharcValForKeyDate
}
union all
// Finally consider the case that a customer has cross-plant batches but uses the value help and searches by
// plant. In this case, both tables are filled but the main attributes are on I_BatchCrossPlant.
// This will lead to additional entries to the first read from I_BatchCrossPlant having the Plant as part of
// the key. It will not lead to additional entries if the batch is not cross-plant as I_BatchCrossPlant would
// be empty in that case and thus the result of the inner join.
select from I_BatchPlant
inner join I_BatchConfiguration on DefinitionOfBatchLevel <> '0'
inner join I_MaterialPlant on I_BatchPlant.Plant = I_MaterialPlant.Plant
and I_BatchPlant.Material = I_MaterialPlant.Material
left outer join I_BatchCrossPlant on I_BatchPlant.Material = I_BatchCrossPlant.Material and
I_BatchPlant.Batch = I_BatchCrossPlant.Batch
association [1..1] to I_Product as _Product on $projection.Material = _Product.Product
association [0..1] to I_ClfnObjectClassForKeyDate as _ClfnObjectClassForKeyDate on $projection.ClfnObjectInternalID = _ClfnObjectClassForKeyDate.ClfnObjectInternalID
association [0..*] to I_ClfnObjectCharcValForKeyDate as _ClfnObjectCharcValForKeyDate on $projection.ClfnObjectInternalID = _ClfnObjectCharcValForKeyDate.ClfnObjectInternalID
{
@ObjectModel.foreignKey.association: '_Plant'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
key I_BatchPlant.Plant,
@ObjectModel.foreignKey.association: '_Material'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
key I_BatchPlant.Material,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #HIGH
key I_BatchPlant.Batch,
I_BatchCrossPlant.BatchIsMarkedForDeletion,
I_BatchCrossPlant.MatlBatchIsInRstrcdUseStock,
@ObjectModel.foreignKey.association: '_Supplier'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
I_BatchCrossPlant.Supplier,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
I_BatchCrossPlant.BatchBySupplier,
@ObjectModel.foreignKey.association: '_CountryOfOrigin'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
I_BatchCrossPlant.CountryOfOrigin,
@ObjectModel.foreignKey.association: '_RegionOfOrigin'
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@Search.ranking: #LOW
I_BatchCrossPlant.RegionOfOrigin,
I_BatchCrossPlant.MatlBatchAvailabilityDate,
I_BatchCrossPlant.ShelfLifeExpirationDate,
I_BatchCrossPlant.ManufactureDate,
I_BatchCrossPlant.FreeDefinedDate1,
I_BatchCrossPlant.FreeDefinedDate2,
I_BatchCrossPlant.FreeDefinedDate3,
I_BatchCrossPlant.FreeDefinedDate4,
I_BatchCrossPlant.FreeDefinedDate5,
I_BatchCrossPlant.FreeDefinedDate6,
cast('1' as kzdch) as DefinitionOfBatchLevel,
@Semantics.systemDateTime.createdAt: true
I_BatchPlant.CreationDateTime,
@Semantics.systemDateTime.lastChangedAt: true
I_BatchPlant.LastChangeDateTime,
I_BatchCrossPlant.ClfnObjectInternalID,
I_BatchPlant.BatchExtWhseMgmtInternalId,
I_BatchPlant._Plant,
I_BatchPlant._Material,
I_BatchCrossPlant._Supplier,
I_BatchCrossPlant._CountryOfOrigin,
I_BatchCrossPlant._RegionOfOrigin,
_Product,
_ClfnObjectClassForKeyDate,
_ClfnObjectCharcValForKeyDate
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BATCHCONFIGURATION",
"I_BATCHCROSSPLANT",
"I_BATCHPLANT",
"I_MATERIALPLANT"
],
"ASSOCIATED":
[
"I_CLFNOBJECTCHARCVALFORKEYDATE",
"I_CLFNOBJECTCLASSFORKEYDATE",
"I_COUNTRY",
"I_MATERIAL",
"I_PLANT",
"I_PRODUCT",
"I_REGION",
"I_SUPPLIER"
],
"BASE":
[
"I_BATCHCROSSPLANT"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/