P_CO_DIANJrnlEntrInvcFinDocLog

DDL: P_CO_DIANJRNLENTRINVCFINDOCLOG SQL: PSRCOJRNLINVCFDL Type: view CONSUMPTION

P_CO_DIANJrnlEntrInvcFinDocLog is a Consumption CDS View in SAP S/4HANA. It reads from 3 data sources (I_CO_DIANGeneralLedgerAccount, I_CO_DIANItemType, I_StRpJournalEntryLog) and exposes 14 fields with key fields Ledger, CompanyCode, FiscalYear, AccountingDocument, CO_DIANReportFormat.

Data Sources (3)

SourceAliasJoin Type
I_CO_DIANGeneralLedgerAccount DIAN_GLAccount inner
I_CO_DIANItemType DIANItemType inner
I_StRpJournalEntryLog ReportedItemsLog inner

Parameters (2)

NameTypeDefault
P_FromPostingDate fis_budat_from
P_ToPostingDate fis_budat_to

Annotations (13)

NameValueLevelField
AbapCatalog.sqlViewName PSRCOJRNLINVCFDL view
VDM.private true view
VDM.viewType #CONSUMPTION view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view
AbapCatalog.buffering.status #NOT_ALLOWED view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #P view
VDM.lifecycle.status #DEPRECATED view
VDM.lifecycle.successor P_CO_DIANStRpFrmt1001FinDocLg view

Fields (14)

KeyFieldSource TableSource FieldDescription
KEY Ledger JournalEntryItem Ledger
KEY CompanyCode JournalEntryItem CompanyCode
KEY FiscalYear
KEY AccountingDocument JournalEntryItem AccountingDocument
KEY CO_DIANReportFormat I_CO_DIANGeneralLedgerAccount CO_DIANReportFormat
KEY CO_DIANReportItemType I_CO_DIANGeneralLedgerAccount CO_DIANReportItemType
KEY IncgInvoiceAccountingDocument InvoiceFinDocument AccountingDocument
KEY StatryRptCategory I_StRpJournalEntryLog StatryRptCategory
KEY StatryRptgEntity I_StRpJournalEntryLog StatryRptgEntity
KEY StatryRptRunID I_StRpJournalEntryLog StatryRptRunID
_Ledger JournalEntryItem _Ledger
_CompanyCode JournalEntryItem _CompanyCode
_FiscalYear JournalEntryItem _FiscalYear
_JournalEntry JournalEntryItem _JournalEntry
@AbapCatalog.sqlViewName: 'PSRCOJRNLINVCFDL'
@VDM.private:true
@VDM.viewType: #CONSUMPTION
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.buffering.status: #NOT_ALLOWED
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass:  #MIXED
@ObjectModel.usageType.serviceQuality: #P
@VDM: {
  lifecycle.status: #DEPRECATED,
  lifecycle.successor: 'P_CO_DIANStRpFrmt1001FinDocLg'
}
/*
  This CDS view is responsible to list the JournalEntries from the following cases:
    1. Items with a G/L account that is included in DIAN G/L customizing
    2. Items related to a Purchasing Order scenario.
      - In this scenario, the proper G/L account will be available in the Material document (MIGO) -> we get this as stated in point 1.
      - As we also need to report the taxes, we must look for them at the Invoice document (MIRO) -> we get this by doing the Left outer Join below
*/
define view P_CO_DIANJrnlEntrInvcFinDocLog 

  with parameters
    P_FromPostingDate : fis_budat_from,
    P_ToPostingDate   : fis_budat_to
  as select distinct from I_JournalEntryItem as JournalEntryItem
  
    inner join I_StRpJournalEntryLog as ReportedItemsLog on ReportedItemsLog.CompanyCode        = JournalEntryItem.CompanyCode
                                                        and ReportedItemsLog.AccountingDocument = JournalEntryItem.AccountingDocument
                                                        and ReportedItemsLog.FiscalYear         = JournalEntryItem.FiscalYear

  -- Here we select only items that match DIAN GL customizing
    inner join I_CO_DIANGeneralLedgerAccount as DIAN_GLAccount on DIAN_GLAccount.CompanyCode          =  JournalEntryItem.CompanyCode
                                                              and DIAN_GLAccount.ValidityStartDate    <= $parameters.P_ToPostingDate
                                                              and DIAN_GLAccount.ValidityEndDate      >= $parameters.P_ToPostingDate
                                                              and DIAN_GLAccount.LowerBoundaryAccount <= JournalEntryItem.GLAccount
                                                              and DIAN_GLAccount.UpperBoundaryAccount >= JournalEntryItem.GLAccount
                          
  -- Only Item Types (conceptos) that are valid at reporting date
    inner join I_CO_DIANItemType as DIANItemType on DIANItemType.CO_DIANReportFormat   = DIAN_GLAccount.CO_DIANReportFormat
                                                and DIANItemType.CO_DIANReportItemType = DIAN_GLAccount.CO_DIANReportItemType
                                                and DIANItemType.ValidityStartDate     <= $parameters.P_ToPostingDate
                                                and DIANItemType.ValidityEndDate       >= $parameters.P_ToPostingDate
                                      
  -- Here we select the items that DON'T match the GL customizing, but have are related via the PurchasingDocument number and should be reported too
    left outer to many join P_CO_DIANInvoiceFinDocument( P_FromPostingDate: $parameters.P_FromPostingDate,
                                                         P_ToPostingDate:   $parameters.P_ToPostingDate )    as InvoiceFinDocument         
                                                                               on InvoiceFinDocument.SourceLedger           = JournalEntryItem.SourceLedger
                                                                              and InvoiceFinDocument.Ledger                 = JournalEntryItem.Ledger
                                                                              and InvoiceFinDocument.CompanyCode            = JournalEntryItem.CompanyCode
                                                                              and InvoiceFinDocument.FiscalYear             = JournalEntryItem.FiscalYear
                                                                              and InvoiceFinDocument.AccountingDocument    <> JournalEntryItem.AccountingDocument
                                                                              and InvoiceFinDocument.PurchasingDocument     = JournalEntryItem.PurchasingDocument
                                                                              and InvoiceFinDocument.PurchasingDocumentItem = JournalEntryItem.PurchasingDocumentItem
                                                                              and InvoiceFinDocument.StatryRptCategory      = ReportedItemsLog.StatryRptCategory
                                                                              and InvoiceFinDocument.StatryRptgEntity       = ReportedItemsLog.StatryRptgEntity
                                                                              and InvoiceFinDocument.StatryRptRunID         = ReportedItemsLog.StatryRptRunID

