P_PrepayDocVersLogPrcgValTC

DDL: P_PREPAYDOCVERSLOGPRCGVALTC Type: view_entity COMPOSITE

P_PrepayDocVersLogPrcgValTC is a Composite CDS View in SAP S/4HANA. It reads from 6 data sources and exposes 12 fields with key fields PrepaymentAgrmtRefBusObject, PrepaymentDocumentNumber, PrepaymentDocumentItemNumber.

Data Sources (6)

SourceAliasJoin Type
I_PreAgrmtTradingContract contract inner
I_PreAgrmtTradingContractStat ContractApplicationStatus inner
I_PrepayWrkCtrAllowedDocTypes DocTypes from
I_VersionedLogisticDocument FixedVal inner
I_VersionedLogisticDocument MarketVal inner
I_PrepaymentWrkCtrLinkConfign WCPrcConfig inner

Annotations (7)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.sizeCategory #L view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.dataClass #TRANSACTIONAL view
Metadata.ignorePropagatedAnnotations true view

Fields (12)

KeyFieldSource TableSource FieldDescription
KEY PrepaymentAgrmtRefBusObject I_VersionedLogisticDocument OriginReferenceDocBusObjType
KEY PrepaymentDocumentNumber I_PreAgrmtTradingContract TradingContract
KEY PrepaymentDocumentItemNumber I_VersionedLogisticDocument OriginReferenceDocumentItem
PurchasingDocumentItem
quan133endasPrepaymentDocCmmdtyMarketQty
PrepaymentDocCmmdtyMktQtyUnit I_VersionedLogisticDocument CommodityUnit
curr253asPrepaymentTotalAmt
PrepaymentTotalAmountCrcy I_VersionedLogisticDocument DocumentCurrency
CompanyCode I_PreAgrmtTradingContract CompanyCode
Counterparty I_PreAgrmtTradingContract SupplierName
PrepaymentWrkCtrDocPricingOptn I_PrepaymentWrkCtrLinkConfign PrepaymentWrkCtrDocPricingOptn
PrepaymentAgrmtWorkCenterType I_PrepayWrkCtrAllowedDocTypes PrepaymentAgrmtWorkCenterType
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck           : #NOT_REQUIRED
@VDM.private                                : true
@VDM.viewType                               : #COMPOSITE
@ObjectModel.usageType.sizeCategory         : #L
@ObjectModel.usageType.serviceQuality       : #X
@ObjectModel.usageType.dataClass            : #TRANSACTIONAL
@Metadata.ignorePropagatedAnnotations       : true

------------------------------------------------------------------------------------
-- This view will calculate Fixed and Market Prices using CMM_VLOGP table
-- in Document Item Currency
------------------------------------------------------------------------------------

define view entity P_PrepayDocVersLogPrcgValTC
 as select from I_PrepayWrkCtrAllowedDocTypes as DocTypes
-- Document Header
  inner join I_PreAgrmtTradingContract      as contract     on contract.TradingContractType = DocTypes.PrepaymentAgrmtRefDocumentType
                                                            and contract.CustomerName is initial
-- Trading Contract Status
  inner join I_PreAgrmtTradingContractStat as ContractApplicationStatus on ContractApplicationStatus.ContractApplicationStatus = contract.TrdgContrApplicationStatus
-- Pricing Options config
  inner join I_PrepaymentWrkCtrLinkConfign as WCPrcConfig  on WCPrcConfig.PrepaymentAgrmtWorkCenterType = DocTypes.PrepaymentAgrmtWorkCenterType
                                                           and WCPrcConfig.PrepaymentWrkCtrDocPricingOptn  = '01'

  inner join I_VersionedLogisticDocument as FixedVal on FixedVal.OriginReferenceDocument = lpad(contract.TradingContract, 20, '0')

  inner join I_VersionedLogisticDocument                                    as MarketVal
     on MarketVal.PricingKey                        = FixedVal.PricingKey
    and MarketVal.Version                           = FixedVal.Version
    and MarketVal.PricingDocumentItem               = FixedVal.PricingDocumentItem
    and MarketVal.ConditionType                     = FixedVal.MTMCalcGrpMarketPriceCondition
    and MarketVal.SubConditionType                  = FixedVal.SubConditionType
    and MarketVal.MTMConditionGroupCategory         = '2'

  association[1] to I_VlogpConvCurr                                         as FixedValRate
     on FixedValRate.PricingKey                     = FixedVal.PricingKey
    and FixedValRate.Version                        = FixedVal.Version
    and FixedValRate.PricingDocumentItem            = FixedVal.PricingDocumentItem
    and FixedValRate.ConditionType                  = FixedVal.ConditionType
    and FixedValRate.SubConditionType               = FixedVal.SubConditionType
    and FixedValRate.SourceCurrency                 = FixedVal.ConditionTermRateCurrency
    and FixedValRate.TargetCurrency                 = FixedVal.DocumentCurrency

  association[1] to I_VlogpConvCurr                                         as MarketValRate
     on MarketValRate.PricingKey                    = MarketVal.PricingKey
    and MarketValRate.Version                       = MarketVal.Version
    and MarketValRate.PricingDocumentItem           = MarketVal.PricingDocumentItem
    and MarketValRate.ConditionType                 = MarketVal.ConditionType
    and MarketValRate.SubConditionType              = MarketVal.SubConditionType
    and MarketValRate.SourceCurrency                = MarketVal.ConditionTermRateCurrency
    and MarketValRate.TargetCurrency                = MarketVal.DocumentCurrency

