P_UpdatedOpenItem

DDL: P_UPDATEDOPENITEM SQL: PAGRIUU Type: view CONSUMPTION

P_UpdatedOpenItem is a Consumption CDS View in SAP S/4HANA. It reads from 4 data sources (I_ChangeDocument, I_ChangeDocumentItem, I_AccountingDocument, P_ResItemSession) and exposes 35 fields with key fields CompanyCode, FiscalYear, AccountingDocument, AccountingDocumentItem.

Data Sources (4)

SourceAliasJoin Type
I_ChangeDocument ChangeDocument inner
I_ChangeDocumentItem ChangeDocumentItem inner
I_AccountingDocument Header inner
P_ResItemSession Session inner

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName PAGRIUU view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #MANDATORY view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.representativeKey AccountingDocumentItem view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #D view
VDM.viewType #CONSUMPTION view
VDM.private true view

Fields (35)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode Item CompanyCode
KEY FiscalYear Item FiscalYear
KEY AccountingDocument Item AccountingDocument
KEY AccountingDocumentItem Item AccountingDocumentItem
AssignmentReference Item AssignmentReference
AccountingDocumentHeaderText I_AccountingDocument AccountingDocumentHeaderText
DocumentItemText Item DocumentItemText
PaymentDifferenceReason Item PaymentDifferenceReason
CreationDate I_AccountingDocument AccountingDocumentCreationDate
CreationTime I_AccountingDocument CreationTime
LastChangeDate I_AccountingDocument LastChangeDate
ChangeDocCreationDate I_ChangeDocument CreationDate
ChangeDocumentCreationTime I_ChangeDocument CreationTime
PostingDate Item PostingDate
DocumentDate Item DocumentDate
NetDueDate Item NetDueDate
DebitCreditCode Item DebitCreditCode
CashDiscountBaseAmount Item CashDiscountBaseAmount
CashDiscountAmount Item CashDiscountAmount
PaymentTerms Item PaymentTerms
CashDiscount1Days Item CashDiscount1Days
CashDiscount2Days Item CashDiscount2Days
NetPaymentDays Item NetPaymentDays
CashDiscount1Percent Item CashDiscount1Percent
CashDiscount2Percent Item CashDiscount2Percent
DueCalculationBaseDate Item DueCalculationBaseDate
FixedCashDiscount Item FixedCashDiscount
PaymentBlockingReason Item PaymentBlockingReason
TransactionCurrency Item TransactionCurrency
CompanyCodeCurrency Item CompanyCodeCurrency
AmountInCompanyCodeCurrency Item AmountInCompanyCodeCurrency
AmountInTransactionCurrency Item AmountInTransactionCurrency
Customer Item Customer
BillingDocument Item BillingDocument
AccountingDocumentType Item AccountingDocumentType
@AbapCatalog.sqlViewName: 'PAGRIUU'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #MANDATORY
//@EndUserText.label: 'Updated Open Item'

@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.representativeKey: 'AccountingDocumentItem'
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.dataClass:  #MIXED
@ObjectModel.usageType.serviceQuality: #D
@VDM.viewType: #CONSUMPTION
//@UI.presentationVariant.sortOrder.by: 'LastChangeDate, ChangeDocumentCreationDate, ChangeDocumentCreationTime'

//@UI.presentationVariant.sortOrder.direction: #ASC

@VDM.private: true
define view P_UpdatedOpenItem as
select distinct from I_OperationalAcctgDocItem as Item

    inner join I_AccountingDocument      as Header on

        // Make sure that Item is A/R item


        Item.FinancialAccountType      = 'D' and

      // Make sure that Item is only searched in relevant categories


        (
            Item.AccountingDocumentCategory = '' or

            Item.AccountingDocumentCategory = 'S' or

            Item.AccountingDocumentCategory = 'A'
        )  and
        Item.CompanyCode               = Header.CompanyCode  and
        Item.FiscalYear                = Header.FiscalYear and
        Item.AccountingDocument        = Header.AccountingDocument
        inner join P_ResItemSession as Session on client = $session.client
        inner join I_ChangeDocument          as ChangeDocument on
        (
            ChangeDocument.ChangeDocObjectClass = 'BELEG' or
            ChangeDocument.ChangeDocObjectClass = 'BELEGR'
        ) and
        ChangeDocument.ChangeDocObject           = concat(
            Session.client, concat(
                Header.CompanyCode, concat(
                    Header.AccountingDocument, Header.FiscalYear
                )
            )
        )
        inner join I_ChangeDocumentItem as ChangeDocumentItem on
            ChangeDocumentItem.ChangeDocObjectClass = ChangeDocument.ChangeDocObjectClass
        and ChangeDocumentItem.ChangeDocObject      = ChangeDocument.ChangeDocObject
        and ChangeDocumentItem.ChangeDocument       = ChangeDocument.ChangeDocument
        and ChangeDocumentItem.DatabaseTable = 'BSEG'
//        and ChangeDocumentItem.ChangeDocDatabaseTableField = 'RSTGR'

{

  key Item.CompanyCode,

  key Item.FiscalYear,

  key Item.AccountingDocument,

  key Item.AccountingDocumentItem,

      Item.AssignmentReference,

      Header.AccountingDocumentHeaderText,   //as HeaderText,


      Item.DocumentItemText,                 //as ItemtText,


      Item.PaymentDifferenceReason,

      Header.AccountingDocumentCreationDate as CreationDate,

      Header.CreationTime                   as CreationTime,

      Header.LastChangeDate                 as LastChangeDate,

      ChangeDocument.CreationDate           as ChangeDocCreationDate,//ChangeDocumentCreationDate


      ChangeDocument.CreationTime           as ChangeDocumentCreationTime,

      Item.PostingDate,
      Item.DocumentDate,
      Item.NetDueDate,
      Item.DebitCreditCode,
      @Semantics.amount.currencyCode: 'TransactionCurrency'
      Item.CashDiscountBaseAmount,
      @Semantics.amount.currencyCode: 'TransactionCurrency'
      Item.CashDiscountAmount,
      Item.PaymentTerms,
      Item.CashDiscount1Days,
      Item.CashDiscount2Days,
      Item.NetPaymentDays,
      Item.CashDiscount1Percent,
      Item.CashDiscount2Percent,
      Item.DueCalculationBaseDate,
      Item.FixedCashDiscount,
      Item.PaymentBlockingReason,
      Item.TransactionCurrency,
      Item.CompanyCodeCurrency,
      Item.AmountInCompanyCodeCurrency,
      Item.AmountInTransactionCurrency,
      Item.Customer,
      Item.BillingDocument,
      Item.AccountingDocumentType
}

where
  ( LastChangeDate is not null and LastChangeDate <> '00000000' )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ACCOUNTINGDOCUMENT",
"I_CHANGEDOCUMENT",
"I_CHANGEDOCUMENTITEM",
"I_OPERATIONALACCTGDOCITEM",
"P_RESITEMSESSION"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/