C_DefectMng

DDL: C_DEFECTMNG SQL: CDEFECTMNG Type: view CONSUMPTION

Manage Defects

C_DefectMng is a Consumption CDS View that provides data about "Manage Defects" in SAP S/4HANA. It reads from 1 data source (I_DefectUnion) and exposes 89 fields with key field DefectInternalID. It has 21 associations to related views.

Data Sources (1)

SourceAliasJoin Type
I_DefectUnion _DefectUnion from

Associations (21)

CardinalityTargetAliasCondition
[1..1] I_CalendarDate _DefectsWeek $projection.CreationDate = _DefectsWeek.CalendarDate
[1..1] C_Plantvaluehelp _Plant $projection.Plant = _Plant.Plant
[0..1] C_InspLotSuplrValHelp _SupplierVH $projection.supplier = _SupplierVH.Supplier
[1..1] C_InspLotCustValHelp _CustomerVH $projection.customer = _CustomerVH.Customer
[0..1] C_InsLotHasUsgeDcsnT _InspLotHasUsgeDcsn $projection.InspectionLotHasUsageDecision = _InspLotHasUsgeDcsn.InspectionLotHasUsageDecision
[0..1] I_WorkCenterBySemanticKey _WorkCenterBySemanticKey $projection.MainWorkCenterInternalID = _WorkCenterBySemanticKey.WorkCenterInternalID and $projection.MainWorkCenterPlant = _WorkCenterBySemanticKey.Plant
[1..1] C_DefectCalc _DefectCalc $projection.DefectInternalID = _DefectCalc.DefectInternalID
[0..1] I_InspectionOperation _InspectionOperation $projection.InspectionLot = _InspectionOperation.InspectionLot and $projection.InspPlanOperationInternalID = _InspectionOperation.InspPlanOperationInternalID
[0..1] C_DefectMngCharcs _DefectMngCharcs $projection.InspectionLot = _DefectMngCharcs.InspectionLot and $projection.InspPlanOperationInternalID = _DefectMngCharcs.InspPlanOperationInternalID and $projection.InspectionCharacteristic = _DefectMngCharcs.InspectionCharacteristic
[0..1] C_DefectMngCharacteristicsSbst _DefectMngCharacteristicsSbst $projection.InspectionLot = _DefectMngCharacteristicsSbst .InspectionLot and $projection.InspPlanOperationInternalID = _DefectMngCharacteristicsSbst .InspPlanOperationInternalID and $projection.InspectionSubsetInternalID = _DefectMngCharacteristicsSbst .InspectionSubsetInternalID and $projection.MaterialSample = _DefectMngCharacteristicsSbst .MaterialSample and $projection.InspectionCharacteristic = _DefectMngCharacteristicsSbst .InspectionCharacteristic
[0..1] I_MfgOrderVH _MfgOrderVH $projection.ManufacturingOrder = _MfgOrderVH.ManufacturingOrder
[0..1] I_StorageLocation _StorageLocation $projection.Plant = _StorageLocation.Plant and $projection.StorageLocation = _StorageLocation.StorageLocation
[0..1] I_ProductionSupplyArea _ProductionSupplyArea $projection.ProductionSupplyArea = _ProductionSupplyArea.ProductionSupplyArea and $projection.Plant = _ProductionSupplyArea.Plant
[0..1] I_EWM_WarehouseNumber_2 _EWM_WarehouseNumber_2 $projection.Warehouse = _EWM_WarehouseNumber_2.EWMWarehouse
[0..1] I_EWM_StorageType_2 _EWM_SourceStorageType $projection.Warehouse = _EWM_SourceStorageType.EWMWarehouse and $projection.StorageType = _EWM_SourceStorageType.EWMStorageType
[0..1] I_EWM_StorageBin_2 _EWM_SourceStorageBin $projection.Warehouse = _EWM_SourceStorageBin.EWMWarehouse and $projection.SourceStorageBin = _EWM_SourceStorageBin.EWMStorageBin
[0..1] C_DefectMngInspectionSubset _DefectMngInspectionSubset $projection.InspectionLot = _DefectMngInspectionSubset .InspectionLot and $projection.InspPlanOperationInternalID = _DefectMngInspectionSubset .InspPlanOperationInternalID and $projection.InspectionSubsetInternalID = _DefectMngInspectionSubset .InspectionSubsetInternalID
[0..*] I_DefectStatusText _DefectStatusText $projection.DefectLifecycleStatus = _DefectStatusText.DefectLifecycleStatus
[0..*] I_DefectCategoryText _DefectCategoryText $projection.DefectCategory = _DefectCategoryText.DefectCategory
[0..1] I_DefectCausedBy _DefectCausedBy $projection.DefectCausedBy = _DefectCausedBy.DefectCausedBy
[1..*] I_DefectCausedByText _DefectCausedByText $projection.DefectCausedBy = _DefectCausedByText.DefectCausedBy

Annotations (20)

