@AbapCatalog.sqlViewName: 'PMPEORIGCOMPASSY'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType: {serviceQuality: #B, sizeCategory: #XL, dataClass: #TRANSACTIONAL}
@VDM.viewType: #COMPOSITE
@VDM.private: true
define view P_MfgOrderOriglComponentAssy
as select from I_MfgOrderComponentAssembly as MfgOrderComponentAssembly
inner join I_OpActyComponentAssignment as OpActyComponentAssignment on OpActyComponentAssignment.Reservation = MfgOrderComponentAssembly.Reservation
and OpActyComponentAssignment.ReservationItem = MfgOrderComponentAssembly.ReservationItem
and OpActyComponentAssignment.RecordType = MfgOrderComponentAssembly.RecordType
and OpActyComponentAssignment.OpActyNtwkInstance = MfgOrderComponentAssembly.OpActyNtwkInstance
and OpActyComponentAssignment.OpActyNtwkElement = MfgOrderComponentAssembly.OpActyNtwkElement
inner join I_ReservationItem as ReservationItem on ReservationItem.Reservation = MfgOrderComponentAssembly.Reservation
and ReservationItem.ReservationItem = MfgOrderComponentAssembly.ReservationItem
and ReservationItem.RecordType = MfgOrderComponentAssembly.RecordType
left outer to one join I_ReservationItem as LeadingReservationItem on LeadingReservationItem.Reservation = OpActyComponentAssignment.LeadingReservation
and LeadingReservationItem.ReservationItem = OpActyComponentAssignment.LeadingReservationItem
and LeadingReservationItem.RecordType = OpActyComponentAssignment.LeadingReservationRecordType
association [1..1] to I_MfgOrder as _MfgOrder on $projection.ManufacturingOrder = _MfgOrder.ManufacturingOrder
association [0..1] to I_DebitCreditCode as _DebitCreditCode on $projection.DebitCreditCode = _DebitCreditCode.DebitCreditCode
{
//MfgOrderComponentAssembly
key MfgOrderComponentAssembly.AssemblyDocument,
key MfgOrderComponentAssembly.AssemblyDocumentItem,
--For the time being Related Reservations are alway in the same order
--> Thus, they have same ManufacturingOrder and Reservation
ReservationItem.ReferenceOrder as ManufacturingOrder,
MfgOrderComponentAssembly.Reservation,
cast(case
when OpActyComponentAssignment.LeadingReservation = '0000000000' then OpActyComponentAssignment.ReservationItem
else OpActyComponentAssignment.LeadingReservationItem
end as rspos preserving type ) as ReservationItem,
cast(case
when OpActyComponentAssignment.LeadingReservation = '0000000000' then OpActyComponentAssignment.RecordType
else OpActyComponentAssignment.LeadingReservationRecordType
end as rsart preserving type ) as RecordType,
cast(case
when OpActyComponentAssignment.LeadingReservation = '0000000000' then OpActyComponentAssignment.OpActyNtwkInstance
else OpActyComponentAssignment.LeadingOpActyNtwkInstance
end as mpe_oan_instance_id preserving type ) as OpActyNtwkInstance,
cast(case
when OpActyComponentAssignment.LeadingReservation = '0000000000' then OpActyComponentAssignment.OpActyNtwkElement
else OpActyComponentAssignment.LeadingOpActyNtwkElement
end as mpe_oan_element_number preserving type ) as OpActyNtwkElement,
MfgOrderComponentAssembly.AssemblyShopFloorItem,
MfgOrderComponentAssembly.ShopFloorItem,
MfgOrderComponentAssembly.Batch,
MfgOrderComponentAssembly.Material,
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
case ReservationItem.DebitCreditCode
when 'S' then MfgOrderComponentAssembly.MaterialComponentQuantity * -1
else MfgOrderComponentAssembly.MaterialComponentQuantity
end as MaterialComponentQuantity,
@Semantics.unitOfMeasure: true
MfgOrderComponentAssembly.MaterialBaseUnit,
cast(case
when OpActyComponentAssignment.LeadingReservation = '0000000000' then ReservationItem.DebitCreditCode
else LeadingReservationItem.DebitCreditCode
end as shkzg preserving type ) as DebitCreditCode,
MfgOrderComponentAssembly.CreationDateTime,
MfgOrderComponentAssembly.CreatedByUser,
MfgOrderComponentAssembly.Plant,
MfgOrderComponentAssembly.StorageLocation,
OpActyComponentAssignment.BOOOpBOMItemInternalID,
_MfgOrder,
MfgOrderComponentAssembly._Material,
MfgOrderComponentAssembly._MaterialBaseUnit,
MfgOrderComponentAssembly._ParentShopFloorItem,
MfgOrderComponentAssembly._Plant,
MfgOrderComponentAssembly._Reservation,
MfgOrderComponentAssembly._ShopFloorItem,
MfgOrderComponentAssembly._StorageLocation,
_DebitCreditCode
}
where
ReservationItem.MatlCompIsMarkedForBackflush = ''
and OpActyComponentAssignment.MatlCompInstceAssyIsRequired = ''
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_MFGORDERCOMPONENTASSEMBLY",
"I_OPACTYCOMPONENTASSIGNMENT",
"I_RESERVATIONITEM"
],
"ASSOCIATED":
[
"I_DEBITCREDITCODE",
"I_MATERIAL",
"I_MFGORDER",
"I_PLANT",
"I_RESERVATIONDOCUMENTHEADER",
"I_SHOPFLOORITEM",
"I_STORAGELOCATION",
"I_UNITOFMEASURE"
],
"BASE":
[
"I_MFGORDERCOMPONENTASSEMBLY"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/