C_QuantityVariance

DDL: C_QUANTITYVARIANCE SQL: CMMQUANTVAR Type: view CONSUMPTION Package: ODATA_MM_ANALYTICS

Quantity Variance

C_QuantityVariance is a Consumption CDS View that provides data about "Quantity Variance" in SAP S/4HANA. It reads from 3 data sources (I_CalendarDate, P_SupplierEvalByQuantity, P_QuantityVarianceUpdatedScore). It has 6 associations to related views. It is used in 5 Fiori applications: Supplier Evaluation by Price (Version 2), Supplier Evaluation by Time (Version 2), Supplier Evaluation by Questionnaire (Version 2), .... Part of development package ODATA_MM_ANALYTICS.

Data Sources (3)

SourceAliasJoin Type
I_CalendarDate Calendar left_outer
P_SupplierEvalByQuantity P_SupplierEvalByQuantity from
P_QuantityVarianceUpdatedScore UpdatedScore left_outer

Parameters (4)

NameTypeDefault
P_DisplayCurrency displaycurrency
P_StartDate bedat
P_EndDate bedat
P_DateFunction datefunctionid

Associations (6)

CardinalityTargetAliasCondition
[1..1] C_MM_SupplierValueHelp _Supplier $projection.Supplier = _Supplier.Supplier and $projection.CompanyCode = _Supplier.CompanyCode
[1..1] I_PurchasingOrganization _PurchasingOrganization $projection.PurchasingOrganization = _PurchasingOrganization.PurchasingOrganization
[1..1] I_PurchasingGroup _PurchasingGroup $projection.PurchasingGroup = _PurchasingGroup.PurchasingGroup
[1..1] I_MaterialGroup _MaterialGroup $projection.MaterialGroup = _MaterialGroup.MaterialGroup
[1..1] I_Material _Material $projection.Material = _Material.Material
[1..1] I_Plant _Plant $projection.Plant = _Plant.Plant

Annotations (11)

NameValueLevelField
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XL view
AbapCatalog.sqlViewName CMMQUANTVAR view
AbapCatalog.compiler.compareFilter true view
VDM.viewType #CONSUMPTION view
EndUserText.label Quantity Variance view
OData.publish true view
AccessControl.authorizationCheck #CHECK view
AccessControl.personalData.blocking #NOT_REQUIRED view

Fiori Apps (5)

App IDApp NameTypeDescription
F1663A Supplier Evaluation by Price (Version 2) Analytical With the Supplier Evaluation by Price app, you can determine the score of a given supplier in an organization based on the variance in the price of ordered items and delivered items. The score is calculated over a period of one year and is based on the difference in the purchase order amount and invoice amount. Both the excess and less price are considered as variance.
F1664A Supplier Evaluation by Time (Version 2) Analytical You can use this app to determine the score of a given supplier in an organisation based on the difference in time between the ordered date of items and delivered date of items. The score is calculated over a period of 365 days. Both the late and earlier deliveries of items are considered as variance.
F2234A Supplier Evaluation by Questionnaire (Version 2) Analytical
F2309A Supplier Evaluation by Quality (Version 2) Analytical With the Supplier Evaluation by Quality app, you can determine the scores for given suppliers based on the inspection lot.
F3295A Supplier Evaluation By Quality (for Quality Notification) (Version 2) Analytical

Supplier Evaluation by Price (Version 2)

Business Role: Strategic Buyer

This new app is a replacement for the app , which is planned to be deprecated with SAP S/4HANA Cloud 2102. We recommend that you start using this new app instead of the old app Supplier Evaluation by Quality (Deprecated). SAP Fiori ID for this app is F3295A. You can now view number of purchase orders and number of purchase order items with this app.

Supplier Evaluation by Time (Version 2)

Business Role: Strategic Buyer

You can use this app to determine the score of a given supplier in an organization based on the difference in time between the ordered date of items and delivered date of items. The score is calculated over a period of 365 days. Both the late and earlier deliveries of items are considered as variance. The role Strategic Buyer (SAP_BR_BUYER) is required to access the role. The KPI is displayed in the following views: •By Supplier•By Purchasing Group•By Purchasing Organization•By Material Group•Document•Trend

