P_PrepaymentRefDocTotalAmtPO

DDL: P_PREPAYMENTREFDOCTOTALAMTPO Type: view_entity COMPOSITE

Prepayment Document Total Amount

P_PrepaymentRefDocTotalAmtPO is a Composite CDS View that provides data about "Prepayment Document Total Amount" in SAP S/4HANA. It reads from 4 data sources (I_PrepayWrkCtrAllowedDocTypes, I_PurchasingDocument, I_PurchasingDocumentItem, I_PrepaymentMaterial) and exposes 18 fields with key fields PrepaymentAgrmtWorkCenterType, PrepaymentAgrmtRefDocumentCat, PrepaymentAgrmtRefBusObject, DocNumber, DocumentItemNumber. It has 2 associations to related views.

Data Sources (4)

SourceAliasJoin Type
I_PrepayWrkCtrAllowedDocTypes DocTypes from
I_PurchasingDocument Document inner
I_PurchasingDocumentItem DocumentItem inner
I_PrepaymentMaterial Material inner

Associations (2)

CardinalityTargetAliasCondition
[0..1] P_PrepayDocVersLogPrcgValPO CMMPrice CMMPrice.PrepaymentWrkCtrDocPricingOptn = WCPrcConfig.PrepaymentWrkCtrDocPricingOptn and Material.Commodity is not initial and CMMPrice.PrepaymentAgrmtRefBusObject = 'BUS2012' and CMMPrice.PrepaymentDocumentNumber = Document.PurchasingDocument and CMMPrice.PurchasingDocumentItem = DocumentItem.PurchasingDocumentItem and CMMPrice.CompanyCode = Document.CompanyCode and CMMPrice.Counterparty = Document.Supplier -- CPE Price
[0..1] I_PrepayDocumentMarketDataPO CPEPrice CPEPrice.PrepaymentWrkCtrDocPricingOptn = WCPrcConfig.PrepaymentWrkCtrDocPricingOptn and CPEPrice.PurchasingDocument = Document.PurchasingDocument and Material.Commodity is not initial and CPEPrice.PrepaymentRefDocCondition = Document.PurchasingDocumentCondition and CPEPrice.PurchasingDocumentItem = DocumentItem.PurchasingDocumentItem and CPEPrice.CompanyCode = Document.CompanyCode and CPEPrice.Counterparty = Document.Supplier

Annotations (8)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.sizeCategory #L view
ObjectModel.usageType.serviceQuality #A view
ObjectModel.usageType.dataClass #TRANSACTIONAL view
Metadata.ignorePropagatedAnnotations true view
EndUserText.label Prepayment Document Total Amount view

Fields (18)

KeyFieldSource TableSource FieldDescription
KEY PrepaymentAgrmtWorkCenterType I_PrepayWrkCtrAllowedDocTypes PrepaymentAgrmtWorkCenterType
KEY PrepaymentAgrmtRefDocumentCat I_PrepayWrkCtrAllowedDocTypes PrepaymentAgrmtRefDocumentCat
KEY PrepaymentAgrmtRefBusObject
KEY DocNumber I_PurchasingDocument PurchasingDocument
KEY DocumentItemNumber
PurchasingDocumentITem I_PurchasingDocumentItem PurchasingDocumentItem
PrepaymentAgrmtRefDocument
CompanyCode I_PurchasingDocument CompanyCode
DocumentType I_PurchasingDocument PurchasingDocumentType
Counterparty I_PurchasingDocument Supplier
PrepaymentRefDocItmValdFromDte I_PurchasingDocument ValidityStartDate
PrepaymentRefDocItmValdToDte I_PurchasingDocument ValidityEndDate
Material I_PurchasingDocumentItem Material
Commodity I_PrepaymentMaterial Commodity
OrderQuantity I_PurchasingDocumentItem OrderQuantity
OrderQuantityUnit I_PurchasingDocumentItem OrderQuantityUnit
curr232asPrepaymentTotalAmt
PrepaymentTotalAmtCrcy I_PurchasingDocument DocumentCurrency
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck           : #NOT_REQUIRED
@VDM.private                                : true
@VDM.viewType                               : #COMPOSITE
@ObjectModel.usageType.sizeCategory         : #L
@ObjectModel.usageType.serviceQuality       : #A
@ObjectModel.usageType.dataClass            : #TRANSACTIONAL
@Metadata.ignorePropagatedAnnotations       : true
@EndUserText.label: 'Prepayment Document Total Amount'

-- This view will get the Total price for Applicable documents in Work Center
-- Based on Pricing Option configuration, one of below 3 options will be used for
-- Total Amount derrivations:
--    VLOGP: Using CMM_VLOGP data
--    CPE: Using CPE tables data
--    Net Price: Net Price from the document
-- This view retrieves data for Purchase orders

