C_PE_StRpSalesLedgerCube

DDL: C_PE_STRPSALESLEDGERCUBE SQL: CPESLSLC Type: view CONSUMPTION

Sales Ledger Peru - Cube

C_PE_StRpSalesLedgerCube is a Consumption CDS View (Cube) that provides data about "Sales Ledger Peru - Cube" in SAP S/4HANA. It reads from 2 data sources (P_PE_SalesTaxAggrgd, I_StRpJournalEntryLog) and exposes 37 fields with key fields CompanyCode, FiscalYear, AccountingDocument, StatryRptCategory, StatryRptgEntity.

Data Sources (2)

SourceAliasJoin Type
P_PE_SalesTaxAggrgd SalesTaxEntry from
I_StRpJournalEntryLog StRpJournalEntryLog inner

Annotations (13)

NameValueLevelField
AbapCatalog.sqlViewName CPESLSLC view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #MANDATORY view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.dataClass #MIXED view
VDM.viewType #CONSUMPTION view
Analytics.dataCategory #CUBE view
Analytics.internalName #LOCAL view
ClientHandling.algorithm #SESSION_VARIABLE view
AccessControl.personalData.blocking #BLOCKED_DATA_INCLUDED view
EndUserText.label Sales Ledger Peru - Cube view
Metadata.allowExtensions true view