Supplier Evaluation by Questionnaire (Version 2)

Business Role: Strategic Buyer

This app determines the evaluation scores for the given suppliers based on the questionnaires. You can also view the target score for the supplier to compare it with the actual calculated score. The role Strategic Buyer (SAP_BR_BUYER) is required to access the app.

Supplier Evaluation by Quality (Version 2)

Business Role: Strategic Buyer

This app determines the score of a supplier in an organization based on the weighted average of the quantity, price, and time variances. The score is calculated over a period of 365 days. It combines scores from the weighted hard facts available from the different criteria (price, time, and quantity), and the soft facts available from questionnaire results. The role Strategic Buyer (SAP_BR_BUYER) is required to access the app.

Supplier Evaluation By Quality (for Quality Notification) (Version 2)

Business Role: Strategic Buyer

With this app you can evaluate suppliers based on score that is calculated on the basis of quality complaints received. You can identify the suppliers with less received complaint notifications and thus with higher quality evaluation score. This helps you to determine the suppliers with the best performance and reliability. This app can also help you to decide which supplier to select if the purchasing conditions such as quality and price of material, quotation and delivery time are the same.

@ClientHandling.algorithm: #SESSION_VARIABLE //Inserted by VDM CDS Suite Plugin

@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.sizeCategory: #XL
@AbapCatalog.sqlViewName: 'CMMQUANTVAR'
//Commented by VDM CDS Suite Plugin:@ClientDependent: true

@AbapCatalog.compiler.compareFilter: true
@VDM.viewType: #CONSUMPTION
@EndUserText.label: 'Quantity Variance'
//Commented as analytical manager no longer supports AVG, COUNT, COUNT_DISTINCT

//@Analytics.dataCategory: #CUBE

@OData.publish: true
@AccessControl.authorizationCheck: #CHECK
@AccessControl.personalData.blocking: #NOT_REQUIRED

