P_CostAccountingDocument

DDL: P_COSTACCOUNTINGDOCUMENT SQL: PCOSTACCTDOC Type: view COMPOSITE Package: ODATA_COST_ACCOUNTING_POSTINGS

Cost Accounting Document

P_CostAccountingDocument is a Composite CDS View that provides data about "Cost Accounting Document" in SAP S/4HANA. It reads from 1 data source (I_GLAccountLineItemRawData) and exposes 21 fields with key fields FiscalYear, ReferenceDocument, ControllingArea, LedgerGLLineItem, ReferenceDocumentType. Part of development package ODATA_COST_ACCOUNTING_POSTINGS.

Data Sources (1)

SourceAliasJoin Type
I_GLAccountLineItemRawData _Header from

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PCOSTACCTDOC view
AbapCatalog.compiler.compareFilter true view
ClientHandling.algorithm #SESSION_VARIABLE view
AccessControl.authorizationCheck #NOT_REQUIRED view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
VDM.viewType #COMPOSITE view
VDM.private true view

Fields (21)

KeyFieldSource TableSource FieldDescription
KEY FiscalYear I_GLAccountLineItemRawData FiscalYear
KEY ReferenceDocument I_GLAccountLineItemRawData ReferenceDocument
KEY ControllingArea I_GLAccountLineItemRawData ControllingArea
KEY LedgerGLLineItem I_GLAccountLineItemRawData LedgerGLLineItem
KEY ReferenceDocumentType I_GLAccountLineItemRawData ReferenceDocumentType
KEY ReferenceDocumentContext I_GLAccountLineItemRawData ReferenceDocumentContext
AccountingDocumentHeaderText
DocumentDate I_GLAccountLineItemRawData DocumentDate
PostingDate I_GLAccountLineItemRawData PostingDate
FiscalPeriod I_GLAccountLineItemRawData FiscalPeriod
FiscalYearPeriod I_GLAccountLineItemRawData FiscalYearPeriod
AccountingDocumentCreationDate
AccountingDocCreatedByUser
IsReversal I_GLAccountLineItemRawData IsReversal
IsReversed I_GLAccountLineItemRawData IsReversed
ExchangeRateDate
ReversalReferenceDocument I_GLAccountLineItemRawData ReversalReferenceDocument
GlobalCurrency I_GLAccountLineItemRawData GlobalCurrency
ControllingBusTransacType
BusinessTransactionCategory I_GLAccountLineItemRawData BusinessTransactionCategory
IsSettled I_GLAccountLineItemRawData IsSettled
@AbapCatalog.sqlViewName: 'PCOSTACCTDOC'
@AbapCatalog.compiler.compareFilter:true
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #NOT_REQUIRED
//@EndUserText.label: 'Cost Accounting Document'

@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
    serviceQuality: #C,
    sizeCategory: #XXL,
    dataClass: #MIXED
}
@VDM: {
  viewType: #COMPOSITE,
  private: true
}
/*+[hideWarning] { "IDS" : [ "KEY_CHECK" ]  } */
define view P_CostAccountingDocument
  as select from I_GLAccountLineItemRawData as _Header
  
{
  key _Header.FiscalYear,
  key _Header.ReferenceDocument,
  key _Header.ControllingArea,
  key _Header.LedgerGLLineItem,
  key _Header.ReferenceDocumentType,
  key _Header.ReferenceDocumentContext,
      
      _Header._JournalEntry.AccountingDocumentHeaderText,
      _Header.DocumentDate,
      _Header.PostingDate,
      _Header.FiscalPeriod,      
      _Header.FiscalYearPeriod,
      cast(_Header._JournalEntry.AccountingDocumentCreationDate as farp_cpudt preserving type) as AccountingDocumentCreationDate,
      cast(_Header.AccountingDocCreatedByUser as fco_cc_createdby preserving type)    as AccountingDocCreatedByUser,
      _Header.IsReversal,
      _Header.IsReversed,   
      cast(_Header._JournalEntry.ExchangeRateDate as fin_currconvdat preserving type) as ExchangeRateDate,    
      cast(
        case
          when _Header.IsReversal = 'X' or _Header.ControllingBusTransacType = 'COIN' then ''
          else _Header.PredecessorReferenceDocument
      end as fis_prec_awref preserving type ) as PredecessorReferenceDocument,          
      _Header.ReversalReferenceDocument,      
      
      _Header.GlobalCurrency,
      @Semantics: { amount : {currencyCode: 'GlobalCurrency'} }
      cast(
        case _Header.OriginCtrlgDebitCreditCode
          when 'S' then _Header.AmountInGlobalCurrency
          else 0
      end as fis_ksl preserving type ) as AmountInGlobalCurrency,
      
      cast(_Header.ControllingBusTransacType as fins_co_bus_trans preserving type ) as ControllingBusTransacType,
      _Header.BusinessTransactionCategory,
      
      cast(
        case _Header.ControllingBusTransacType
          when 'COIN' then '1'
          else ( case _Header.IsReversal
                   when '' then ( case _Header.PredecessorReferenceDocument
                                    when '' then '1'
                                    else '3' end )
                   else '2' end )
      end as fco_posting_type ) as AllocationPostingType,
      
      cast(
        case _Header.IsReversal
            when '' then ''
            else _Header.ReversalReferenceDocument 
        end as reversedreferencedocument preserving type )  as ReversedReferenceDocument,
      _Header.IsSettled
}

where 
(
  (    
    (
      ( _Header.ControllingBusTransacType   = 'RKU1' and _Header.BusinessTransactionCategory = 'RKU1' )
      or ( _Header.ControllingBusTransacType   = 'RKU2' and _Header.BusinessTransactionCategory = 'RKU2' )
      or ( _Header.ControllingBusTransacType   = 'RKU1' and _Header.BusinessTransactionCategory = 'RKU3' )
      or( _Header.ControllingBusTransacType   = 'RKU2' and _Header.BusinessTransactionCategory = 'RKU3' )
      or( _Header.ControllingBusTransacType   = 'RKU3' and _Header.BusinessTransactionCategory = 'RKU3' )      
    )
    and _Header.ReferenceDocumentType = 'COBK'
  ) 
  or
  (
    _Header.ControllingBusTransacType = 'COIN' 
    and
    _Header.IsReversal = '' and _Header.IsReversed = ''    
    and
    ( 
       _Header.BusinessTransactionCategory = 'ABGA'
    or _Header.BusinessTransactionCategory = 'ACEA'
    or _Header.BusinessTransactionCategory = 'RFBU'
    or _Header.BusinessTransactionCategory = 'RFIC'
    or _Header.BusinessTransactionCategory = 'RFIV'
    or _Header.BusinessTransactionCategory = 'RFPI'
    or _Header.BusinessTransactionCategory = 'RFPO'
    or _Header.BusinessTransactionCategory = 'RMRP'    
    ) 
  )  
)
and _Header._Ledger.IsLeadingLedger   = 'X'
and _Header.IsSettlement = ''
and _Header.JournalEntryIsSecondaryEntry = ''
and _Header.LogicalSystem = ''
and _Header.AccountAssignmentType <> ''
and _Header.ReferenceDocument <> ''
and _Header.ControllingObject <> ''