define view entity P_PrepaymentRefDocTotalAmtPO

  -- Valid Doc Types
  as select from           I_PrepayWrkCtrAllowedDocTypes as DocTypes

  -- Document Header
    inner join             I_PurchasingDocument          as Document     on Document.PurchasingDocumentType = DocTypes.PrepaymentAgrmtRefDocumentType

  -- Document Item
    inner join             I_PurchasingDocumentItem      as DocumentItem on DocumentItem.PurchasingDocument = Document.PurchasingDocument

  -- Material and Commodity
    inner join             I_PrepaymentMaterial          as Material     on DocumentItem.Material = Material.Material

  -- Pricing Options config
    left outer to one join I_PrepaymentWrkCtrLinkConfign as WCPrcConfig  on WCPrcConfig.PrepaymentAgrmtWorkCenterType = DocTypes.PrepaymentAgrmtWorkCenterType

  -- CMM Prices
  association [0..1] to P_PrepayDocVersLogPrcgValPO  as CMMPrice on  CMMPrice.PrepaymentWrkCtrDocPricingOptn = WCPrcConfig.PrepaymentWrkCtrDocPricingOptn
                                                                 and Material.Commodity                      is not initial
                                                                 and CMMPrice.PrepaymentAgrmtRefBusObject    = 'BUS2012'
                                                                 and CMMPrice.PrepaymentDocumentNumber       = Document.PurchasingDocument
                                                                 and CMMPrice.PurchasingDocumentItem         = DocumentItem.PurchasingDocumentItem
                                                                 and CMMPrice.CompanyCode                    = Document.CompanyCode
                                                                 and CMMPrice.Counterparty                   = Document.Supplier
  -- CPE Price
  association [0..1] to I_PrepayDocumentMarketDataPO as CPEPrice on  CPEPrice.PrepaymentWrkCtrDocPricingOptn = WCPrcConfig.PrepaymentWrkCtrDocPricingOptn
                                                                 and CPEPrice.PurchasingDocument             = Document.PurchasingDocument
                                                                 and Material.Commodity                      is not initial
                                                                 and CPEPrice.PrepaymentRefDocCondition      = Document.PurchasingDocumentCondition
                                                                 and CPEPrice.PurchasingDocumentItem         = DocumentItem.PurchasingDocumentItem
                                                                 and CPEPrice.CompanyCode                    = Document.CompanyCode
                                                                 and CPEPrice.Counterparty                   = Document.Supplier
{

  key DocTypes.PrepaymentAgrmtWorkCenterType                      as PrepaymentAgrmtWorkCenterType,
  key DocTypes.PrepaymentAgrmtRefDocumentCat                      as PrepaymentAgrmtRefDocumentCat,
  key 'BUS2012'                                                   as PrepaymentAgrmtRefBusObject,
  key Document.PurchasingDocument                                 as DocNumber,
  key cast( DocumentItem.PurchasingDocumentItem as abap.char(6) ) as DocumentItemNumber,

      DocumentItem.PurchasingDocumentItem                         as PurchasingDocumentITem,
      lpad( Document.PurchasingDocument, 25, '0' )                as PrepaymentAgrmtRefDocument,
      Document.CompanyCode                                        as CompanyCode,
      Document.PurchasingDocumentType                             as DocumentType,
      Document.Supplier                                           as Counterparty,
      Document.ValidityStartDate                                  as PrepaymentRefDocItmValdFromDte,
      Document.ValidityEndDate                                    as PrepaymentRefDocItmValdToDte,
      DocumentItem.Material                                       as Material,
      Material.Commodity,
      @Semantics.quantity.unitOfMeasure: 'OrderQuantityUnit'
      DocumentItem.OrderQuantity                                  as OrderQuantity,
      DocumentItem.OrderQuantityUnit                              as OrderQuantityUnit,

      @Semantics.amount.currencyCode: 'PrepaymentTotalAmtCrcy'
      cast(cast(
      case when WCPrcConfig.PrepaymentWrkCtrDocPricingOptn = '01'          -- CMM Pricing
                and Material.Commodity is not initial
           then curr_to_decfloat_amount(CMMPrice.PrepaymentTotalAmt)

           when WCPrcConfig.PrepaymentWrkCtrDocPricingOptn = '02'          -- CPE Pricing
                and Material.Commodity is not initial
           then curr_to_decfloat_amount(CPEPrice.PrepaymentTotalAmt)

           when WCPrcConfig.PrepaymentWrkCtrDocPricingOptn = '03'          -- Item Net Amount
                or WCPrcConfig.PrepaymentWrkCtrDocPricingOptn is null
                or Material.Commodity is initial
           then curr_to_decfloat_amount(DocumentItem.NetAmount)

           else 0 end  as abap.dec(23,2) )as abap.curr(23,2) )                       as PrepaymentTotalAmt,


      Document.DocumentCurrency                                   as PrepaymentTotalAmtCrcy,

      case when WCPrcConfig.PrepaymentWrkCtrDocPricingOptn = '01'          -- CMM Pricing
                and CMMPrice.PrepaymentDocCmmdtyMarketQty is initial
                and Material.Commodity is not initial
           then 'X'

           when WCPrcConfig.PrepaymentWrkCtrDocPricingOptn = '02'          -- CPE Pricing
                and Material.Commodity is not initial
           then CPEPrice.PrepaymentTotalAmtIsFixedPrice

           when WCPrcConfig.PrepaymentWrkCtrDocPricingOptn = '03'          -- Item Net Amount
                or WCPrcConfig.PrepaymentWrkCtrDocPricingOptn is null
                or Material.Commodity is initial
           then 'X'

           else '' end                                            as PrepaymentTotalAmtIsFixedPrice

}
where DocTypes.PrepaymentAgrmtRefDocumentCat = 'PO' and DocTypes.PrepaymentAgrmtWorkCenterType  = '1'
  and Document.PurchasingDocumentDeletionCode     <> 'X'
  and DocumentItem.PurchasingDocumentDeletionCode <> 'X'
  and DocumentItem.IsCompletelyDelivered          <> 'X'
  and DocumentItem.IsFinallyInvoiced              <> 'X'