NameValueLevelField
AbapCatalog.sqlViewName CDEFECTMNG view
AbapCatalog.compiler.compareFilter true view
ClientHandling.algorithm #SESSION_VARIABLE view
AccessControl.authorizationCheck #CHECK view
AccessControl.personalData.blocking #BLOCKED_DATA_EXCLUDED view
EndUserText.label Manage Defects view
VDM.viewType #CONSUMPTION view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.representativeKey DefectInternalID view
UI.headerInfo.title.label Defect view
UI.headerInfo.title.type #STANDARD view
UI.headerInfo.title.value Defect view
UI.headerInfo.description.label Defects view
UI.headerInfo.description.type #STANDARD view
UI.headerInfo.description.value DefectText view
UI.headerInfo.typeNamePlural Defects view
UI.headerInfo.typeName Defect view
Metadata.allowExtensions true view

Fields (89)

KeyFieldSource TableSource FieldDescription
KEY DefectInternalID I_DefectUnion DefectInternalID
Notification I_DefectUnion Notification
NotificationType I_DefectUnion NotificationType
NotificationTypeName
NotificationItem I_DefectUnion NotificationItem
Defect I_DefectUnion Defect Defect
NotificationItemExternalID I_DefectUnion NotificationItemExternalID
InspectionLot I_DefectUnion InspectionLot
InspPlanOperationInternalID I_DefectUnion InspPlanOperationInternalID
InspectionCharacteristic I_DefectUnion InspectionCharacteristic Inspection Characteristic
InspectionSubsetInternalID I_DefectUnion InspectionSubsetInternalID
MaterialSample I_DefectUnion MaterialSample
DefectText I_DefectUnion DefectText
DefectLifecycleStatus I_DefectUnion DefectLifecycleStatus
DefectCode I_DefectUnion DefectCode Defect Code
DefectCodeText Defect Code Text
DefectCodeGroup I_DefectUnion DefectCodeGroup Defect Code Group
DefectCodeGroupText
DefectCodeGroupAndCode
DefectCategory I_DefectUnion DefectCategory
MaterialName
Material I_DefectUnion Material
PlantName _Plant PlantName
Plant I_DefectUnion Plant
NumberOfDefectsCriticality _DefectCalc NumberOfDefectsCriticality
NumberOfDefects I_DefectUnion NumberOfDefects
CreationDate I_DefectUnion CreationDate
InspectionLotOrigin
SupplierName
Supplier
CustomerName
Customer
DefectClassText Defect Class Text
DefectClass I_DefectUnion DefectClass Defect Class
InspectionLotHasUsageDecision
InspectionLotTypeText
InspectionLotType
Batch I_DefectUnion Batch Batch
BatchStorageLocation
WorkCenter _WorkCenterBySemanticKey WorkCenter Work Center
WorkCenterText
MainWorkCenterInternalID I_DefectUnion MainWorkCenterInternalID
WorkCenterTypeCode I_DefectUnion WorkCenterTypeCode
MainWorkCenterPlant I_DefectUnion MainWorkCenterPlant
StorageLocation I_DefectUnion StorageLocation
ProductionSupplyArea I_DefectUnion ProductionSupplyArea
ProductionSupplyAreaName
Warehouse I_DefectUnion Warehouse
EWMWarehouseDescription
StorageType I_DefectUnion StorageType
EWMStorageTypeName
SourceStorageBin I_DefectUnion SourceStorageBin
ManufacturerName
Manufacturer
PurchasingOrganizationName
PurchasingOrganization Purchasing Organization
PurchasingDocument Purchasing Document
PurchasingDocumentItem Purchasing Document Item
ManufacturerPartNmbr
SalesOrder
SalesOrderItem
DeliveryDocument
SalesOrganization
MaterialByCustomer
CalendarWeek _DefectsWeek CalendarWeek
CalendarYear _DefectsWeek CalendarYear
MaterialIsBatchManaged
InspLotHasSubsets
CreatedByUser I_DefectUnion CreatedByUser
CreationTime I_DefectUnion CreationTime
LastChangedByUser I_DefectUnion LastChangedByUser
LastChangeDate I_DefectUnion LastChangeDate
LastChangeTime I_DefectUnion LastChangeTime
InspectionLotQuantity
InspectionLotQuantityUnit
MaterialDocument
MaterialDocumentItem
MaterialDocumentYear
InspLotUsageDecisionCodeGroup
InspectionLotUsageDecisionCode Usage Decision Code
UsageDecisionCodeText
InspectionLotQualityScore Quality Score
IsBusinessPurposeCompleted
IsDeleted I_DefectUnion IsDeleted
MainWorkCenter I_DefectUnion MainWorkCenter
DefectCausedBy I_DefectUnion DefectCausedBy
DefectLocationCatalog I_DefectUnion DefectLocationCatalog
DefectLocationCodeGroup I_DefectUnion DefectLocationCodeGroup
DefectLocationCodeGroupText
@AbapCatalog.sqlViewName: 'CDEFECTMNG'
@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl: {
    authorizationCheck: #CHECK,
    personalData.blocking: #BLOCKED_DATA_EXCLUDED
}
@EndUserText.label: 'Manage Defects'
@VDM.viewType: #CONSUMPTION
@AccessControl.privilegedAssociations:  [ '_DefectMngCharcs', '_DefectMngCharacteristicsSbst', '_CreatedByUserContactCard', '_LastChangedByUserContactCard' ]