define view C_QuantityVariance

  with parameters
    @Consumption.defaultValue: 'EUR'
    @Consumption.valueHelpDefinition: [{
      entity: {
        name:'I_Currency',
        element:'Currency'
      }
    }]
    P_DisplayCurrency           : displaycurrency,
    
    @Consumption.derivation: { lookupEntity: 'C_SglGregorianCalDateFunction', 
    resultElement: 'DateFunctionStartDate', binding: [ {
      targetParameter: 'P_DateFunction', type: #PARAMETER, value : 'P_DateFunction' },
       { targetParameter : 'P_Language' , type : #SYSTEM_FIELD, value : '#SYSTEM_LANGUAGE'  } ] 
    } 
    @Consumption.hidden: true
    P_StartDate: bedat,
    
    @Consumption.derivation: { lookupEntity: 'C_SglGregorianCalDateFunction', 
    resultElement: 'DateFunctionEndDate', binding: [ {
      targetParameter: 'P_DateFunction', type: #PARAMETER, value : 'P_DateFunction' },
       { targetParameter : 'P_Language' , type : #SYSTEM_FIELD, value : '#SYSTEM_LANGUAGE'  } ] 
    } 
    @Consumption.hidden: true
    P_EndDate: bedat,
    @Consumption.defaultValue: 'PREVIOUSYEARTODATE'
    @Consumption.valueHelpDefinition: [{
      entity: {
        name:'C_GregorianCalDateFuncVH',
        element:'DateFunction'
      }
    }]
    P_DateFunction              : datefunctionid 
  as select from    P_SupplierEvalByQuantity( P_DisplayCurrency : $parameters.P_DisplayCurrency,
                                              P_StartDate : $parameters.P_StartDate,
                                              P_EndDate : $parameters.P_EndDate)    as QuantityVariance

//   inner join P_SuplrEvalScoring as CalculatedScore on (   QuantityVariance.PurchasingOrganization = CalculatedScore.PurchasingOrganization

//                                                      and CalculatedScore.SuplrEvalCriterion                = '2'

//                                                      and QuantityVariance.QuantityVariancePctWithSign     = CalculatedScore.AbsolutePercentage

//                                                      and CalculatedScore.IsSupplierEvalSwitchActive = 'X'

//                                                      )

//                                                   or (    (  ( QuantityVariance.PurchasingCategory    = CalculatedScore.PurchasingCategory )

//                                                          or ( QuantityVariance.PurchasingCategory is null and CalculatedScore.PurchasingCategory is null ) )

//

//                                                      and CalculatedScore.SuplrEvalCriterion                = '02'

//                                                      and QuantityVariance.QuantityVariancePctWithSign     = CalculatedScore.AbsolutePercentage

//                                                      and CalculatedScore.IsSupplierEvalSwitchActive = 'X'

//                                                      

//                                                   )

    
    left outer join P_QuantityVarianceUpdatedScore  as UpdatedScore     on  QuantityVariance.PurchaseOrder     = UpdatedScore.PurchaseOrder
                                                                                 and QuantityVariance.PurchaseOrderItem = UpdatedScore.PurchaseOrderItem
    left outer  join  I_CalendarDate as Calendar    on PurchaseOrderDate = Calendar.CalendarDate
    
  association [1..1] to C_MM_SupplierValueHelp   as _Supplier                   on $projection.Supplier = _Supplier.Supplier 
                                                                               and $projection.CompanyCode = _Supplier.CompanyCode

  association [1..1] to I_PurchasingOrganization as _PurchasingOrganization     on $projection.PurchasingOrganization = _PurchasingOrganization.PurchasingOrganization

  association [1..1] to I_PurchasingGroup        as _PurchasingGroup            on $projection.PurchasingGroup = _PurchasingGroup.PurchasingGroup
  
  association [1..1] to I_MaterialGroup          as _MaterialGroup              on $projection.MaterialGroup = _MaterialGroup.MaterialGroup

  association [1..1] to I_Material               as _Material                   on $projection.Material = _Material.Material

  association [1..1] to I_Plant                  as _Plant                      on $projection.Plant = _Plant.Plant

{
      /* Keys */
  key cast( QuantityVariance.PurchaseOrder as vdm_purchaseorder )                       as  PurchaseOrder,
  key cast( QuantityVariance.PurchaseOrderItem as vdm_purchaseorderitem)                as  PurchaseOrderItem,


  @Consumption: {
                      filter: {                    -- Usage of derviation.lookupEntity requires a filter definition too!
                                mandatory: false,
                                hidden: true,
                                selectionType: #SINGLE,
                                multipleSelections: false
                              },
  //                     hidden: true,

                      derivation: {
                                    lookupEntity: 'F_SuplrEvalCriteriaGenConfign',
                                    resultElement: 'SuplrEvalCritraDelivCompleted'
                                  }
                    }
  @Environment.sql.passValue: true 
  //@Semantics.booleanIndicator:true

  SuplrEvalCritraDelivCompleted , 
  
      /* Order Date */
      PurOrdItmFirstGRPostingDate,
      PurOrdItmFinalGRPostingDate,
      @Semantics.calendar.year: true
      Calendar.CalendarYear,
      Calendar.CalendarQuarter,
      Calendar.CalendarMonth,
      Calendar.CalendarWeek,

      /* Org Data */
      @Consumption.labelElement: 'PurchasingOrganizationName'
      @Consumption.valueHelpDefinition: [{ entity: { name : 'C_PurchasingOrgValueHelp', element : 'PurchasingOrganization' } }]
      QuantityVariance.PurchasingOrganization,
      @Semantics.text: true
      _PurchasingOrganization.PurchasingOrganizationName ,
      @Consumption.labelElement: 'PurchasingGroupName'
      @Consumption.valueHelpDefinition: [{ entity: { name : 'C_PurchasingGroupValueHelp', element : 'PurchasingGroup' } }]
      PurchasingGroup,
      @Semantics.text: true
      _PurchasingGroup.PurchasingGroupName,
      CompanyCode,

      /* Supplier Data */
      @Consumption.labelElement: 'SupplierName'
      @Consumption.valueHelpDefinition: [{ entity: { name : 'C_MM_SmplSupplierValueHelp', element : 'Supplier' } }]
      Supplier,
      @Semantics.text: true
      _Supplier.SupplierName,
      @Consumption.labelElement: 'CountryName'
      _Supplier.Country                                                                 as   SupplierCountry,
      @Semantics.text: true
      _Supplier._CountryText[1: Language = $session.system_language].CountryName,

      /* Item Data */
      @Consumption.labelElement: 'MaterialName'
      @Consumption.valueHelpDefinition: [{ entity: { name : 'C_MM_MaterialValueHelp', element : 'Material' } }]
      Material,
      @Semantics.text: true
      _Material._Text[1: Language = $session.system_language].MaterialName,

      @Consumption.labelElement: 'MaterialGroupName'
      QuantityVariance.MaterialGroup,
      @Semantics.text: true
      _MaterialGroup._Text[1: Language = $session.system_language].MaterialGroupName,

      @Consumption.labelElement: 'PlantName'
      Plant,
      @Semantics.text: true
      _Plant.PlantName                                                                  as  PlantName,

      @ObjectModel.text.element: ['PurgCatName']
      @Consumption.labelElement: 'PurgCatName'
      @Consumption.valueHelpDefinition: [{ entity: { name : 'I_PurchasingCategoryValueHelp', element : 'PurchasingCategory' } }]
      PurchasingCategory,
      @Semantics.text: true
      PurgCatName,

      @Semantics.unitOfMeasure: true
      PurchaseOrderQuantityUnit,

      @Semantics.currencyCode: true
      cast( DisplayCurrency as displaycurrency )                                        as  DisplayCurrency,

      /* Measures */
      @DefaultAggregation: #SUM
      @Semantics.quantity.unitOfMeasure: 'PurchaseOrderQuantityUnit'
      cast( OrderedQuantity as mm_a_ordered_quantity )                                  as  OrderedQuantity,
      @EndUserText.label: 'Goods Receipt Quantity'
      @DefaultAggregation: #SUM
      @Semantics.quantity.unitOfMeasure: 'PurchaseOrderQuantityUnit'
      DeliveredQuantity                                                                 as  GoodsReceiptQty,

      @DefaultAggregation: #SUM
      @Semantics.quantity.unitOfMeasure: 'PurchaseOrderQuantityUnit'
      cast ( QuantityVarianceInOrdUnit as mm_a_quantity_variance )                      as  QuantityVarianceInOrdUnit,

      @DefaultAggregation: #SUM
      @Semantics.amount.currencyCode: 'DisplayCurrency'
      cast( QuantityVarianceInDspCrcy as mm_a_quantity_var_amount )                     as  QuantityVarianceInDspCrcy,

      @DefaultAggregation: #AVG
//      0 as QuantityVarianceScore,

      cast( case when UpdatedScore.IsScoreChanged = 'X' 
        then UpdatedScore.QuantityVarianceScore
       else SupplierEvaluationScore
      end as mm_a_variance_score )                                                      as  QuantityVarianceScore,


      @DefaultAggregation: #AVG
      cast ( QuantityVarianceInPct as mmpur_ana_de_quantityvar_pct )                               as  QuantityVarianceInPct , // changed the DE to avoid numeric overflow error , as this filed holds the variance and not percentage mm_a_timevar_statdeliv_pct 

      
       
      
      // @EndUserText.label: 'Purchase Order Count'

       @Aggregation.referenceElement: ['PurchaseOrder']
      @Aggregation.default: #COUNT_DISTINCT
       cast( 1 as mm_pur_ana_numbrofpurords ) as NumberOfPurchaseOrders,    
       
      //@EndUserText.label: 'Purchase Order Item Count'

        @DefaultAggregation: #SUM
       cast( 1 as mm_pur_ana_numbrofpurorditms ) as NumberOfPurchaseOrderItems  
      
}