P_CostAccountingDocument_2

DDL: P_COSTACCOUNTINGDOCUMENT_2 Type: view_entity COMPOSITE Package: ODATA_COST_ACCOUNTING_POSTINGS

Cost Accounting Document

P_CostAccountingDocument_2 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 26 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 (7)

NameValueLevelField
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 (26)

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
PredecessorReferenceDocument I_GLAccountLineItemRawData PredecessorReferenceDocument
PredecessorReferenceDocType I_GLAccountLineItemRawData PredecessorReferenceDocType
PredecessorReferenceDocCntxt I_GLAccountLineItemRawData PredecessorReferenceDocCntxt
ReversalReferenceDocument I_GLAccountLineItemRawData ReversalReferenceDocument
ReversalReferenceDocumentType I_GLAccountLineItemRawData ReversalReferenceDocumentType
GlobalCurrency I_GLAccountLineItemRawData GlobalCurrency
AmountInGlobalCurrency I_GLAccountLineItemRawData AmountInGlobalCurrency
ControllingBusTransacType
BusinessTransactionCategory I_GLAccountLineItemRawData BusinessTransactionCategory
IsSettled I_GLAccountLineItemRawData IsSettled
@AbapCatalog.viewEnhancementCategory: [#NONE]
@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 entity P_CostAccountingDocument_2
  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,
      _Header.PredecessorReferenceDocument,
      _Header.PredecessorReferenceDocType,
      _Header.PredecessorReferenceDocCntxt,
      _Header.ReversalReferenceDocument,
      _Header.ReversalReferenceDocumentType,

      _Header.GlobalCurrency,
      @Semantics: { amount : {currencyCode: 'GlobalCurrency'} }
      _Header.AmountInGlobalCurrency,
      
      cast(_Header.ControllingBusTransacType as fins_co_bus_trans preserving type ) as ControllingBusTransacType,
      _Header.BusinessTransactionCategory,
      
      cast(
        case _Header.IsReversal
            when '' then ( case _Header.PredecessorReferenceDocument
                            when '' then '1'
                            else '3' end )
            else '2'
      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.OriginCtrlgDebitCreditCode = 'S' 
and ( ReferenceDocumentType = 'COBK' 
      or ( ReferenceDocumentType = 'CATS' 
           and IsReversal = '' 
           and ControllingBusTransacType = 'RKL'
           and ( _Header._JournalEntry.JournalEntryReprocessingStatus = '' or _Header._JournalEntry.JournalEntryReprocessingStatus = '3' ) ) 
      or ( ReferenceDocumentType = 'AFRU' and ControllingBusTransacType = 'RKL' ) )
and _Header._Ledger.IsLeadingLedger   = 'X'
and _Header.IsSettlement = ''
and _Header.JournalEntryIsSecondaryEntry = ''
and _Header.LogicalSystem = ''
and _Header.AccountAssignmentType <> ''
and _Header.ReferenceDocument <> ''