{
    key FixedVal.OriginReferenceDocBusObjType                               as PrepaymentAgrmtRefBusObject,
    key contract.TradingContract                                            as PrepaymentDocumentNumber,
    key FixedVal.OriginReferenceDocumentItem                                as PrepaymentDocumentItemNumber,

        right( FixedVal.OriginReferenceDocumentItem, 5 )                    as PurchasingDocumentItem,

        @Semantics.quantity.unitOfMeasure: 'PrepaymentDocCmmdtyMktQtyUnit'
        sum(
        case when FixedVal.ConditionTermRateIsFixed = ' ' and
                  ( FixedVal.MTMCalculationGroup = 'B' or FixedVal.MTMCalculationGroup = 'F' )
             then MarketVal.CommodityQuantity

             else cast( 0 as abap.quan(13,3)) end  )                        as PrepaymentDocCmmdtyMarketQty,

        FixedVal.CommodityUnit                                              as PrepaymentDocCmmdtyMktQtyUnit,

        @Semantics.amount.currencyCode: 'PrepaymentTotalAmountCrcy'
      cast(cast(
        sum(
        case when FixedVal.ConditionTermRateIsFixed   = 'X' and
                  FixedVal.ConditionTermRateCurrency  = FixedVal.DocumentCurrency
             then curr_to_decfloat_amount(FixedVal.ConditionTermValue)

             when FixedVal.ConditionTermRateIsFixed   = 'X' and
                  FixedVal.ConditionTermRateCurrency  <> FixedVal.DocumentCurrency
             then curr_to_decfloat_amount(FixedVal.ConditionTermValue) * FixedValRate.TargetConversionFactor

             when FixedVal.ConditionTermRateIsFixed   = ' ' and
                  MarketVal.ConditionTermRateCurrency = MarketVal.DocumentCurrency
             then curr_to_decfloat_amount(MarketVal.ConditionTermValue)

             when FixedVal.ConditionTermRateIsFixed   = ' ' and
                  MarketVal.ConditionTermRateCurrency <> MarketVal.DocumentCurrency and
                  FixedVal.ConditionTermExchRateIsFixed   = ' '
             then curr_to_decfloat_amount(MarketVal.ConditionTermValue) * MarketValRate.TargetConversionFactor

             when FixedVal.ConditionTermRateIsFixed   = ' ' and
                  MarketVal.ConditionTermRateCurrency <> MarketVal.DocumentCurrency and
                  FixedVal.ConditionTermExchRateIsFixed   = 'X'
             then curr_to_decfloat_amount(MarketVal.ConditionTermValue) * FixedValRate.TargetConversionFactor

             else 0 end ) as abap.dec(25,3)) as abap.curr(25,3) )           as PrepaymentTotalAmt,


        FixedVal.DocumentCurrency                                           as PrepaymentTotalAmountCrcy,
        contract.CompanyCode,
        contract.SupplierName                                               as Counterparty,
        WCPrcConfig.PrepaymentWrkCtrDocPricingOptn,
        DocTypes.PrepaymentAgrmtWorkCenterType

}
where FixedVal.MTMConditionGroupCategory = '1'
  and FixedVal.Version is initial
  and DocTypes.PrepaymentAgrmtWorkCenterType = '1'

group by FixedVal.OriginReferenceDocBusObjType,
         contract.TradingContract,
         FixedVal.OriginReferenceDocumentItem,
         FixedVal.DocumentCurrency,
         FixedVal.CommodityUnit,
         contract.CompanyCode,
         contract.SupplierName,
         WCPrcConfig.PrepaymentWrkCtrDocPricingOptn,
         DocTypes.PrepaymentAgrmtWorkCenterType