P_PrepaymentDocVersLogPrcgVal

DDL: P_PREPAYMENTDOCVERSLOGPRCGVAL SQL: PPPMGDOCVERSLOG Type: view COMPOSITE

P_PrepaymentDocVersLogPrcgVal is a Composite CDS View in SAP S/4HANA. It reads from 2 data sources (I_VersionedLogisticDocument, I_VersionedLogisticDocument) and exposes 8 fields with key fields PrepaymentAgrmtRefBusObject, PrepaymentDocumentNumber, PrepaymentDocumentItemNumber.

Data Sources (2)

SourceAliasJoin Type
I_VersionedLogisticDocument FixedVal from
I_VersionedLogisticDocument MarketVal inner

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName PPPMGDOCVERSLOG view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
ClientHandling.algorithm #SESSION_VARIABLE view
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 (8)

KeyFieldSource TableSource FieldDescription
KEY PrepaymentAgrmtRefBusObject I_VersionedLogisticDocument OriginReferenceDocBusObjType
KEY PrepaymentDocumentNumber
KEY PrepaymentDocumentItemNumber I_VersionedLogisticDocument OriginReferenceDocumentItem
PurchasingDocumentItem
quan133endasPrepaymentDocCmmdtyMarketQty
PrepaymentDocCmmdtyMktQtyUnit I_VersionedLogisticDocument CommodityUnit
curr253asPrepaymentTotalAmt
PrepaymentTotalAmountCrcy I_VersionedLogisticDocument DocumentCurrency
@AbapCatalog.sqlViewName                    : 'PPPMGDOCVERSLOG'
@AbapCatalog.compiler.compareFilter         : true
@AbapCatalog.preserveKey                    : true
@ClientHandling.algorithm                   : #SESSION_VARIABLE
@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 from CMM_VLOGP table
--      in Document Item Currency
------------------------------------------------------------------------------------

define view P_PrepaymentDocVersLogPrcgVal
  as select from I_VersionedLogisticDocument                                as FixedVal

  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 RIGHT( FixedVal.OriginReferenceDocument, 10 )                       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,

        @Semantics.unitOfMeasure: true
        FixedVal.CommodityUnit                                              as PrepaymentDocCmmdtyMktQtyUnit,

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

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

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

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

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

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

        @Semantics.currencyCode: true
        FixedVal.DocumentCurrency                                           as PrepaymentTotalAmountCrcy

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

group by FixedVal.OriginReferenceDocBusObjType,
         FixedVal.OriginReferenceDocument,
         FixedVal.OriginReferenceDocumentItem,
         FixedVal.DocumentCurrency,
         FixedVal.CommodityUnit
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_VERSIONEDLOGISTICDOCUMENT",
"I_VLOGPCONVCURR"
],
"ASSOCIATED":
[
"I_VLOGPCONVCURR"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/