Fields (37)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode P_PE_SalesTaxAggrgd CompanyCode
KEY FiscalYear P_PE_SalesTaxAggrgd FiscalYear
KEY AccountingDocument P_PE_SalesTaxAggrgd AccountingDocument
KEY StatryRptCategory I_StRpJournalEntryLog StatryRptCategory
KEY StatryRptgEntity I_StRpJournalEntryLog StatryRptgEntity
KEY StatryRptRunID I_StRpJournalEntryLog StatryRptRunID
Ledger P_PE_SalesTaxAggrgd Ledger
LogicalSystem P_PE_SalesTaxAggrgd LogicalSystem
OriginalReferenceDocument P_PE_SalesTaxAggrgd OriginalReferenceDocument
PE_CompanyCodeTaxNumber P_PE_SalesTaxAggrgd PE_CompanyCodeTaxNumber
CompanyCodeName P_PE_SalesTaxAggrgd CompanyCodeName
CalendarYearMonth P_PE_SalesTaxAggrgd CalendarYearMonth
DocumentDate P_PE_SalesTaxAggrgd DocumentDate
DocumentNetDueDate P_PE_SalesTaxAggrgd DocumentNetDueDate
PE_OfficialDocumentType P_PE_SalesTaxAggrgd PE_OfficialDocumentType
PE_DocumentSerialNumber P_PE_SalesTaxAggrgd PE_DocumentSerialNumber
PE_OfficialDocumentNumber P_PE_SalesTaxAggrgd PE_OfficialDocumentNumber
TaxNumberType P_PE_SalesTaxAggrgd TaxNumberType
TaxNumber1 P_PE_SalesTaxAggrgd TaxNumber1
CustomerName P_PE_SalesTaxAggrgd CustomerName
CountryCurrency P_PE_SalesTaxAggrgd CountryCurrency
TransactionCurrency P_PE_SalesTaxAggrgd TransactionCurrency
SalesDocument CFinBillingDocument SalesDocument
FiscalPeriod P_PE_SalesTaxAggrgd FiscalPeriod
ReportingDate P_PE_SalesTaxAggrgd ReportingDate
PE_ExportAmountInCtryCrcy P_PE_SalesTaxAggrgd PE_ExportAmountInCtryCrcy
PE_TaxableBaseAmountInCtryCrcy P_PE_SalesTaxAggrgd PE_TaxableBaseAmountInCtryCrcy
PE_DiscountBaseAmtInCtryCrcy P_PE_SalesTaxAggrgd PE_DiscountBaseAmtInCtryCrcy
PE_VATAmountInCtryCrcy P_PE_SalesTaxAggrgd PE_VATAmountInCtryCrcy
PE_VATDiscountAmountInCtryCrcy P_PE_SalesTaxAggrgd PE_VATDiscountAmountInCtryCrcy
PE_ExemptTaxAmountInCtryCrcy P_PE_SalesTaxAggrgd PE_ExemptTaxAmountInCtryCrcy
PE_SelectiveAcqnAmtInCtryCrcy P_PE_SalesTaxAggrgd PE_SelectiveAcqnAmtInCtryCrcy
PE_TxBaseOnRiceAmtInCtryCrcy P_PE_SalesTaxAggrgd PE_TxBaseOnRiceAmtInCtryCrcy
PE_TaxOnRiceAmountInCtryCrcy P_PE_SalesTaxAggrgd PE_TaxOnRiceAmountInCtryCrcy
PE_TxOnPlasticBagAmtInCtryCrcy P_PE_SalesTaxAggrgd PE_TxOnPlasticBagAmtInCtryCrcy
PE_OthTxAndChrgsAmtInCtryCrcy P_PE_SalesTaxAggrgd PE_OthTxAndChrgsAmtInCtryCrcy
PE_NonTxblBaseAmtInCtryCrcy P_PE_SalesTaxAggrgd PE_NonTxblBaseAmtInCtryCrcy
@AbapCatalog.sqlViewName: 'CPESLSLC'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #MANDATORY
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@VDM.viewType: #CONSUMPTION
@Analytics: { dataCategory: #CUBE }
@Analytics.internalName: #LOCAL
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@EndUserText.label: 'Sales Ledger Peru - Cube'
@Metadata.allowExtensions:true

define view C_PE_StRpSalesLedgerCube
  as select from           P_PE_SalesTaxAggrgd       as SalesTaxEntry

    inner join             I_StRpJournalEntryLog     as StRpJournalEntryLog on  StRpJournalEntryLog.CompanyCode        = SalesTaxEntry.CompanyCode
                                                                            and StRpJournalEntryLog.AccountingDocument = SalesTaxEntry.AccountingDocument
                                                                            and StRpJournalEntryLog.FiscalYear         = SalesTaxEntry.FiscalYear

    left outer to one join I_ExchangeRate            as ExchangeRate        on  ExchangeRate.SourceCurrency            =  SalesTaxEntry.TransactionCurrency
                                                                            and ExchangeRate.TargetCurrency            =  SalesTaxEntry.CountryCurrency
                                                                            and SalesTaxEntry.TransactionCurrency      <> SalesTaxEntry.CountryCurrency
                                                                            and ExchangeRate.ExchangeRateType          =  SalesTaxEntry.ExchangeRateType
                                                                            and ExchangeRate.ExchangeRateEffectiveDate =  SalesTaxEntry.ExchangeRateEffectiveDate

    left outer to one join P_PE_CFinBillingDocAggrgd as CFinBillingDocument on  CFinBillingDocument.CentralFinanceBillingDocument = SalesTaxEntry.OriginalReferenceDocument
                                                                            and CFinBillingDocument.CompanyCode                   = SalesTaxEntry.CompanyCode

    association[0..1] to   I_JournalEntry            as _JournalEntry       on  _JournalEntry.CompanyCode               = SalesTaxEntry.CompanyCode
                                                                            and _JournalEntry.ReferenceDocumentType     = 'VBRK'
                                                                            and SalesTaxEntry.PE_OriginalDocumentType   = ''
                                                                            and SalesTaxEntry.PE_OriginalDocumentSeries = ''
                                                                            and SalesTaxEntry.PE_OriginalDocumentNumber = ''
                                                                            and CFinBillingDocument.SalesDocument       is not null
                                                                            and CFinBillingDocument.SalesDocument       <> ''
                                                                            and CFinBillingDocument.SalesDocument       = _JournalEntry.OriginalReferenceDocument

{
  key SalesTaxEntry.CompanyCode,
  key SalesTaxEntry.FiscalYear,
  key SalesTaxEntry.AccountingDocument,
  key StRpJournalEntryLog.StatryRptCategory,
  key StRpJournalEntryLog.StatryRptgEntity,
  key StRpJournalEntryLog.StatryRptRunID,

      SalesTaxEntry.Ledger,
      SalesTaxEntry.LogicalSystem,
      SalesTaxEntry.OriginalReferenceDocument,
      SalesTaxEntry.PE_CompanyCodeTaxNumber,
      SalesTaxEntry.CompanyCodeName,
      SalesTaxEntry.CalendarYearMonth,
      SalesTaxEntry.DocumentDate,
      SalesTaxEntry.DocumentNetDueDate,
      SalesTaxEntry.PE_OfficialDocumentType,
      SalesTaxEntry.PE_DocumentSerialNumber,
      SalesTaxEntry.PE_OfficialDocumentNumber,
      SalesTaxEntry.TaxNumberType,
      SalesTaxEntry.TaxNumber1,
      SalesTaxEntry.CustomerName,
      SalesTaxEntry.CountryCurrency,
      SalesTaxEntry.TransactionCurrency,

      cast ( case
               when ( SalesTaxEntry.PE_OriginalDocumentType  = '' or SalesTaxEntry.PE_OriginalDocumentType is initial )
                 then _JournalEntry.DocumentDate
             end as fipe_original_document_date ) as PE_OriginalDocumentDate,

      cast( case
              when ( SalesTaxEntry.PE_OriginalDocumentType  = '' or SalesTaxEntry.PE_OriginalDocumentType is initial )
                then substring(_JournalEntry.DocumentReferenceID,1,2)
              else ''
            end
      as fipe_original_document_type ) as PE_OriginalDocumentType,

      cast( case
              when ( SalesTaxEntry.PE_OriginalDocumentType  = '' or SalesTaxEntry.PE_OriginalDocumentType is initial )
                then case instr(substring(_JournalEntry.DocumentReferenceID,4,13), '-')
                       when 2
                         then substring(_JournalEntry.DocumentReferenceID,4,1)
                       when 3
                         then substring(_JournalEntry.DocumentReferenceID,4,2)
                       when 4
                         then substring(_JournalEntry.DocumentReferenceID,4,3)
                       when 5
                         then substring(_JournalEntry.DocumentReferenceID,4,4)
                       else ''
                     end
              else ''
            end
      as fipe_original_document_series ) as PE_OriginalDocumentSeries,

      cast( case
              when ( SalesTaxEntry.PE_OriginalDocumentType  = '' or SalesTaxEntry.PE_OriginalDocumentType is initial )
                then
                  case instr(substring(_JournalEntry.DocumentReferenceID,4,13), '-')
                    when 2
                      then substring(_JournalEntry.DocumentReferenceID,6,11)
                    when 3
                      then substring(_JournalEntry.DocumentReferenceID,7,10)
                    when 4
                      then substring(_JournalEntry.DocumentReferenceID,8,9)
                    when 5
                      then substring(_JournalEntry.DocumentReferenceID,9,8)
                    else ''
                end
            end
      as fipe_original_document_number ) as PE_OriginalDocumentNumber,

      CFinBillingDocument.SalesDocument,

      cast( case SalesTaxEntry.TransactionCurrency
              when 'PEN'
                then 1
              else ExchangeRate.ExchangeRate
            end
      as fipe_exchange_rate )                                                                  as ExchangeRate,

      SalesTaxEntry.FiscalPeriod,
      SalesTaxEntry.ReportingDate,

      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_ExportAmountInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_TaxableBaseAmountInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_DiscountBaseAmtInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_VATAmountInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_VATDiscountAmountInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_ExemptTaxAmountInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_SelectiveAcqnAmtInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_TxBaseOnRiceAmtInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_TaxOnRiceAmountInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_TxOnPlasticBagAmtInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_OthTxAndChrgsAmtInCtryCrcy,
      @Semantics.amount.currencyCode: 'CountryCurrency'
      SalesTaxEntry.PE_NonTxblBaseAmtInCtryCrcy,

      @Semantics.amount.currencyCode: 'CountryCurrency'
      cast( coalesce(SalesTaxEntry.PE_ExportAmountInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_TaxableBaseAmountInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_DiscountBaseAmtInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_VATAmountInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_VATDiscountAmountInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_ExemptTaxAmountInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_NonTxblBaseAmtInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_SelectiveAcqnAmtInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_TxBaseOnRiceAmtInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_TaxOnRiceAmountInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_TxOnPlasticBagAmtInCtryCrcy, 0)
          + coalesce(SalesTaxEntry.PE_OthTxAndChrgsAmtInCtryCrcy, 0)
      as fipe_total_tax_documents )                                                            as TotalAmountInLocalCurrency
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_EXCHANGERATE",
"I_JOURNALENTRY",
"I_STRPJOURNALENTRYLOG",
"P_PE_CFINBILLINGDOCAGGRGD",
"P_PE_SALESTAXAGGRGD"
],
"ASSOCIATED":
[
"I_JOURNALENTRY"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/