I_RSHOperationAssignment

DDL: I_RSHOPERATIONASSIGNMENT SQL: IRSHOPERATIONASG Type: view BASIC

Maintenance Order Operation Assignment

I_RSHOperationAssignment is a Basic CDS View that provides data about "Maintenance Order Operation Assignment" in SAP S/4HANA. It reads from 2 data sources (afvc, kbed) and exposes 14 fields with key fields CapacityRequirement, CapacityRequirementItem, CapacityRqmtItemCapacity. It has 3 associations to related views.

Data Sources (2)

SourceAliasJoin Type
afvc _MaintenanceOrderOperation inner
kbed _Split from

Associations (3)

CardinalityTargetAliasCondition
[0..1] afko _Order _Order.bedid = _Split.bedid
[0..1] I_MaintenanceOrder _MaintenanceOrder $projection.MaintenanceOrder = _MaintenanceOrder.MaintenanceOrder
[0..1] afvc _SuperiorOperation _SuperiorOperation.aufpl = _MaintenanceOrderOperation.aufpl and _SuperiorOperation.aplzl = _MaintenanceOrderOperation.sumnr

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName IRSHOPERATIONASG view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #MANDATORY view
VDM.viewType #BASIC view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.sizeCategory #XL view
AccessControl.personalData.blocking #REQUIRED view
EndUserText.label Maintenance Order Operation Assignment view

Fields (14)

KeyFieldSource TableSource FieldDescription
KEY CapacityRequirement kbed bedid
KEY CapacityRequirementItem
KEY CapacityRqmtItemCapacity
MaintenanceOrder _Order aufnr
MaintenanceOrderOperation
MaintenanceOrderSubOperation
MaintOrderRoutingNumber
MaintOrderOperationCounter
PersonnelNumber kbed pernr
AssignedMaintOpStartDate kbed fstad
AssignedMaintOpStartTime kbed fstau
AssignedMaintOpEndDate kbed fendd
AssignedMaintOpEndTime kbed fendu
_MaintenanceOrder _MaintenanceOrder
@AbapCatalog.sqlViewName: 'IRSHOPERATIONASG'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #MANDATORY
@VDM.viewType: #BASIC
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality:#C
@ObjectModel.usageType.sizeCategory: #XL
@AccessControl.personalData.blocking:#REQUIRED
@EndUserText.label: 'Maintenance Order Operation Assignment'

/*
CONTRACT*************************************************************************************************************************************

Specification:              This view only handles maintenance orders and filter out the empty personnelNumber
Requires:                   NA
Ensures:                    Mainternance order along with personnel Number assigned to operation are returned
Owners:                     GG
Contributors:
Unit Test required Y/N:     Y
Additional comments         None

END OF CONTRACT******************************************************************************************************************************
*/
define view I_RSHOperationAssignment
  as select from        kbed as _Split
    inner join          afvc as _MaintenanceOrderOperation on  _MaintenanceOrderOperation.aufpl = _Split.aufpl
                                                           and _MaintenanceOrderOperation.aplzl = _Split.aplzl

  // Since AFKO has the key AUFNR and the key is not used as reference in the other tables KBED and AFVC, we need to disable the cardinality check / warning

  /*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ] } */
  association [0..1] to afko as _Order            on  _Order.bedid = _Split.bedid

  // Included for DCL checks on 

  // - order type

  // - maintenance plant, planner group

  // - equipment plant

  // - functional location plant

  association [0..1] to I_MaintenanceOrder as _MaintenanceOrder on $projection.MaintenanceOrder = _MaintenanceOrder.MaintenanceOrder

//  // Included for DCL checks on order type

//  association [0..1] to aufk as _OrderHeader      on  _OrderHeader.aufnr = _Order.aufnr

//

//  // Included for DCL checks on maintenance plant, planner group

//  association [0..1] to afih as _MaintenanceOrder on  _MaintenanceOrder.aufnr = _Order.aufnr

//

//  // Included for DCL checks on equipment plant

//  association [0..1] to equi as _Equipment        on  _MaintenanceOrder.equnr = _Equipment.equnr


  association [0..1] to afvc as _SuperiorOperation on  _SuperiorOperation.aufpl = _MaintenanceOrderOperation.aufpl
                                                   and _SuperiorOperation.aplzl = _MaintenanceOrderOperation.sumnr

// --------------------------------------------------------------------------------------------------------------------------

// BEFORE CHANGE:

// --------------------------------------------------------------------------------------------------------------------------

//left outer to one join afko as _MaintenanceOrder          on _MaintenanceOrderOperation.aufpl = _MaintenanceOrder.aufpl

// --------------------------------------------------------------------------------------------------------------------------


{

  key _Split.bedid                                                                                                                                                  as CapacityRequirement,
  key cast(_Split.bedzl as pph_bedzl preserving type)                                                                                                               as CapacityRequirementItem,
  key cast(_Split.canum as pph_canum preserving type)                                                                                                               as CapacityRqmtItemCapacity,

      _Order.aufnr                                                                                                                                                  as MaintenanceOrder,
      cast( coalesce( _SuperiorOperation.vornr, _MaintenanceOrderOperation.vornr ) as maintenanceorderoperation preserving type )                                   as MaintenanceOrderOperation,
      cast( case when  _MaintenanceOrderOperation.sumnr = '00000000' then '' else _MaintenanceOrderOperation.vornr end as vdm_vornr preserving type )               as MaintenanceOrderSubOperation,
      cast(_Split.aufpl as pph_aufpl preserving type)                                                                                                               as MaintOrderRoutingNumber,
      cast(_Split.aplzl as operationinternalid preserving type)                                                                                                     as MaintOrderOperationCounter,

      _Split.pernr                                                                                                                                                  as PersonnelNumber,
      _Split.fstad                                                                                                                                                  as AssignedMaintOpStartDate,
      _Split.fstau                                                                                                                                                  as AssignedMaintOpStartTime,

      _Split.fendd                                                                                                                                                  as AssignedMaintOpEndDate,
      _Split.fendu                                                                                                                                                  as AssignedMaintOpEndTime,
      
      // Use date and time and system time zone and create a TIMESTAMP (which is in UTC)

      // BADI call will not be required post this conversion.

      case when _Split.fstau = '240000'
      then  cast(dats_tims_to_tstmp( _Split.fstad, cast('235959' as tims), abap_system_timezone( $session.client,'NULL'), $session.client,'NULL') as timestamp preserving type)
      else
      cast(dats_tims_to_tstmp( _Split.fstad, _Split.fstau,abap_system_timezone( $session.client,'NULL'), $session.client,'NULL') as timestamp preserving type) end  as AssignedMaintOpStartDateTime,

      case when _Split.fendu = '240000'
      then  cast(dats_tims_to_tstmp( _Split.fendd, cast('235959' as tims), abap_system_timezone( $session.client,'NULL'), $session.client,'NULL') as timestamp preserving type)
      else
      cast(dats_tims_to_tstmp( _Split.fendd, _Split.fendu, abap_system_timezone( $session.client,'NULL'), $session.client,'NULL') as timestamp preserving type) end as AssignedMaintOpEndDateTime,

//    _Order,      

      _MaintenanceOrder
      
//      _Order,

//      _OrderHeader,

//      _MaintenanceOrder,

//      _Equipment


}
where
  _Order.plnaw = 'I' and
  _Split.pernr is not initial;
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"AFKO",
"AFVC",
"KBED"
],
"ASSOCIATED":
[
"I_MAINTENANCEORDER",
"AFKO",
"AFVC"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/