@ObjectModel: {
    usageType: { serviceQuality: #D, sizeCategory: #XL, dataClass: #MIXED },
    semanticKey:  [ 'Defect' ],
    representativeKey: 'DefectInternalID'
}

@UI.headerInfo: {
    title: { label: 'Defect', type: #STANDARD, value: 'Defect' },
    description: { label: 'Defects', type: #STANDARD, value:'DefectText' },
    typeNamePlural: 'Defects',
    typeName: 'Defect'
}

@Metadata.allowExtensions: true
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK" ]  } */
define view C_DefectMng as select from I_DefectUnion as _DefectUnion
    
    //Week & Year format

    association [1..1] to I_CalendarDate                    as _DefectsWeek                           on  $projection.CreationDate                    = _DefectsWeek.CalendarDate

    //Default Value Helps

    association [1..1] to C_Plantvaluehelp                  as _Plant                                 on  $projection.Plant                           = _Plant.Plant
    association [0..1] to C_InspLotSuplrValHelp             as _SupplierVH                            on  $projection.supplier                        = _SupplierVH.Supplier
    association [1..1] to C_InspLotCustValHelp              as _CustomerVH                            on  $projection.customer                        = _CustomerVH.Customer

    // Additional Value helps

    association [0..1] to C_InsLotHasUsgeDcsnT              as _InspLotHasUsgeDcsn                    on  $projection.InspectionLotHasUsageDecision   = _InspLotHasUsgeDcsn.InspectionLotHasUsageDecision

    association [0..1] to I_WorkCenterBySemanticKey         as _WorkCenterBySemanticKey               on  $projection.MainWorkCenterInternalID        = _WorkCenterBySemanticKey.WorkCenterInternalID
                                                                                                      and $projection.MainWorkCenterPlant             = _WorkCenterBySemanticKey.Plant

  // Calculation View

    association [1..1] to C_DefectCalc                      as _DefectCalc                            on  $projection.DefectInternalID                = _DefectCalc.DefectInternalID

//Characteristics View

    association [0..1] to I_InspectionOperation             as _InspectionOperation                   on    $projection.InspectionLot  =   _InspectionOperation.InspectionLot
                                                                                                      and   $projection.InspPlanOperationInternalID =  _InspectionOperation.InspPlanOperationInternalID
//C_DefectMngCharcs- no subset

    association [0..1] to C_DefectMngCharcs                 as _DefectMngCharcs                       on    $projection.InspectionLot                   = _DefectMngCharcs.InspectionLot
                                                                                                      and   $projection.InspPlanOperationInternalID     = _DefectMngCharcs.InspPlanOperationInternalID
                                                                                                      and   $projection.InspectionCharacteristic        = _DefectMngCharcs.InspectionCharacteristic
 // with subset

     association [0..1] to C_DefectMngCharacteristicsSbst   as _DefectMngCharacteristicsSbst          on  $projection.InspectionLot                   = _DefectMngCharacteristicsSbst .InspectionLot
                                                                                                      and $projection.InspPlanOperationInternalID     = _DefectMngCharacteristicsSbst .InspPlanOperationInternalID
                                                                                                      and $projection.InspectionSubsetInternalID      = _DefectMngCharacteristicsSbst .InspectionSubsetInternalID
                                                                                                      and $projection.MaterialSample                  = _DefectMngCharacteristicsSbst .MaterialSample
                                                                                                      and $projection.InspectionCharacteristic        = _DefectMngCharacteristicsSbst .InspectionCharacteristic

// Manufacturing Order

     association [0..1] to I_MfgOrderVH              as _MfgOrderVH                                   on  $projection.ManufacturingOrder = _MfgOrderVH.ManufacturingOrder
     
// EWM

     association [0..1] to I_StorageLocation         as _StorageLocation                              on  $projection.Plant = _StorageLocation.Plant
                                                                                                      and $projection.StorageLocation = _StorageLocation.StorageLocation
     association [0..1] to I_ProductionSupplyArea    as _ProductionSupplyArea                         on  $projection.ProductionSupplyArea = _ProductionSupplyArea.ProductionSupplyArea
                                                                                                      and $projection.Plant = _ProductionSupplyArea.Plant
     association [0..1] to I_EWM_WarehouseNumber_2   as _EWM_WarehouseNumber_2                        on  $projection.Warehouse = _EWM_WarehouseNumber_2.EWMWarehouse
     association [0..1] to I_EWM_StorageType_2       as _EWM_SourceStorageType                        on  $projection.Warehouse = _EWM_SourceStorageType.EWMWarehouse 
                                                                                                      and $projection.StorageType = _EWM_SourceStorageType.EWMStorageType
     association [0..1] to I_EWM_StorageBin_2        as _EWM_SourceStorageBin                         on  $projection.Warehouse = _EWM_SourceStorageBin.EWMWarehouse
                                                                                                      and $projection.SourceStorageBin = _EWM_SourceStorageBin.EWMStorageBin
     
//Inspection Points

     association [0..1] to C_DefectMngInspectionSubset      as _DefectMngInspectionSubset             on  $projection.InspectionLot                   = _DefectMngInspectionSubset .InspectionLot
                                                                                                      and $projection.InspPlanOperationInternalID     = _DefectMngInspectionSubset .InspPlanOperationInternalID
                                                                                                      and $projection.InspectionSubsetInternalID      = _DefectMngInspectionSubset .InspectionSubsetInternalID
//Text Associations (because ALP cannot read text properties (*_Text) from associations

    association [0..*] to I_DefectStatusText    as _DefectStatusText    on $projection.DefectLifecycleStatus = _DefectStatusText.DefectLifecycleStatus
    association [0..*] to I_DefectCategoryText  as _DefectCategoryText  on $projection.DefectCategory = _DefectCategoryText.DefectCategory

//Defect Caused By

    association [0..1] to I_DefectCausedBy          as _DefectCausedBy     on $projection.DefectCausedBy = _DefectCausedBy.DefectCausedBy
    association [1..*] to I_DefectCausedByText      as _DefectCausedByText on $projection.DefectCausedBy = _DefectCausedByText.DefectCausedBy
    
{
       @ObjectModel.readOnly: true
       @Consumption.filter.hidden: true
       key _DefectUnion.DefectInternalID,
       
       // UX Inc

       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_QltyNotificationVH',
                     element: 'QualityNotification' }
        }]
       @ObjectModel.readOnly: true
       _DefectUnion.Notification,
       
       @Consumption.valueHelpDefinition: [
         { entity: { name:    'I_QltyNotificationTypeVH',
                     element: 'NotificationType' }
         }]
       @ObjectModel.foreignKey.association: null
       @ObjectModel.readOnly: true
       @ObjectModel.text.element: ['NotificationTypeName']
       _DefectUnion.NotificationType,
       @ObjectModel.readOnly: true
       _DefectUnion._NotificationType._NotificationTypeName[1: Language = $session.system_language].NotificationTypeName,
       
       @ObjectModel.readOnly: true
       _DefectUnion.NotificationItem,
       
       @ObjectModel.readOnly: true
       @EndUserText.label: 'Defect'
       _DefectUnion.Defect,
       
       @ObjectModel.readOnly: true
       _DefectUnion.NotificationItemExternalID,
       
       // UX FIX

       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_InspectionLotStd1VH',
                     element: 'InspectionLot' }
        }]
       @ObjectModel.readOnly: true
       _DefectUnion.InspectionLot,
       
       @ObjectModel.readOnly: true
       _DefectUnion.InspPlanOperationInternalID,
       
       @ObjectModel.readOnly: true
       case _DefectUnion.DefectCategory
         when '07'
           // Operation is related to production order

           then cast( _DefectUnion.ProductionOrderOperation as vornr preserving type )
           // Operation is related to inspection plan (inspection lot)

           else cast(_InspectionOperation.InspectionOperation as vornr preserving type )
       end                                                                               as InspectionOperation, // Need to stay with one common GFN, even if it not fits for all cases.

       
       //UX Inc

       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_InspectionCharacteristicVH',
                     element: 'InspectionCharacteristic' },
                     additionalBinding: [{ localElement: 'InspectionLot',
                                element: 'InspectionLot' },
                                { localElement: 'InspectionOperation',
                                element: 'InspectionOperation' }]
        }]
       @ObjectModel.readOnly: true
       @EndUserText.label: 'Inspection Characteristic'
       _DefectUnion.InspectionCharacteristic,

       @ObjectModel.readOnly: true
       _DefectUnion.InspectionSubsetInternalID,
       
       @ObjectModel.readOnly: true
       _DefectUnion.MaterialSample,

       @ObjectModel.readOnly: true
       _DefectUnion.DefectText,
       
       @ObjectModel.text.association: '_DefectStatusText'
       _DefectUnion.DefectLifecycleStatus,
      
      //--[ GENERATED:012:GlBfhyFV7kY4h7jYW0xcqG

      @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_DefectCodeStdVH',
                     element: 'DefectCode' },
          additionalBinding: [{ localElement: 'DefectCodeGroup',
                                element: 'DefectCodeGroup' }]
        }]
      // ]--GENERATED

       @ObjectModel: { readOnly: true, text.element:  [ 'DefectCodeText'], foreignKey.association: '_DefectCode' }
       @EndUserText.label: 'Defect Code'
       _DefectUnion.DefectCode,

       @Semantics.text: true
       @EndUserText.label: 'Defect Code Text'
       @Consumption.filter.hidden: true
       _DefectUnion._DefectCode._Text[1:Language=$session.system_language].DefectCodeText,
       
      //--[ GENERATED:012:GlBfhyFV7kY4h7jYW0xcqG

      @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_DefectCodeGroupStdVH',
                     element: 'DefectCodeGroup' }
        }]
      // ]--GENERATED

       @ObjectModel: { readOnly: true, foreignKey.association: '_DefectCodeGroup', text.element: ['DefectCodeGroupText'] }
       @EndUserText.label: 'Defect Code Group'
       _DefectUnion.DefectCodeGroup,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       _DefectUnion._DefectCodeGroup._Text[1:Language=$session.system_language].DefectCodeGroupText,
       
       @ObjectModel: {
         readOnly: true,
         text.element: ['DefectCodeText']
       }
       @Consumption.valueHelpDefinition: [ 
        { entity:  { name:    'I_DefectCodeStdVH',
                     element: 'DefectCodeGroupAndCode' }
        }]
       cast( concat_with_space(_DefectUnion.DefectCodeGroup, _DefectUnion.DefectCode, 1) as qdefect_code_group_and_code preserving type ) as DefectCodeGroupAndCode,
       
       @ObjectModel: { readOnly: true, text.association: '_DefectCategoryText' }  
       _DefectUnion.DefectCategory,   
       
       @Semantics.text: true
       @ObjectModel.readOnly: true
       _Product._Text[1:Language=$session.system_language].ProductName as MaterialName,
       
       @ObjectModel.readOnly: true       
       @ObjectModel: {  text.element:  [ 'MaterialName' ] }
       @Consumption.valueHelpDefinition: [ 
        { entity:  { name:    'I_ProductVH',
                     element: 'Product' }
        }]
       _DefectUnion.Material,
       
       @Semantics.text: true
       @ObjectModel.readOnly: true
       _Plant.PlantName,
       
       @ObjectModel.readOnly: true
       @ObjectModel: {  text.element:  [ 'PlantName' ], foreignKey.association:'_Plant' }
       //UX Inc

       @Consumption.semanticObject: 'Plant'
       _DefectUnion.Plant,       
       
       @Consumption.filter.hidden: true
       _DefectCalc.NumberOfDefectsCriticality,

       @ObjectModel.readOnly: true
       @DefaultAggregation: #SUM
       _DefectUnion.NumberOfDefects,
       
       @ObjectModel.readOnly: true 
       _DefectUnion.CreationDate,
       
       @ObjectModel: { readOnly: true }
       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'C_DefectMngInspLotOriginVH',
                     element: 'InspectionLotOrigin' }
        }]   
       _DefectUnion._InspectionLot.InspectionLotOrigin,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot._Supplier.SupplierName,
       
       @ObjectModel: { readOnly: true, text.element:  [ 'SupplierName' ]  }
       @Consumption.valueHelp: '_SupplierVH'
       //UX Inc

       @Consumption.semanticObject: 'Supplier'
       _DefectUnion._InspectionLot.Supplier,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot._Customer.CustomerName,     
       
       @ObjectModel: { readOnly: true, text.element:  [ 'CustomerName' ]  }
       @Consumption.valueHelp: '_CustomerVH'
       //UX Inc

       @Consumption.semanticObject: 'Customer'
       _DefectUnion._InspectionLot.Customer,
       
       @Semantics.text: true
       @EndUserText.label: 'Defect Class Text'
       _DefectClass._Text[1:Language=$session.system_language].DefectClassText,
       
       @EndUserText.label: 'Defect Class' 
       @ObjectModel: { text.element: ['DefectClassText'] }  
       @Consumption.valueHelpDefinition: [{ association: '_DefectClass' }]    
       _DefectUnion.DefectClass,           
       
       @ObjectModel: { readOnly: true, foreignKey.association: '_InspLotHasUsgeDcsn' }
       @EndUserText: { label: 'Usage Decision Made', quickInfo: 'Usage Decision Made for Inspection Lot' }
       cast ( _DefectUnion._InspectionLot.InspectionLotHasUsageDecision as xfeld preserving type ) as InspectionLotHasUsageDecision ,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       _DefectUnion._InspectionLot._InspectionLotType._Text[1:Language=$session.system_language].InspectionLotTypeText,

       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_InspectionLotType',
                     element: 'InspectionLotType' }
        }]
       @ObjectModel: { readOnly: true, text.element:  [ 'InspectionLotTypeText' ]  }
       _DefectUnion._InspectionLot.InspectionLotType,
       
       
       @ObjectModel: { readOnly: true }
       @EndUserText.label: 'Batch'
       @Consumption: {
         semanticObject: 'Batch',
         valueHelpDefinition: [
         {   entity: { name: 'I_BatchVH', element: 'Batch' },
             additionalBinding: [{ element: 'Plant', localElement: 'Plant' }, { element: 'Material', localElement: 'Material' }]
         }]
       }
       _DefectUnion.Batch,
       
       @ObjectModel: { readOnly: true }
       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_StorageLocation',
                     element: 'StorageLocation' }
        }]
       _DefectUnion._InspectionLot.BatchStorageLocation,
       
       @Consumption.valueHelpDefinition: [ 
        { entity:  { name:    'C_DefectMngWrkCtrValueHelp',
                     element: 'WorkCenter' }
        }]
       @ObjectModel: { readOnly: true, /*foreignKey.association: '_WorkCenterBySemanticKey',*/ text.element:  [ 'WorkCenterText' ]  }
       @EndUserText.label: 'Work Center'
       //_DefectCalc.WorkCenter,

       //UX Inc

       @Consumption.semanticObject: 'WorkCenter'
       _WorkCenterBySemanticKey.WorkCenter,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _WorkCenterBySemanticKey._WorkCenterTextBySemanticKey[1:Language=$session.system_language].WorkCenterText,
       
       @UI.hidden: true
       @ObjectModel.readOnly: true
       @Consumption.filter.hidden: true
       _DefectUnion.MainWorkCenterInternalID,
       
       @UI.hidden: true
       _DefectUnion.WorkCenterTypeCode,
       
       @UI.hidden: true
       @ObjectModel.readOnly: true
       @Consumption.filter.hidden: true
       _DefectUnion.MainWorkCenterPlant,
       
       @ObjectModel: { foreignKey.association: '_StorageLocation',
                       readOnly: true
                     }
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectUnion.StorageLocation,
       
       @ObjectModel: { text.element: [ 'ProductionSupplyAreaName' ],
                       readOnly: true
                     }
       @Consumption.valueHelpDefinition: [
         { entity: { name: 'I_ProductionSupplyAreaStdVH',
           element: 'ProductionSupplyArea' },
           additionalBinding: [{ element: 'Plant', localElement: 'Plant', usage: #FILTER }]
         }
       ]
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectUnion.ProductionSupplyArea,
       @ObjectModel.readOnly: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _ProductionSupplyArea._Text[1: Language = $session.system_language].ProductionSupplyAreaName,
       
       @ObjectModel: { foreignKey.association: '_EWM_WarehouseNumber',
                       readOnly: true,
                       text.element: [ 'EWMWarehouseDescription' ]
                     }
       @Consumption.valueHelpDefinition: [
         { entity: { name: 'I_EWM_WarehouseNumberVH', element: 'EWMWarehouse' } }
       ]
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectUnion.Warehouse,
       @ObjectModel.readOnly: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _EWM_WarehouseNumber_2._Text[1: Language = $session.system_language].EWMWarehouseDescription,
       
       @ObjectModel: { text.element: [ 'EWMStorageTypeName' ],
                       readOnly: true
                     }
       @Consumption.valueHelpDefinition: [
         { entity: { name: 'I_EWM_StorageTypeVH',
           element: 'EWMStorageType' },
           additionalBinding: [{ element: 'Warehouse', localElement: 'Warehouse', usage: #FILTER }]
         }
       ]
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectUnion.StorageType,
       @ObjectModel.readOnly: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _EWM_SourceStorageType._Text[1: Language = $session.system_language].EWMStorageTypeName,
    
       @Consumption.valueHelpDefinition: [
         { entity: { name: 'I_EWM_StorageBinVH', 
           element: 'EWMStorageBin' }, 
           additionalBinding: [{ element: 'Warehouse', localElement: 'Warehouse', usage: #FILTER },
                               { element: 'StorageType', localElement: 'StorageType', usage: #FILTER }]
         }
       ]
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectUnion.SourceStorageBin,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       cast( _DefectUnion._InspectionLot._Manufacturer.SupplierName as vdm_qm_manufacturer_name preserving type ) as ManufacturerName,
       
       @ObjectModel: { readOnly: true, text.element:  [ 'ManufacturerName' ] }
       @Consumption.valueHelpDefinition: [{ entity: { name: 'I_Supplier_VH', element: 'Supplier' } }]
       
       //UX Inc

       @Consumption.semanticObject: 'Supplier'
       _DefectUnion._InspectionLot.Manufacturer,
       
       @Semantics.text: true
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot._PurchasingOrganization.PurchasingOrganizationName,
       
       @ObjectModel: { readOnly: true, text.element:  [ 'PurchasingOrganizationName' ]  }
       @EndUserText.label: 'Purchasing Organization'
       _DefectUnion._InspectionLot.PurchasingOrganization,
       
      //--[ GENERATED:012:GlBfhyFV7kY4h7jYW0xcqG

      @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_PurchasingDocumentStdVH',
                     element: 'PurchasingDocument' }
        }]
      // ]--GENERATED

       @EndUserText.label: 'Purchasing Document'
       //UX Inc

       @Consumption.semanticObject: 'PurchasingDocument'
       _DefectUnion._InspectionLot.PurchasingDocument,
       
       @ObjectModel.readOnly: true
       @EndUserText.label: 'Purchasing Document Item'
       _DefectUnion._InspectionLot.PurchasingDocumentItem,
       
       /*@Semantics.text: true
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectCalc._ManufacturerMatl._Text.MaterialName as ManufacturerPartNmbrText,*/
       
      //--[ GENERATED:012:GlBfhyFV7kY4h7jYW0xcqG

      @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_MaterialStdVH',
                     element: 'Material' }
        }]
      // ]--GENERATED

       @ObjectModel: { readOnly: true}
       _DefectUnion._InspectionLot.ManufacturerPartNmbr,
       
       @ObjectModel: {
          readOnly: true,
          foreignKey.association: '_MfgOrderVH' 
       }
       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_Order',
                     element: 'OrderID' }
        }]
       //UX Inc

       @Consumption.semanticObject: 'ProductionOrder'
       case 
         when _DefectUnion.ProductionOrder is not initial and _DefectUnion.ProductionOrder is not null 
           // Defect is related to production order

           then cast( _DefectUnion.ProductionOrder as vdm_qm_fertaufnr preserving type )
           // Order is related to inspection lot

           else cast( _DefectUnion._InspectionLot.ManufacturingOrder as vdm_qm_fertaufnr preserving type )
       end                                                                                                  as ManufacturingOrder,
      
      // UX Inc

      //--[ GENERATED:012:GlBfhyFV7kY4h7jYW0xcqG

      @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_SalesOrderStdVH',
                     element: 'SalesOrder' }
        }]
       //UX Inc

       @Consumption.semanticObject: 'SalesOrder'
       // ]--GENERATED

       @ObjectModel: { readOnly: true }
       _DefectUnion._InspectionLot.SalesOrder,
       
       
       // UX Inc

       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_SalesOrderItemStdVH',
                     element: 'SalesOrderItem' },
                     additionalBinding: [{ localElement: 'SalesOrder',
                                element: 'SalesOrder' }]
        }]
       @ObjectModel: { readOnly: true }
       _DefectUnion._InspectionLot.SalesOrderItem,
       
      //--[ GENERATED:012:GlBfhyFV7kY4h7jYW0xcqG

      @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_DeliveryDocumentStdVH',
                     element: 'DeliveryDocument' }
        }]
      // ]--GENERATED

       @ObjectModel: { readOnly: true }
       _DefectUnion._InspectionLot.DeliveryDocument,
       
       @ObjectModel: { readOnly: true }
       @Consumption.valueHelpDefinition: [
        { entity:  { name:    'I_SalesOrganization',
                     element: 'SalesOrganization' }
        }]
       //UX Inc

       @Consumption.semanticObject: 'SalesOrganization'
       _DefectUnion._InspectionLot.SalesOrganization,
       
       _DefectUnion._InspectionLot.MaterialByCustomer,
       
       @ObjectModel.readOnly: true
       _DefectsWeek.CalendarWeek,
       
       @ObjectModel.readOnly: true
       _DefectsWeek.CalendarYear,
       
       @UI.hidden: true
       @ObjectModel.readOnly: true
       cast(_DefectUnion._InspectionLot.MaterialIsBatchManaged as xfeld preserving type )  as MaterialIsBatchManaged,
       
       @UI.hidden: true
       @ObjectModel.readOnly: true
       cast (_DefectUnion._InspectionLot.InspLotHasSubsets  as xfeld preserving type ) as InspLotHasSubsets,
       
       @ObjectModel.readOnly: true
       _DefectUnion.CreatedByUser, 
       
       @ObjectModel.readOnly: true
       _DefectUnion.CreationTime,
       
       @ObjectModel.readOnly: true
       _DefectUnion.LastChangedByUser,
       
       @ObjectModel.readOnly: true
       _DefectUnion.LastChangeDate,
       
       @ObjectModel.readOnly: true
       _DefectUnion.LastChangeTime,
       
       //Inspection Lot Details

       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot.InspectionLotQuantity,
       
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot.InspectionLotQuantityUnit,
       
       
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot.MaterialDocument ,
       
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot.MaterialDocumentItem,
       
       @Consumption.filter.hidden: true
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot.MaterialDocumentYear,
       
       
        /*@Consumption.filter.hidden: true
        @ObjectModel.readOnly: true
        @EndUserText.label: 'Sales Order/ Item'
        _DefectUnion._InspectionLot.InventorySpclStkSalesDocument,

        @Consumption.filter.hidden: true
        @ObjectModel.readOnly: true
        @EndUserText.label: 'Sales Order/ Item'
        _DefectUnion._InspectionLot.InventorySpclStkSalesDocItm,*/
      
      
       @ObjectModel.readOnly: true
       _DefectUnion._InspectionLot._InspLotUsageDecision.InspLotUsageDecisionCodeGroup,
       
       @ObjectModel.readOnly: true
       @EndUserText.label: 'Usage Decision Code'
       @ObjectModel.text.element:  [ 'UsageDecisionCodeText' ]
       _DefectUnion._InspectionLot._InspLotUsageDecision.InspectionLotUsageDecisionCode,
       
       @ObjectModel.readOnly: true
       @Consumption.filter.hidden: true
       _DefectUnion._InspectionLot._InspLotUsageDecision._UsageDecisionCode.UsageDecisionCodeText,
       
       @ObjectModel.readOnly: true
       @Consumption.filter.hidden: true
       @EndUserText.label: 'Quality Score'
       _DefectUnion._InspectionLot._InspLotUsageDecision.InspectionLotQualityScore,
       
       @Consumption.hidden: true
       _DefectUnion._InspectionLot.IsBusinessPurposeCompleted,
       
       /*@UI.hidden: true
       _DefectUnion._InspectionLot._InspLotUsageDecision.InspLotUsageDecisionValuation,*/
       
       @UI.hidden: true
       _DefectUnion.IsDeleted,
       
       // Fields for authorization check

       @Consumption.hidden: true
       _DefectUnion.MainWorkCenter,
       
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       @ObjectModel: { foreignKey.association: '_DefectCausedBy' }
       @ObjectModel.text.association: '_DefectCausedByText'
       _DefectUnion.DefectCausedBy,
       
       @ObjectModel.foreignKey.association: '_DefectLocationCatalog'
       _DefectUnion.DefectLocationCatalog,
       @ObjectModel: { foreignKey.association: '_DefectLocationCodeGroup', text.element: ['DefectLocationCodeGroupText'] }
       @Consumption.valueHelpDefinition: [
          { entity: { name: 'I_DefectLocationCodeGroupStdVH', element: 'DefectLocationCodeGroup' },
            additionalBinding: [{ element: 'DefectLocationCatalog', localElement: 'DefectLocationCatalog', usage: #RESULT }]
          }
        ]
       _DefectUnion.DefectLocationCodeGroup,
       @Consumption.filter.hidden: true
       _DefectLocationCodeGroup._Text[1:Language=$session.system_language].DefectLocationCodeGroupText,
       @ObjectModel: { foreignKey.association: '_DefectLocationCode', text.element: ['DefectLocationCodeText'] }
       @Consumption.valueHelpDefinition: [
         { entity: { name: 'I_DefectLocationCodeStdVH', element: 'DefectLocationCode' },
           additionalBinding: [{ element: 'DefectLocationCatalog', localElement: 'DefectLocationCatalog', usage: #RESULT },
                               { element: 'DefectLocationCodeGroup', localElement: 'DefectLocationCodeGroup' }
                              ]
         }
       ]
       _DefectUnion.DefectLocationCode,
       @Consumption.filter.hidden: true
       _DefectLocationCode._DefectLocationCodeText[1:Language=$session.system_language].DefectLocationCodeText,
       
       
       /* Associations */
       _DefectCode,
       _DefectCodeGroup,
       _DefectsWeek,
       _Plant,
       _SupplierVH,
       _CustomerVH,
       _DefectCategory,
       @Consumption.filter.hidden: true
       _DefectCategoryText,
       _DefectClass,
       _InspLotHasUsgeDcsn,
       _InspectionLot._InspectionLotType,
       _InspectionLot._PurchasingOrganization,
       _InspectionLot._Manufacturer,
       _DefectCalc,
       @Consumption.filter.hidden: true
       _DefectMngCharcs,
       @Consumption.filter.hidden: true
       _DefectMngCharacteristicsSbst,
       @Consumption.filter.hidden: true
       _DefectMngInspectionSubset,
       _InspectionLot._InspectionLotOrigin,
       _CreatedByUserContactCard,
       _LastChangedByUserContactCard,
       @Consumption.filter.hidden: true
       _InspectionLot._ManufacturerPartNmbr,
       @Consumption.filter.hidden: true
       @Consumption.hidden: true
       _Notification, //do not publish this association via the OData service, it is just needed for auth. check!

       @Consumption.filter.hidden: true
       _DefectStatus,
       @Consumption.filter.hidden: true
       _DefectStatusText,
       @Consumption.filter.hidden: true
       @Consumption.hidden: true
       _InspectionLot,
       @Consumption.filter.hidden: true
       _MfgOrderVH,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _StorageLocation,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _ProductionSupplyArea,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _EWM_WarehouseNumber,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _EWM_SourceStorageType,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _EWM_SourceStorageBin,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectCausedBy,
       @Consumption.filter.hidden: true
       @Feature: 'QM_CE_DEFECT_WAREHOUSE_DEF'
       _DefectCausedByText,
       @Consumption.filter.hidden: true
       _DefectLocationCatalog,
       @Consumption.filter.hidden: true
       _DefectLocationCodeGroup,
       @Consumption.filter.hidden: true
       _DefectLocationCode,
       @Consumption.filter.hidden: true
       _Product,
       @Consumption.filter.hidden: true
       _InspectionLot._Supplier,
       @Consumption.filter.hidden: true
       _InspectionLot._Customer,
       @Consumption.filter.hidden: true
       _InspectionLot._SalesOrganization,
       @Consumption.filter.hidden: true
       _InspectionLot._InspectionLotQuantityUnit,
       @Consumption.filter.hidden: true
       _InspectionLot._InspLotUsageDecision._UsageDecisionCodeGroup,
       @Consumption.filter.hidden: true
       _InspectionLot._InspLotUsageDecision._UsageDecisionCode,
       @Consumption.filter.hidden: true
       _DefectsWeek._CalendarYear
}