@EndUserText.label: 'Transaction History of In-House Repair Item'
@VDM: {
viewType: #CONSUMPTION
}
@AccessControl: {
authorizationCheck: #MANDATORY,
personalData.blocking: #('TRANSACTIONAL_DATA')
}
@ObjectModel: {
usageType: {serviceQuality: #C, sizeCategory: #XXL, dataClass: #MIXED}
}
@Metadata: {
ignorePropagatedAnnotations: true,
allowExtensions: true
}
@ClientHandling: {
algorithm: #SESSION_VARIABLE
}
@AbapCatalog: {
sqlViewName: 'CINHRPRPROCFLW',
compiler.compareFilter: true
}
define view C_InhRepairProcessFlow
// In-House Repair Items and Repair Orders
as select from I_InHouseRepairItem as repobj
// there is at most one VONA relation to a service quotation or service order for each repair object
// this is a left outer join, beacause when there is no service quotation and no order we still want to return a record for the repair object
left outer to one join I_CustMgmtTransactionRelation as relX on relX.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relX.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relX.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relX.CustMgmtTransacRelationType = 'VONA'
// we have to read the object ID for the service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relX.CustMgmtSuccssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relX.CustMgmtSuccssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
// find the service documents other ihr relevant predecessors
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to P_SrvcDocIhrPrdcssrRelation as _relPred on _relPred.SuccssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and _relPred.IhrPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
// find cyclic relations with direct two way VONA between service documents
association [0..1] to P_CustMgmtTransPredSuccRel as _relCycle on _relCycle.PrdcssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and _relCycle.SuccssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and _relCycle.PrdcssrTransactionObjType = 'BUS2000116'
and _relCycle.TransactionObjType = 'BUS2000116'
and _relCycle.PrdcssrTransactionRelType = 'VONA'
and _relCycle.SuccssrTransactionRelType = 'VONA'
{
key repobj.InHouseRepair as PrecedingDocument,
key 'REPA' as PrecedingDocumentCategory,
key _SuccessorServiceTransaction.ServiceDocument as SubsequentDocument,
key 'CSVO' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
cast('' as crmt_subobject_category_db) as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// only orders and ignore if service document also has other service document predecessors
where ( _SuccessorServiceTransaction.ServiceDocumentIsQuotation = '' and _relPred.mandt is null ) // mandt is null means that there are no associations found
// exception: other predecessor exist but are coming from a cycle (diagnosis case), so it's ok
or ( _SuccessorServiceTransaction.ServiceDocumentIsQuotation = '' and _relPred.mandt is not null and _relCycle.mandt is not null )
// In-House Repair Items and Repair Quotations
union all select from I_InHouseRepairItem as repobj
// there is at most one VONA relation to a service quotation or service order for each repair object
// this is a left outer join, beacause when there is no service quotation and no order we still want to return a record for the repair object
left outer to one join I_CustMgmtTransactionRelation as relX on relX.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relX.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relX.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relX.CustMgmtTransacRelationType = 'VONA'
// we have to read the object ID for the service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relX.CustMgmtSuccssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relX.CustMgmtSuccssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
// find the service documents other ihr relevant predecessors
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to P_SrvcDocIhrPrdcssrRelation as _relPred on _relPred.SuccssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and _relPred.IhrPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
// find cyclic relations with direct two way VONA between service documents
association [0..1] to P_CustMgmtTransPredSuccRel as _relCycle on _relCycle.PrdcssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and _relCycle.SuccssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and _relCycle.PrdcssrTransactionObjType = 'BUS2000116'
and _relCycle.TransactionObjType = 'BUS2000116'
and _relCycle.PrdcssrTransactionRelType = 'VONA'
and _relCycle.SuccssrTransactionRelType = 'VONA'
{
key repobj.InHouseRepair as PrecedingDocument,
key 'REPA' as PrecedingDocumentCategory,
key _SuccessorServiceTransaction.ServiceDocument as SubsequentDocument,
key 'REPQ' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
cast('' as crmt_subobject_category_db) as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// only quotations and ignore if service document also has other service document predecessors
where ( _SuccessorServiceTransaction.ServiceDocumentIsQuotation = 'X' and _relPred.mandt is null )
// exception: other predecessor exist but are coming from a cycle (diagnosis case), so it's ok
or ( _SuccessorServiceTransaction.ServiceDocumentIsQuotation = 'X' and _relPred.mandt is not null and _relCycle.mandt is not null )
// In-House Repair Items without succesor
union all select from I_InHouseRepairItem as repobj
// there is at most one VONA relation to a service quotation or service order for each repair object
// this is a left outer join, beacause when there is no service quotation and no order we still want to return a record for the repair object
left outer to one join I_CustMgmtTransactionRelation as relX on relX.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relX.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relX.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relX.CustMgmtTransacRelationType = 'VONA'
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key repobj.InHouseRepair as PrecedingDocument,
key 'REPA' as PrecedingDocumentCategory,
key '' as SubsequentDocument,
key '' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
cast('' as crmt_subobject_category_db) as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
where relX.CustMgmtSuccssrTransactionUUID is null
// Repair Quotations/Orders and In-House Repair Items
union all select from I_InHouseRepairItem as repobj
inner join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtSuccssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtTransacRelationType = 'VONA'
// we have to read the object ID for the service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _PredecessorServiceTransaction on rel1.CustMgmtPrdcssrTransactionUUID = _PredecessorServiceTransaction.ServiceDocumentUUID
and rel1.CustMgmtPrdcssrTransacObjType = _PredecessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _PredecessorServiceTransaction.ServiceDocument as PrecedingDocument,
key case _PredecessorServiceTransaction.ServiceDocumentIsQuotation
when 'X' then 'REPQ'
when ' ' then 'CSVO'
end as PrecedingDocumentCategory,
key repobj.InHouseRepair as SubsequentDocument,
key 'REPA' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_PredecessorServiceTransaction.ServiceObjectType as ServiceObjectType,
//cast('' as crmt_subobject_category_db) as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_PredecessorServiceTransaction.ServiceDocument as ServiceDocument,
//cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Repair Quotations and Repair Orders
// Direction: in-house repair -> quotation -> order
union all select from I_InHouseRepairItem as repobj
// here we read the relation to the service quotation
// there is at most one relation to a service quotation for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
inner join I_CustMgmtTransactionRelation as relQ on relQ.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relQ.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relQ.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relQ.CustMgmtTransacRelationType = 'IHR2'
// here we read the relation to the service order
// there is at most one relation to a service order for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
// note, we cannot read the orders as successor of the quotation, because there could be multiple orders per quotation (when the quotation contains multiple repair objects)
inner join I_CustMgmtTransactionRelation as relO on relO.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relO.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relO.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relO.CustMgmtTransacRelationType = 'IHR1'
// with introduction of diagnosis orders, it is now possible to have a quotation as follow-up of a diagnosis order.
// with this the quotation is no longer the follow-up of the ihr but of the diagnosis order.
// to find out if the diagnosis order or the quotation is the follow-up of the in-house repair we need the direct successor
// of the in-house repair. the direct successor is defined by a VONA relationship
inner join I_CustMgmtTransactionRelation as relX on relX.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relX.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relX.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relX.CustMgmtTransacRelationType = 'VONA'
// there is a VONA ralation from quotation to order
inner join I_CustMgmtTransactionRelation as relVq on relVq.CustMgmtPrdcssrTransactionUUID = relQ.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtPrdcssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtSuccssrTransactionUUID = relO.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relVq.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relVq.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionQ on relVq.CustMgmtPrdcssrTransactionUUID = _ServiceTransactionQ.ServiceDocumentUUID
and relVq.CustMgmtPrdcssrTransacObjType = _ServiceTransactionQ.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionO on relVq.CustMgmtSuccssrTransactionUUID = _ServiceTransactionO.ServiceDocumentUUID
and relVq.CustMgmtSuccssrTransacObjType = _ServiceTransactionO.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relVq.CustMgmtPrdcssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relVq.CustMgmtPrdcssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _ServiceTransactionQ.ServiceDocument as PrecedingDocument,
key 'REPQ' as PrecedingDocumentCategory,
key _ServiceTransactionO.ServiceDocument as SubsequentDocument,
key 'CSVO' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_SuccessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_SuccessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Direction: in-house repair -> order -> quotation
union all select from I_InHouseRepairItem as repobj
// here we read the relation to the service quotation
// there is at most one relation to a service quotation for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
inner join I_CustMgmtTransactionRelation as relQ on relQ.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relQ.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relQ.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relQ.CustMgmtTransacRelationType = 'IHR2'
// here we read the relation to the service order
// there is at most one relation to a service order for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
// note, we cannot read the orders as successor of the quotation, because there could be multiple orders per quotation (when the quotation contains multiple repair objects)
inner join I_CustMgmtTransactionRelation as relO on relO.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relO.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relO.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relO.CustMgmtTransacRelationType = 'IHR1'
// with introduction of diagnosis orders, it is now possible to have a quotation as follow-up of a diagnosis order.
// with this the quotation is no longer the follow-up of the ihr but of the diagnosis order.
// to find out if the diagnosis order or the quotation is the follow-up of the in-house repair we need the direct successor
// of the in-house repair. the direct successor is defined by a VONA relationship
inner join I_CustMgmtTransactionRelation as relX on relX.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relX.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relX.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relX.CustMgmtTransacRelationType = 'VONA'
// there is a VONA ralation from order to quotation
inner join I_CustMgmtTransactionRelation as relVo on relVo.CustMgmtPrdcssrTransactionUUID = relO.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtPrdcssrTransactionUUID = relX.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtSuccssrTransactionUUID = relQ.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relVo.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relVo.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionO on relVo.CustMgmtPrdcssrTransactionUUID = _ServiceTransactionO.ServiceDocumentUUID
and relVo.CustMgmtPrdcssrTransacObjType = _ServiceTransactionO.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionQ on relVo.CustMgmtSuccssrTransactionUUID = _ServiceTransactionQ.ServiceDocumentUUID
and relVo.CustMgmtSuccssrTransacObjType = _ServiceTransactionQ.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relVo.CustMgmtPrdcssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relVo.CustMgmtPrdcssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _ServiceTransactionO.ServiceDocument as PrecedingDocument,
key 'CSVO' as PrecedingDocumentCategory,
key _ServiceTransactionQ.ServiceDocument as SubsequentDocument,
key 'REPQ' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_SuccessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_SuccessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Direction: quotation -> (in-house repair from quotation) -> order
union all select from I_InHouseRepairItem as repobj
// here we read the relation to the service quotation
// there is at most one relation to a service quotation for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
inner join I_CustMgmtTransactionRelation as relQ on relQ.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relQ.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relQ.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relQ.CustMgmtTransacRelationType = 'IHR2'
// here we read the relation to the service order
// there is at most one relation to a service order for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
// note, we cannot read the orders as successor of the quotation, because there could be multiple orders per quotation (when the quotation contains multiple repair objects)
inner join I_CustMgmtTransactionRelation as relO on relO.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relO.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relO.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relO.CustMgmtTransacRelationType = 'IHR1'
// VONA relationship from quotation to ihr with quotation as predecessor
inner join I_CustMgmtTransactionRelation as relXq on relXq.CustMgmtSuccssrTransactionUUID = repobj.InHouseRepairItemUUID
and relXq.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relXq.CustMgmtSuccssrTransacObjType = 'BUS2000257'
and relXq.CustMgmtTransacRelationType = 'VONA'
// there is a VONA ralation from quotation to order
inner join I_CustMgmtTransactionRelation as relVq on relVq.CustMgmtPrdcssrTransactionUUID = relQ.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtPrdcssrTransactionUUID = relXq.CustMgmtPrdcssrTransactionUUID
and relVq.CustMgmtSuccssrTransactionUUID = relO.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relVq.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relVq.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionQ on relVq.CustMgmtPrdcssrTransactionUUID = _ServiceTransactionQ.ServiceDocumentUUID
and relVq.CustMgmtPrdcssrTransacObjType = _ServiceTransactionQ.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionO on relVq.CustMgmtSuccssrTransactionUUID = _ServiceTransactionO.ServiceDocumentUUID
and relVq.CustMgmtSuccssrTransacObjType = _ServiceTransactionO.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relVq.CustMgmtPrdcssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relVq.CustMgmtPrdcssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _ServiceTransactionQ.ServiceDocument as PrecedingDocument,
key 'REPQ' as PrecedingDocumentCategory,
key _ServiceTransactionO.ServiceDocument as SubsequentDocument,
key 'CSVO' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_SuccessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_SuccessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Direction: order -> (in-house repair from order) -> quotation
union all select from I_InHouseRepairItem as repobj
// here we read the relation to the service quotation
// there is at most one relation to a service quotation for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
inner join I_CustMgmtTransactionRelation as relQ on relQ.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relQ.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relQ.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relQ.CustMgmtTransacRelationType = 'IHR2'
// here we read the relation to the service order
// there is at most one relation to a service order for each repair object
// this is an inner join to suppress all records that do not have a service order as successor of a quotation
// note, we cannot read the orders as successor of the quotation, because there could be multiple orders per quotation (when the quotation contains multiple repair objects)
inner join I_CustMgmtTransactionRelation as relO on relO.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relO.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relO.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relO.CustMgmtTransacRelationType = 'IHR1'
// VONA relationship from order to ihr with order as predecessor
inner join I_CustMgmtTransactionRelation as relXo on relXo.CustMgmtSuccssrTransactionUUID = repobj.InHouseRepairItemUUID
and relXo.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relXo.CustMgmtSuccssrTransacObjType = 'BUS2000257'
and relXo.CustMgmtTransacRelationType = 'VONA'
// there is a VONA ralation from order to quotation
inner join I_CustMgmtTransactionRelation as relVo on relVo.CustMgmtPrdcssrTransactionUUID = relO.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtPrdcssrTransactionUUID = relXo.CustMgmtPrdcssrTransactionUUID
and relVo.CustMgmtSuccssrTransactionUUID = relQ.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relVo.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relVo.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionO on relVo.CustMgmtPrdcssrTransactionUUID = _ServiceTransactionO.ServiceDocumentUUID
and relVo.CustMgmtPrdcssrTransacObjType = _ServiceTransactionO.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionQ on relVo.CustMgmtSuccssrTransactionUUID = _ServiceTransactionQ.ServiceDocumentUUID
and relVo.CustMgmtSuccssrTransacObjType = _ServiceTransactionQ.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relVo.CustMgmtPrdcssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relVo.CustMgmtPrdcssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _ServiceTransactionO.ServiceDocument as PrecedingDocument,
key 'CSVO' as PrecedingDocumentCategory,
key _ServiceTransactionQ.ServiceDocument as SubsequentDocument,
key 'REPQ' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_SuccessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_SuccessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Requote Cases
// Direction: quotation -> (in-house repair from quotation) -> quotation
union all select from I_InHouseRepairItem as repobj
// read the relation to the service quotation
inner join I_CustMgmtTransactionRelation as relQ on relQ.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relQ.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relQ.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relQ.CustMgmtTransacRelationType = 'IHR2'
// read the relation to another service quotation
inner join I_CustMgmtTransactionRelation as relQ2 on relQ2.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relQ2.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relQ2.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relQ2.CustMgmtTransacRelationType = 'IHR2'
// VONA relationship from quotation to the other ihr with quotation as predecessor
inner join I_CustMgmtTransactionRelation as relXq on relXq.CustMgmtSuccssrTransactionUUID = repobj.InHouseRepairItemUUID
and relXq.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relXq.CustMgmtSuccssrTransacObjType = 'BUS2000257'
and relXq.CustMgmtTransacRelationType = 'VONA'
// there is a VONA ralation from quotation to the other quotation
inner join I_CustMgmtTransactionRelation as relVq on relVq.CustMgmtPrdcssrTransactionUUID = relQ.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtPrdcssrTransactionUUID = relXq.CustMgmtPrdcssrTransactionUUID
and relVq.CustMgmtSuccssrTransactionUUID = relQ2.CustMgmtSuccssrTransactionUUID
and relVq.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relVq.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relVq.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionQ on relVq.CustMgmtPrdcssrTransactionUUID = _ServiceTransactionQ.ServiceDocumentUUID
and relVq.CustMgmtPrdcssrTransacObjType = _ServiceTransactionQ.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionQ2 on relVq.CustMgmtSuccssrTransactionUUID = _ServiceTransactionQ2.ServiceDocumentUUID
and relVq.CustMgmtSuccssrTransacObjType = _ServiceTransactionQ2.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relVq.CustMgmtPrdcssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relVq.CustMgmtPrdcssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _ServiceTransactionQ.ServiceDocument as PrecedingDocument,
key 'REPQ' as PrecedingDocumentCategory,
key _ServiceTransactionQ2.ServiceDocument as SubsequentDocument,
key 'REPQ' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_SuccessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_SuccessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Direction: order -> (in-house repair from order) -> order
union all select from I_InHouseRepairItem as repobj
// read the relation to the service order
inner join I_CustMgmtTransactionRelation as relO on relO.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relO.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relO.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relO.CustMgmtTransacRelationType = 'IHR1'
// read the relation to another service order
inner join I_CustMgmtTransactionRelation as relO2 on relO2.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and relO2.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and relO2.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relO2.CustMgmtTransacRelationType = 'IHR1'
// VONA relationship from order to ihr with order as predecessor
inner join I_CustMgmtTransactionRelation as relXo on relXo.CustMgmtSuccssrTransactionUUID = repobj.InHouseRepairItemUUID
and relXo.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relXo.CustMgmtSuccssrTransacObjType = 'BUS2000257'
and relXo.CustMgmtTransacRelationType = 'VONA'
// there is a VONA ralation from order to the other order
inner join I_CustMgmtTransactionRelation as relVo on relVo.CustMgmtPrdcssrTransactionUUID = relO.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtPrdcssrTransactionUUID = relXo.CustMgmtPrdcssrTransactionUUID
and relVo.CustMgmtSuccssrTransactionUUID = relO2.CustMgmtSuccssrTransactionUUID
and relVo.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and relVo.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and relVo.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service quotation and order from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionO on relVo.CustMgmtPrdcssrTransactionUUID = _ServiceTransactionO.ServiceDocumentUUID
and relVo.CustMgmtPrdcssrTransacObjType = _ServiceTransactionO.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _ServiceTransactionO2 on relVo.CustMgmtSuccssrTransactionUUID = _ServiceTransactionO2.ServiceDocumentUUID
and relVo.CustMgmtSuccssrTransacObjType = _ServiceTransactionO2.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on relVo.CustMgmtPrdcssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and relVo.CustMgmtPrdcssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _ServiceTransactionO.ServiceDocument as PrecedingDocument,
key 'CSVO' as PrecedingDocumentCategory,
key _ServiceTransactionO2.ServiceDocument as SubsequentDocument,
key 'CSVO' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_SuccessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_SuccessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Repair Orders and Repair Confirmations
union all select from I_InHouseRepairItem as repobj
// the following join is an inner join because here we want to be sure that we have an order
// there is at most one relation to a service order for each repair object
inner join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtTransacRelationType = 'IHR1' // with this condition we skip the repair quotation
// select the relations from service order to confirmation
// here we use an outer join so we get service orders when there is no confirmation
// this is necessary to get BUS2000116 in field ServiceObjectType to display details from the order (ServiceObjectType contains the BUS type of the predecessor)
left outer to many join I_CustMgmtTransactionRelation as rel2 on rel2.CustMgmtPrdcssrTransactionUUID = rel1.CustMgmtSuccssrTransactionUUID
and rel2.CustMgmtPrdcssrTransacObjType = rel1.CustMgmtSuccssrTransacObjType
and rel2.CustMgmtSuccssrTransacObjType = 'BUS2000117'
and rel2.CustMgmtTransacRelationType = 'VONA'
// we have to read the object IDs for service order and confirmation from I_ServiceDocument, because the relation view contains just GUIDs
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _PredecessorServiceTransaction on rel1.CustMgmtSuccssrTransactionUUID = _PredecessorServiceTransaction.ServiceDocumentUUID
and rel1.CustMgmtSuccssrTransacObjType = _PredecessorServiceTransaction.ServiceObjectType
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] }*/
association [0..1] to I_ServiceDocument as _SuccessorServiceTransaction on rel2.CustMgmtSuccssrTransactionUUID = _SuccessorServiceTransaction.ServiceDocumentUUID
and rel2.CustMgmtSuccssrTransacObjType = _SuccessorServiceTransaction.ServiceObjectType
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key _PredecessorServiceTransaction.ServiceDocument as PrecedingDocument,
key 'CSVO' as PrecedingDocumentCategory,
key _SuccessorServiceTransaction.ServiceDocument as SubsequentDocument,
key case when _SuccessorServiceTransaction.ServiceDocument is not null
then'CSCO'
end as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
_PredecessorServiceTransaction.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
_PredecessorServiceTransaction.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Repair Orders and Billing Document Requests
// I_SDDocumentMultiLevelProcFlow returns multiple records when there are billing documents with multiple items, hence we use "select distinct" here.
union all select distinct from I_InHouseRepairItem as repobj
// there is at most one relation to a service order for each repair object
left outer to one join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtTransacRelationType = 'IHR1' // with this condition we skip the repair quotation
// we have to read the object ID for the service order from I_ServiceDocument, because the relation view contains just GUIDs
left outer to one join I_ServiceDocument as ord on ord.ServiceDocumentUUID = rel1.CustMgmtSuccssrTransactionUUID
and ord.ServiceObjectType = rel1.CustMgmtSuccssrTransacObjType
// the following join is an inner join to suppress all records that do not have a billing document request
// select the billing document requests for the service orders
inner join I_SDDocumentMultiLevelProcFlow as rel3 on rel3.SubsequentDocumentCategory = 'EBDR' // Billing Document Request
and rel3.PrecedingDocument = ord.ServiceDocument
and rel3.PrecedingDocumentCategory = 'CSVO' // Service Order
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key rel3.PrecedingDocument,
key rel3.PrecedingDocumentCategory,
key rel3.SubsequentDocument,
key rel3.SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
ord.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Repair Confirmations and Billing Document Requests
// I_SDDocumentMultiLevelProcFlow returns multiple records when there are billing documents with multiple items, hence we use "select distinct" here.
union all select distinct from I_InHouseRepairItem as repobj
// there is at most one relation to a service order for each repair object
left outer to one join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtTransacRelationType = 'IHR1' // with this condition we skip the repair quotation
// the following join is an inner join because here we want to be sure that we have a confirmation
// select the relations from service order to confirmation
inner join I_CustMgmtTransactionRelation as rel2 on rel2.CustMgmtPrdcssrTransactionUUID = rel1.CustMgmtSuccssrTransactionUUID
and rel2.CustMgmtPrdcssrTransacObjType = rel1.CustMgmtSuccssrTransacObjType
and rel2.CustMgmtSuccssrTransacObjType = 'BUS2000117'
and rel2.CustMgmtTransacRelationType = 'VONA'
// we have to read the object ID for service confirmation from I_ServiceDocument, because the relation view contains just GUIDs
left outer to one join I_ServiceDocument as conf on conf.ServiceDocumentUUID = rel2.CustMgmtSuccssrTransactionUUID
and conf.ServiceObjectType = rel2.CustMgmtSuccssrTransacObjType
// select the billing document requests for the service confirmations
// here we use an outer join so we get service confirmations when there is no billing document request
// this is necessary to get BUS2000117 in field ServiceObjectType to display details from the confirmation (ServiceObjectType contains the BUS type of the predecessor)
left outer to many join I_SDDocumentMultiLevelProcFlow as rel3 on rel3.SubsequentDocumentCategory = 'EBDR' // Billing Document Request
and rel3.PrecedingDocument = conf.ServiceDocument
and rel3.PrecedingDocumentCategory = 'CSCO' // Service Confirmation
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key conf.ServiceDocument as PrecedingDocument,
key 'CSCO' as PrecedingDocumentCategory,
key rel3.SubsequentDocument,
key rel3.SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
conf.ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
conf.ServiceDocument as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Billing Document Requests and Billing Documents
// I_SDDocumentMultiLevelProcFlow returns multiple records when there are billing documents with multiple items, hence we use "select distinct" here.
union all select distinct from I_InHouseRepairItem as repobj
// there is at most one relation to a service order for each repair object
left outer to one join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtTransacRelationType = 'IHR1' // with this condition we skip the repair quotation
// select the relations from service order to confirmation
left outer to many join I_CustMgmtTransactionRelation as rel2 on rel2.CustMgmtPrdcssrTransactionUUID = rel1.CustMgmtSuccssrTransactionUUID
and rel2.CustMgmtPrdcssrTransacObjType = rel1.CustMgmtSuccssrTransacObjType
and rel2.CustMgmtSuccssrTransacObjType = 'BUS2000117'
and rel2.CustMgmtTransacRelationType = 'VONA'
// the following joins are inner joins to suppress all records that do not have an invoice
// we have to read the object IDs for service order and confirmation from I_ServiceDocument, because the relation view contains just GUIDs
left outer to one join I_ServiceDocument as ord on ord.ServiceDocumentUUID = rel1.CustMgmtSuccssrTransactionUUID
and ord.ServiceObjectType = rel1.CustMgmtSuccssrTransacObjType
left outer to one join I_ServiceDocument as conf on conf.ServiceDocumentUUID = rel2.CustMgmtSuccssrTransactionUUID
and conf.ServiceObjectType = rel2.CustMgmtSuccssrTransacObjType
// select the billing document requests for the service orders and confirmations
inner join I_SDDocumentMultiLevelProcFlow as rel3 on rel3.SubsequentDocumentCategory = 'EBDR' // Billing Document Request
and(
rel3.PrecedingDocument = conf.ServiceDocument
and rel3.PrecedingDocumentCategory = 'CSCO' // Service Order
or rel3.PrecedingDocument = ord.ServiceDocument
and rel3.PrecedingDocumentCategory = 'CSVO' // Service Confirmation
)
// select the invoices for the billing document requests
inner join I_SDDocumentMultiLevelProcFlow as rel4 on rel4.PrecedingDocument = rel3.SubsequentDocument
and rel4.PrecedingDocumentCategory = rel3.SubsequentDocumentCategory
and rel4.SubsequentDocumentCategory = 'M' // Invoice
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key rel4.PrecedingDocument,
key rel4.PrecedingDocumentCategory,
key rel4.SubsequentDocument,
key rel4.SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
cast('' as crmt_subobject_category_db) as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Return Order and In-House Repair
union all select from I_InHouseRepairItem as repobj
// Relation of Return Order with In-House Repair Item
inner join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtSuccssrTransactionUUID = repobj.InHouseRepairUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2102'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000256'
and rel1.CustMgmtTransacRelationType = 'VONA' // with this condition we skip the repair quotation
// we have to read the Customer Return ID from I_CustomerReturn, because the relation view contains Transaction Key which is Return ID number
inner join I_CustomerReturn as ord on ord.CustomerReturn = rel1.CustMgmtPrdcssrTransactionKey
// and ord.CustomerReturnType = 'RE2'
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key ord.CustomerReturn as PrecedingDocument,
// key ord.CustomerReturnType as PrecedingDocumentCategory,
key 'H' as PrecedingDocumentCategory,
key repobj.InHouseRepair as SubsequentDocument,
// key repobj.InhRepairType as SubsequentDocumentCategory,
key 'REPA' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
repobj.CustMgmtObjectType as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Outbound Delivery and In-House Repair
union all select from I_InHouseRepairItem as repobj
inner join I_SrvcDocItemRelation as ItemRel on ItemRel.ServiceDocumentItemPredecessor = repobj.InHouseRepairItemCharUUID
and ItemRel.ServiceDocItmPrdcssrBusObjType = 'BUS2000257'
and ItemRel.ServiceDocItmSuccssrBusObjType = 'LIPS'
and ItemRel.ServiceDocumentItmRelationType = 'VONA'
// Relation of Return Order with In-House Repair Item
inner join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtTransacRelationUUID = ItemRel.ServiceDocumentItmRelationUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000256'
and rel1.CustMgmtSuccssrTransacObjType = 'LIKP'
and rel1.CustMgmtTransacRelationType = 'VONA'
// we have to read the Delivery Document ID from I_DeliveryDocument, because the relation view contains Transaction Key which is Delivery ID number
inner join I_DeliveryDocument as ord on ord.DeliveryDocument = rel1.CustMgmtSuccssrTransactionKey
// and ord.DeliveryDocumentType = 'LR2' //'LF'
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key repobj.InHouseRepair as PrecedingDocument,
key 'REPA' as PrecedingDocumentCategory,
key ord.DeliveryDocument as SubsequentDocument,
key 'J' as SubsequentDocumentCategory,
// key ord.DeliveryDocumentType as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, // used to filter on in-house repair item
repobj.CustMgmtObjectType as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType, // also required to read details like status from in-house repair
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Return order as a follow-up of IHR
union all select from I_InHouseRepairItem as repobj
// Relation of Return Order Header with In-House Repair Object
inner join I_SrvcDocItemRelation as rel1 on rel1.ServiceDocumentItemPredecessor = repobj.InHouseRepairItemCharUUID
and rel1.ServiceDocItmPrdcssrBusObjType = 'BUS2000257'
and rel1.ServiceDocItmSuccssrBusObjType = 'VBAP'
and rel1.ServiceDocumentItmRelationType = 'VONA'
// Relationship of In-House Repair with In-House Repair Objects
inner join I_CustMgmtTransactionRelation as rel2 on rel2.CustMgmtTransacRelationUUID = rel1.ServiceDocumentItmRelationUUID
and rel2.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairUUID
and rel2.CustMgmtPrdcssrTransacObjType = 'BUS2000256'
and rel2.CustMgmtSuccssrTransacObjType = 'BUS2102'
and rel2.CustMgmtTransacRelationType = 'VONA'
// Read the Customer Return ID from I_CustomerReturn, because the relation view contains Transaction Key which is Return ID number
inner join I_CustomerReturn as ord on ord.CustomerReturn = rel2.CustMgmtSuccssrTransactionKey
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key repobj.InHouseRepair as PrecedingDocument,
key 'REPA' as PrecedingDocumentCategory,
key ord.CustomerReturn as SubsequentDocument,
key 'H' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem,
repobj.CustMgmtObjectType as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType,
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
//MSO and Debit Memo Requests
union all select from I_InHouseRepairItem as repobj
//There is at most one relation to a service order for each repair object
left outer to one join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtTransacRelationType = 'IHR1' //with this condition we skip the repair quotation
//we have to read the object ID for the service order from I_ServiceDocument, because the relation view contains just GUIDs
// will be use for Precending Document field
left outer to one join I_ServiceDocument as ord on ord.ServiceDocumentUUID = rel1.CustMgmtSuccssrTransactionUUID
and ord.ServiceObjectType = rel1.CustMgmtSuccssrTransacObjType
// the following join is an inner join to suppress all records that do not have a debit memo requests
// select the debit memo requests UUID
inner join I_CustMgmtTransactionRelation as rel2 on rel2.CustMgmtPrdcssrTransactionUUID = ord.ServiceDocumentUUID
and rel2.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and rel2.CustMgmtSuccssrTransacObjType = 'BUS2096'
and rel2.CustMgmtTransacRelationType = 'VONA'
// select the debit memo request for the service orders
inner join I_SalesDocument as dmr on dmr.SalesDocument = rel2.CustMgmtSuccssrTransactionKey
// used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key ord.ServiceDocument as PrecedingDocument,
key 'CSVO' as PrecedingDocumentCategory,
key dmr.SalesDocument as SubsequentDocument,
key 'EDMR' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, //used to filter on in-house repair item
repobj.CustMgmtObjectType as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType,
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}
// Debit Memo Request and Debit Memo
union all select distinct from I_InHouseRepairItem as repobj
//there is at most one relation to a service order for each repair object
left outer to one join I_CustMgmtTransactionRelation as rel1 on rel1.CustMgmtPrdcssrTransactionUUID = repobj.InHouseRepairItemUUID
and rel1.CustMgmtPrdcssrTransacObjType = 'BUS2000257'
and rel1.CustMgmtSuccssrTransacObjType = 'BUS2000116'
and rel1.CustMgmtTransacRelationType = 'IHR1' //with this condition we skip the repair quotation
//the following join is an inner join to suppress all records that do not have a debit memo requests
//select the debit memo requests
inner join I_CustMgmtTransactionRelation as rel2 on rel2.CustMgmtPrdcssrTransactionUUID = rel1.CustMgmtSuccssrTransactionUUID
and rel2.CustMgmtPrdcssrTransacObjType = 'BUS2000116'
and rel2.CustMgmtSuccssrTransacObjType = 'BUS2096'
and rel2.CustMgmtTransacRelationType = 'VONA'
//select the debit memo request for the service orders
inner join I_SalesDocument as dmr on dmr.SalesDocument = rel2.CustMgmtSuccssrTransactionKey
//select the debit memo for the debit memo request
inner join I_SDDocumentMultiLevelProcFlow as dm on dm.PrecedingDocument = dmr.SalesDocument
and dm.PrecedingDocumentCategory = 'L'
and dm.SubsequentDocumentCategory = 'P'
//used for authorization check
association [1..1] to I_InHouseRepair as _InHouseRepair on $projection.CustMgmtObjectType = _InHouseRepair.CustMgmtObjectType
and $projection.InHouseRepair = _InHouseRepair.InHouseRepair
{
key dm.PrecedingDocument as PrecedingDocument,
key 'EDMR' as PrecedingDocumentCategory,
key dm.SubsequentDocument as SubsequentDocument,
key 'P' as SubsequentDocumentCategory,
key repobj.InHouseRepairItem, //used to filter on in-house repair item
repobj.CustMgmtObjectType as ServiceObjectType,
// we need the ServiceDocument as navigation to service actuals
cast('' as crmt_object_id_db) as ServiceDocument,
// used to filter on in-house repair item
repobj.InHouseRepair,
// used for authorization check
@Consumption.hidden: true
repobj.InhRepairType,
repobj.CustMgmtObjectType,
// Responsible Employee
@Consumption.hidden: true
_InHouseRepair.ResponsibleEmployee as RespEmployeeBusinessPartnerId,
// Organizational Data
@Consumption.hidden: true
_InHouseRepair.SalesOrganization as SalesOrganization,
@Consumption.hidden: true
_InHouseRepair.DistributionChannel as DistributionChannel,
@Consumption.hidden: true
_InHouseRepair.Division as Division,
@Consumption.hidden: true
_InHouseRepair.SalesOffice as SalesOffice,
@Consumption.hidden: true
_InHouseRepair.SalesGroup as SalesGroup,
// CRM Org units
@Consumption.hidden: true
_InHouseRepair.SalesOrganizationOrgUnitID as SalesOrganizationOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesOfficeOrgUnitID as SalesOfficeOrgUnitID,
@Consumption.hidden: true
_InHouseRepair.SalesGroupOrgUnitID as SalesGroupOrgUnitID,
@Consumption.hidden: true
_InHouseRepair
}