@AbapCatalog.sqlViewName: 'PSRVORDIEMDAT'
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.compiler.compareFilter: true
//@AbapCatalog.preserveKey: true
@VDM: {
private:true,
viewType: #COMPOSITE
}
@AccessControl: {
personalData.blocking: #('TRANSACTIONAL_DATA')
}
@ObjectModel: {
usageType: {
dataClass: #MIXED,
serviceQuality: #D,
sizeCategory: #XXL
}
}
define view P_ServiceOrderItemDateConv
as select from I_ServiceDocumentItemEnhcd
association [1] to I_ServiceDocumentEnhcd as _ServiceDocument on $projection.ServiceObjectType = _ServiceDocument.ServiceObjectType
and $projection.ServiceDocument = _ServiceDocument.ServiceDocument
association [1] to I_ServiceDocumentRefObject as _MainObject on $projection.ServiceObjectType = _MainObject.ServiceObjectType
and $projection.ServiceDocument = _MainObject.ServiceDocument
and $projection.ServiceDocumentItem = _MainObject.ServiceDocumentItem
and _MainObject.SrvcRefObjIsMainObject is not initial
{
@ObjectModel.foreignKey.association: '_ServiceObjType'
key ServiceObjectType,
@ObjectModel.foreignKey.association: '_ServiceDocument'
key ServiceDocument,
key ServiceDocumentItem,
ServiceDocumentDescription,
ServiceDocumentItemObjectType,
ServiceDocumentItemDescription,
ParentServiceDocumentItemUUID,
ServiceDocumentItemPriority,
@ObjectModel.foreignKey.association: '_ServiceDocumentType'
ServiceDocumentType,
PostingDate,
@ObjectModel.foreignKey.association: '_TransactionCurrency'
@Semantics.currencyCode:true
TransactionCurrency,
tstmp_to_dats( RequestedServiceStartDateTime, $session.user_timezone, $session.client, 'NULL' ) as RequestedServiceStartDate,
tstmp_to_dats( RequestedServiceEndDateTime, $session.user_timezone, $session.client, 'NULL' ) as RequestedServiceEndDate,
tstmp_to_dats( ServiceFirstResponseByDateTime, $session.user_timezone, $session.client, 'NULL' ) as ServiceFirstResponseByDate,
tstmp_to_dats( SrvcDocItemSLADueByDateTime, $session.user_timezone, $session.client, 'NULL' ) as SrvcDocItemSLADueByDate,
tstmp_to_dats( PlannedServiceStartDateTime, $session.user_timezone, $session.client, 'NULL' ) as PlannedServiceStartDate,
tstmp_to_dats( PlannedServiceEndDateTime, $session.user_timezone, $session.client, 'NULL' ) as PlannedServiceEndDate,
//Main Equipment based search
@ObjectModel.foreignKey.association: '_SrvcReferenceObjectType'
_MainObject.ServiceReferenceObjectType as ServiceReferenceObjectType,
@ObjectModel.foreignKey.association: '_Equipment'
_MainObject.Equipment as Equipment,
case
when _MainObject.ServiceReferenceObjectType = 'A'
then _MainObject.ProductID
when _MainObject.ServiceReferenceObjectType = 'B'
then _MainObject.FunctionalLocation
when _MainObject.ServiceReferenceObjectType = 'C'
then _MainObject.Equipment
else ''
end as ReferenceObjectID,
case
when _MainObject.ServiceReferenceObjectType = 'A'
then _MainObject._Product._MaterialText[1: Language=$session.system_language].ProductDescription
when _MainObject.ServiceReferenceObjectType = 'B'
then _MainObject._FunctionalLocation._FunctionalLocationText[1: Language=$session.system_language].FunctionalLocationName
when _MainObject.ServiceReferenceObjectType = 'C'
then _MainObject._Equipment._EquipmentText[1: Language=$session.system_language].EquipmentName
else ''
end as SrvcRefObjName,
@ObjectModel.foreignKey.association: '_ServiceDocumentIsOpen'
_ServiceDocument.ServiceDocumentIsOpen as ServiceDocumentIsOpen,
@ObjectModel.foreignKey.association: '_ServiceTeam'
ServiceTeam,
@ObjectModel.foreignKey.association: '_RespEmployee'
ResponsibleEmployee,
@ObjectModel.foreignKey.association: '_ServiceEmployee'
ServiceEmployee,
@ObjectModel.foreignKey.association: '_ContactPerson'
ContactPerson as ContactPersonBusinessPartnerId,
@ObjectModel.foreignKey.association: '_ShipToParty'
ShipToParty,
RefBusinessSolutionOrder,
@ObjectModel.foreignKey.association: '_SrvcDocItmLifecycleStatus'
ServiceDocumentItemStatus,
@ObjectModel.foreignKey.association: '_ServiceDocItemHasError'
ServiceDocumentItemHasError,
@ObjectModel.foreignKey.association: '_ServiceDocumentItemIsOpen'
ServiceDocumentItemIsOpen,
@Semantics.systemDate.createdAt: true
ServiceDocItemCreationDate,
OriginallyRequestedProduct,
@Aggregation.default: #SUM
@Semantics: { quantity : {unitOfMeasure: 'ServiceDocItemQuantityUnit'} }
ServiceDocumentItemQuantity,
@Semantics.unitOfMeasure:true
ServiceDocItemQuantityUnit,
@ObjectModel.foreignKey.association: '_ServiceDocItemCategory'
ServiceDocItemCategory,
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
ServiceDocumentItemNetAmount,
RequestedServiceStartDateTime,
RequestedServiceEndDateTime,
cast (1 as abap.int4) as NmbrOfIncompleteServiceOrders,
cast (1 as abap.int4) as NmbrOfServiceOrderItems,
cast (1 as abap.int4) as NumberOfOverdueServiceOrders,
// case when RequestedServiceEndDate < $session.system_date
// then cast (1 as abap.int4)
// end as NumberOfOverdueServiceOrders,
@ObjectModel.foreignKey.association: '_SalesOrganization'
SalesOrganization,
@ObjectModel.foreignKey.association: '_SalesOffice'
SalesOffice,
@ObjectModel.foreignKey.association: '_SalesGroup'
SalesGroup,
@ObjectModel.foreignKey.association: '_DistributionChannel'
DistributionChannel,
@ObjectModel.foreignKey.association: '_Division'
Division,
ServiceOrganization,
@ObjectModel.foreignKey.association: '_SalesOrganizationOrgUnit_2'
SalesOrganizationOrgUnitID,
@ObjectModel.foreignKey.association: '_SalesOfficeOrgUnit_2'
SalesOfficeOrgUnitID,
@ObjectModel.foreignKey.association: '_SalesGroupOrgUnit_2'
SalesGroupOrgUnitID,
@ObjectModel.foreignKey.association: '_SoldToParty'
SoldToParty,
@ObjectModel.foreignKey.association: '_ServiceTeamHeader'
RespyMgmtServiceTeam,
_ServiceTeamHeader._TeamDescription.TeamDescription as RespyMgmtServiceTeamDesc,
_ServiceTeamHeader.TeamName as TeamName,
@ObjectModel.foreignKey.association: '_Product'
Product,
/* Associations */
_RespEmployee,
_ServiceDocItemCategory,
_ServiceDocItemPriority,
// @API.element.releaseState: #DEPRECATED
// @API.element.successor: '_SrvcDocItmLifecycleStatus'
_ServiceDocItemStatus,
_SrvcDocItmLifecycleStatus,
_ServiceDocItemHasError,
_ServiceDocumentType,
_ServiceDocument,
_ServiceObjType,
_TransactionCurrency,
// @API.element.releaseState: #DEPRECATED
// @API.element.successor: '_SalesOrganizationOrgUnit_2'
_SalesOrganizationOrgUnit,
//
// @API.element.releaseState: #DEPRECATED
// @API.element.successor: '_SalesOfficeOrgUnit_2'
_SalesOfficeOrgUnit,
//
// @API.element.releaseState: #DEPRECATED
// @API.element.successor: '_SalesGroupOrgUnit_2'
_SalesGroupOrgUnit,
//
_SalesOrganizationOrgUnit_2,
_SalesOfficeOrgUnit_2,
_SalesGroupOrgUnit_2,
_SalesOrganization,
_SalesOffice,
_SalesGroup,
_Division,
_DistributionChannel,
_SoldToParty,
_ServiceDocItemRefObj,
_ServiceTeam,
_ServiceEmployee,
_ContactPerson,
_ShipToParty,
_ServiceDocument._ServiceDocumentIsOpen as _ServiceDocumentIsOpen,
_ServiceDocumentIsOpen as _ServiceDocumentItemIsOpen,
//Main Equipment based search
_MainObject._SrvcReferenceObjectType as _SrvcReferenceObjectType,
_MainObject._Equipment as _Equipment,
//END - Main Equipment based search
_ServiceTeamHeader,
_Product
}
where
_ServiceDocument.ServiceDocumentIsOpen = 'X'
and ServiceObjectType = 'BUS2000116'
and ServiceDocumentItemIsQuotation != 'X'
and _ServiceDocument.SrvcDocIsMaintServiceOrder != 'X'
and _ServiceDocument.ServiceDocumentTemplateType is initial
and RefInHouseRepairIsExisting is initial
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_EQUIPMENT",
"I_EQUIPMENTTEXT",
"I_FUNCTIONALLOCATION",
"I_FUNCTIONALLOCATIONTEXT",
"I_PRODUCT",
"I_PRODUCTDESCRIPTION",
"I_RESPYMGMTTEAMDESCRIPTION",
"I_RESPYMGMTTEAMHEADERDETAIL",
"I_SERVICEDOCUMENTENHCD",
"I_SERVICEDOCUMENTITEMENHCD",
"I_SERVICEDOCUMENTREFOBJECT"
],
"ASSOCIATED":
[
"I_BUSINESSPARTNER",
"I_CURRENCY",
"I_CUSTMGMTBUSOBJTYPE",
"I_DISTRIBUTIONCHANNEL",
"I_DIVISION",
"I_EQUIPMENT",
"I_PRODUCT",
"I_RESPYMGMTTEAMHEADERDETAIL",
"I_SALESGROUP",
"I_SALESOFFICE",
"I_SALESORGANIZATION",
"I_SALESORGANIZATIONUNIT",
"I_SERVICEDOCERRORSTATUS",
"I_SERVICEDOCITEMCATEGORY",
"I_SERVICEDOCOPENSTATUS",
"I_SERVICEDOCUMENTENHCD",
"I_SERVICEDOCUMENTPRIORITY",
"I_SERVICEDOCUMENTREFOBJECT",
"I_SERVICEDOCUMENTSTATUS",
"I_SERVICEDOCUMENTTYPE",
"I_SRVCDOCLIFECYCLESTATUS",
"I_SRVCMGMTORGANIZATIONUNIT",
"I_SRVCREFERENCEOBJECTTYPE"
],
"BASE":
[
"I_SERVICEDOCUMENTENHCD",
"I_SERVICEDOCUMENTITEMENHCD",
"I_SERVICEDOCUMENTREFOBJECT"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/