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.
@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 viewis 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 LeftouterJoin below
*/defineview P_CO_DIANJrnlEntrInvcFinDocLog
withparameters
P_FromPostingDate : fis_budat_from,
P_ToPostingDate : fis_budat_to
asselectdistinctfrom I_JournalEntryItem as JournalEntryItem
innerjoin 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
innerjoin 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
innerjoin 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
leftouter 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,
keycast( 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":""
}
}*/