{
  key JournalEntryItem.Ledger,
  key JournalEntryItem.CompanyCode,
  key cast( JournalEntryItem.FiscalYear as fis_gjahr_no_conv preserving type ) as FiscalYear,
  key JournalEntryItem.AccountingDocument,
  key DIAN_GLAccount.CO_DIANReportFormat,
  key DIAN_GLAccount.CO_DIANReportItemType,
  key InvoiceFinDocument.AccountingDocument as IncgInvoiceAccountingDocument,
  key ReportedItemsLog.StatryRptCategory,
  key ReportedItemsLog.StatryRptgEntity,
  key ReportedItemsLog.StatryRptRunID,      
      JournalEntryItem._Ledger,
      JournalEntryItem._CompanyCode,
      JournalEntryItem._FiscalYear,
      JournalEntryItem._JournalEntry
}
where JournalEntryItem.PostingDate between $parameters.P_FromPostingDate and $parameters.P_ToPostingDate
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CO_DIANGENERALLEDGERACCOUNT",
"I_CO_DIANITEMTYPE",
"I_JOURNALENTRYITEM",
"I_STRPJOURNALENTRYLOG",
"P_CO_DIANINVOICEFINDOCUMENT"
],
"ASSOCIATED":
[
"I_COMPANYCODE",
"I_FISCALYEARFORCOMPANYCODE",
"I_JOURNALENTRY",
"I_LEDGER"
],
"BASE":
[
"I_JOURNALENTRYITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/