P_PurchaseContractTargetAmount

DDL: P_PURCHASECONTRACTTARGETAMOUNT SQL: PMMPCTARAMT Type: view CONSUMPTION Package: ODATA_MM_ANALYTICS

Purchase Contract Target Amount

P_PurchaseContractTargetAmount is a Consumption CDS View that provides data about "Purchase Contract Target Amount" in SAP S/4HANA. It reads from 3 data sources (I_PurContractClassification, I_PurchaseContract, I_PurchaseContractItem) and exposes 4 fields with key field PurchaseContract. Part of development package ODATA_MM_ANALYTICS.

Data Sources (3)

SourceAliasJoin Type
I_PurContractClassification ContractClassification inner
I_PurchaseContract PurchaseContract inner
I_PurchaseContractItem PurchaseContractItem from

Parameters (4)

NameTypeDefault
P_DisplayCurrency displaycurrency
P_Material matnr
P_StartDate vdm_validitystart
P_EndDate vdm_validityend

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName PMMPCTARAMT view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #CHECK view
VDM.viewType #CONSUMPTION view
VDM.private true view
AccessControl.personalData.blocking #NOT_REQUIRED view

Fields (4)

KeyFieldSource TableSource FieldDescription
KEY PurchaseContract I_PurchaseContract ActivePurchasingDocument
PurchasingGroup I_PurchaseContract PurchasingGroup
PurchasingOrganization I_PurchaseContract PurchasingOrganization
Plant Plant
@AbapCatalog.sqlViewName: 'PMMPCTARAMT'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@VDM.viewType : #CONSUMPTION
@VDM.private: true
@AccessControl.personalData.blocking: #NOT_REQUIRED
@AbapCatalog.viewEnhancementCategory: [#PROJECTION_LIST,#GROUP_BY] // Added for extensibility


define view P_PurchaseContractTargetAmount
  with parameters
    P_DisplayCurrency : displaycurrency,
    P_Material        : matnr,
    P_StartDate       : vdm_validitystart,
    P_EndDate         : vdm_validityend

  as select from I_PurchaseContractItem      as PurchaseContractItem

    inner join   I_PurchaseContract          as PurchaseContract       on PurchaseContractItem.PurchaseContract = PurchaseContract.ActivePurchasingDocument

    inner join   I_PurContractClassification as ContractClassification on PurchaseContract.PurchaseContractType = ContractClassification.PurchasingDocumentType

{
  key PurchaseContract.ActivePurchasingDocument as PurchaseContract,

      //included for DCL

      PurchaseContract.PurchasingGroup,
      PurchaseContract.PurchasingOrganization,
      Plant,

      case when ContractClassification.PurchaseContractClassification  = '0'           // WK : Amount type and MK : Quantity type

                then
                    currency_conversion
                    (
                       amount             => PurchaseContract.PurchaseContractTargetAmount,
                       source_currency    => PurchaseContract.DocumentCurrency,
                       target_currency    =>  :P_DisplayCurrency,
                       exchange_rate_date => PurchaseContract.CreationDate,
                       exchange_rate_type => 'M',
                       error_handling => 'FAIL_ON_ERROR'
                    )
               when ContractClassification.PurchaseContractClassification = '1'
                then   sum(case when ContractClassification.PurchaseContractClassification = '1' then
                              currency_conversion
                              (
                                 amount             => TargetAmount,
                                 source_currency    => PurchaseContract.DocumentCurrency,
                                 target_currency    =>  :P_DisplayCurrency,
                                 exchange_rate_date => PurchaseContract.CreationDate,
                                 exchange_rate_type => 'M',
                                 error_handling => 'FAIL_ON_ERROR'
                              ) else 0 end
                          )
               else 0
          end                                   as PurchaseContractTargetAmount

}
where
      PurchaseContract.PurchasingDocumentDeletionCode     = ''
  and PurchaseContractItem.PurchasingContractDeletionCode = ''
  and PurchaseContract.IsEndOfPurposeBlocked              = ''
  and Material                                            = $parameters.P_Material
  and CreationDate                                        between $parameters.P_StartDate and $parameters.P_EndDate


group by
  PurchaseContract.ActivePurchasingDocument,
  PurchaseContract.PurchasingGroup,
  PurchaseContract.PurchasingOrganization,
  Plant,
  ContractClassification.PurchaseContractClassification,
  PurchaseContract.PurchaseContractTargetAmount,
  PurchaseContract.DocumentCurrency,
  PurchaseContract.CreationDate