P_POItemHistoryCalc

DDL: P_POITEMHISTORYCALC SQL: PPOITMHISTCALC Type: view CONSUMPTION

P_POItemHistoryCalc is a Consumption CDS View in SAP S/4HANA. It reads from 1 data source (I_PurchasingDocumentHistory) and exposes 2 fields with key fields PurchaseOrder, PurchaseOrderItem.

Data Sources (1)

SourceAliasJoin Type
I_PurchasingDocumentHistory I_PurchasingDocumentHistory from

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PPOITMHISTCALC view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
ClientHandling.algorithm #SESSION_VARIABLE view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #CONSUMPTION view
VDM.private true view

Fields (2)

KeyFieldSource TableSource FieldDescription
KEY PurchaseOrder PurchasingDocument
KEY PurchaseOrderItem PurchasingDocumentItem
@AbapCatalog.sqlViewName: 'PPOITMHISTCALC'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true

@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType : #CONSUMPTION
@VDM.private: true

define view P_POItemHistoryCalc
  as select from I_PurchasingDocumentHistory
{
  key PurchasingDocument     as PurchaseOrder,
  key PurchasingDocumentItem as PurchaseOrderItem,

      sum( case when PurchasingHistoryDocumentType = '2' and Quantity is not null
            then
       case when DebitCreditCode = 'S' then Quantity
        else -abs(Quantity)
        end
        else 0
        end )                as InvoiceReceiptQty,

      sum( case when PurchasingHistoryDocumentType = '2' and PurOrdAmountInCompanyCodeCrcy is not null
      then
      case when DebitCreditCode = 'S' then PurOrdAmountInCompanyCodeCrcy
      else -abs(PurOrdAmountInCompanyCodeCrcy)
      end
      else 0
      end )                  as InvoiceRcptAmtInCoCodeCrcy,

      sum(case when PurchasingHistoryDocumentType = '1' and PurchaseOrderAmount is not null
      then
       case when DebitCreditCode = 'S' then PurchaseOrderAmount
       else -abs(PurchaseOrderAmount)
       end
       else 0
       end )                 as GoodsReceiptAmount

}
where
     PurchasingHistoryDocumentType = '1'
  or PurchasingHistoryDocumentType = '2' // PurchasingHistoryDocumentType = '1' -> Goods Receipt Indicator

                                         //   PurchasingHistoryDocumentType = '2' -> Invoice Receipt Indicator

group by
  PurchasingDocument,
  PurchasingDocumentItem
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_PURCHASINGDOCUMENTHISTORY"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/