P_PE_SalesEntrAggrgd
P_PE_SalesEntrAggrgd is a Consumption CDS View in SAP S/4HANA. It reads from 4 data sources (I_AddlCompanyCodeInformation, I_Country, I_JournalEntry, I_JournalEntryItem) and exposes 21 fields with key fields CompanyCode, FiscalYear, AccountingDocument, Ledger. It has 1 association to related views.
Data Sources (4)
| Source | Alias | Join Type |
|---|---|---|
| I_AddlCompanyCodeInformation | CompanyCodeInfo | inner |
| I_Country | Country | inner |
| I_JournalEntry | JournalEntry | from |
| I_JournalEntryItem | JournalEntryItem | inner |
Associations (1)
| Cardinality | Target | Alias | Condition |
|---|---|---|---|
| [0..1] | I_CompanyCode | _CompanyCode | $projection.CompanyCode = _CompanyCode.CompanyCode |
Annotations (9)
| Name | Value | Level | Field |
|---|---|---|---|
| AbapCatalog.sqlViewName | PPESALAGGRGD | view | |
| AbapCatalog.compiler.compareFilter | true | view | |
| VDM.private | true | view | |
| VDM.viewType | #CONSUMPTION | view | |
| AccessControl.authorizationCheck | #NOT_REQUIRED | view | |
| ClientHandling.algorithm | #SESSION_VARIABLE | view | |
| ObjectModel.usageType.sizeCategory | #XL | view | |
| ObjectModel.usageType.serviceQuality | #D | view | |
| ObjectModel.usageType.dataClass | #MIXED | view |
Fields (21)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | CompanyCode | I_JournalEntry | CompanyCode | |
| KEY | FiscalYear | I_JournalEntry | FiscalYear | |
| KEY | AccountingDocument | I_JournalEntry | AccountingDocument | |
| KEY | Ledger | I_JournalEntryItem | Ledger | |
| CompanyCodeCurrency | I_JournalEntry | CompanyCodeCurrency | ||
| DocumentReferenceID | I_JournalEntry | DocumentReferenceID | ||
| FiscalPeriod | I_JournalEntry | FiscalPeriod | ||
| LogicalSystem | I_JournalEntry | LogicalSystem | ||
| IsReversed | I_JournalEntry | IsReversed | ||
| TaxCalculationProcedure | I_Country | TaxCalculationProcedure | ||
| InvoiceReference | ||||
| PE_CompanyCodeTaxNumber | ||||
| CompanyCodeName | _CompanyCode | CompanyCodeName | ||
| CalendarYearMonth | ||||
| DocumentDate | I_JournalEntry | DocumentDate | ||
| OriginalReferenceDocument | I_JournalEntry | OriginalReferenceDocument | ||
| DocumentNetDueDate | ||||
| TaxNumberTypeendasTaxNumberType | ||||
| TaxNumber1endasTaxNumber1 | ||||
| OrganizationBPName1endasCustomerName | ||||
| ExchangeRateType | I_JournalEntry | ExchangeRateType |
@AbapCatalog.sqlViewName: 'PPESALAGGRGD'
@AbapCatalog.compiler.compareFilter: true
@VDM.private:true
@VDM.viewType: #CONSUMPTION
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
define view P_PE_SalesEntrAggrgd
as select from I_JournalEntry as JournalEntry
inner join I_Country as Country on Country.Country = 'PE'
inner join I_JournalEntryItem as JournalEntryItem on JournalEntryItem.CompanyCode = JournalEntry.CompanyCode
and JournalEntryItem.AccountingDocument = JournalEntry.AccountingDocument
and JournalEntryItem.FiscalYear = JournalEntry.FiscalYear
inner join I_AddlCompanyCodeInformation as CompanyCodeInfo on CompanyCodeInfo.CompanyCode = JournalEntry.CompanyCode
and CompanyCodeInfo.CompanyCodeParameterType = 'TAXNR'
left outer to one join I_OneTimeAccountBP as OneTimeAccountBP on OneTimeAccountBP.CompanyCode = JournalEntry.CompanyCode
and OneTimeAccountBP.AccountingDocument = JournalEntry.AccountingDocument
and OneTimeAccountBP.FiscalYear = JournalEntry.FiscalYear
left outer to one join I_Customer as Customer on Customer.Customer = JournalEntryItem.Customer
left outer to one join P_PE_SalesOriginalJrnlEntry as OriginalDocument on OriginalDocument.CompanyCode = JournalEntry.CompanyCode
and OriginalDocument.FiscalYear = JournalEntry.FiscalYear
and (
OriginalDocument.ClearingAccountingDocument = JournalEntry.AccountingDocument
or(
OriginalDocument.InvoiceReference <> ''
and OriginalDocument.AccountingDocument = JournalEntry.AccountingDocument
)
)
left outer to one join I_ExchangeRate as ExchangeRate on ExchangeRate.SourceCurrency = JournalEntry.TransactionCurrency
and ExchangeRate.TargetCurrency = Country.CountryCurrency
and JournalEntry.TransactionCurrency <> Country.CountryCurrency
and ExchangeRate.ExchangeRateType = JournalEntry.ExchangeRateType
and (
(
OriginalDocument.DocumentDate is null
and ExchangeRate.ExchangeRateEffectiveDate <= JournalEntry.DocumentDate
)
or(
ExchangeRate.ExchangeRateEffectiveDate <= OriginalDocument.DocumentDate
)
)
left outer to one join I_DomainFixedValueText as ReversedDocumentsText on ReversedDocumentsText.SAPDataDictionaryDomain = 'FIPE_REVERSED_DOCUMENTS_TEXT'
and ReversedDocumentsText.DomainValue = '1'
and ReversedDocumentsText.Language = $session.system_language
and ReversedDocumentsText.DomainActivationState = 'A'
and ReversedDocumentsText.DomainValuePosition = '0001'
and ReversedDocumentsText.DomainVersion = '0000'
association [0..1] to I_CompanyCode as _CompanyCode on $projection.CompanyCode = _CompanyCode.CompanyCode
{
key JournalEntry.CompanyCode,
key JournalEntry.FiscalYear,
key JournalEntry.AccountingDocument,
key JournalEntryItem.Ledger,
JournalEntry.CompanyCodeCurrency,
JournalEntry.DocumentReferenceID,
JournalEntry.FiscalPeriod,
JournalEntry.LogicalSystem,
JournalEntry.IsReversed,
Country.TaxCalculationProcedure,
max(JournalEntryItem.InvoiceReference) as InvoiceReference,
cast( CompanyCodeInfo.CompanyCodeParameterValue as fipe_company_code_tax_number ) as PE_CompanyCodeTaxNumber,
_CompanyCode.CompanyCodeName,
cast( concat( JournalEntry.FiscalYear, substring(JournalEntry.FiscalPeriod,2,2) ) as vdm_yearmonth ) as CalendarYearMonth,
JournalEntry.DocumentDate,
JournalEntry.OriginalReferenceDocument,
cast( JournalEntryItem.NetDueDate as fipe_due_payment_date ) as DocumentNetDueDate,
cast( case
when JournalEntry.DocumentReferenceID is not initial
then case instr(substring(JournalEntry.DocumentReferenceID,1,3), '-')
when 3
then substring(JournalEntry.DocumentReferenceID,1,2)
else ''
end
end
as fipe_document_type ) as PE_OfficialDocumentType,
cast( case
when JournalEntry.DocumentReferenceID is not initial
then case instr(substring(JournalEntry.DocumentReferenceID,1,3), '-')
when 3
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 substring(JournalEntry.DocumentReferenceID,1,4)
end
else ''
end
as fipe_serial_number ) as PE_DocumentSerialNumber,
cast( case substring(JournalEntry.DocumentReferenceID,1,2)
when '50'
then case
when JournalEntry.DocumentReferenceID is not initial
then case instr(substring(JournalEntry.DocumentReferenceID,4,13), '-')
when 2
then substring(JournalEntry.DocumentReferenceID,11,6)
when 3
then substring(JournalEntry.DocumentReferenceID,12,5)
when 4
then substring(JournalEntry.DocumentReferenceID,13,4)
when 5
then substring(JournalEntry.DocumentReferenceID,14,3)
end
end
when '51'
then case
when JournalEntry.DocumentReferenceID is not initial
then case instr(substring(JournalEntry.DocumentReferenceID,4,13), '-')
when 2
then substring(JournalEntry.DocumentReferenceID,11,6)
when 3
then substring(JournalEntry.DocumentReferenceID,12,5)
when 4
then substring(JournalEntry.DocumentReferenceID,13,4)
when 5
then substring(JournalEntry.DocumentReferenceID,14,3)
end
end
else 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)
end
end
as fipe_official_doc_number ) as PE_OfficialDocumentNumber,
case
when JournalEntry.IsReversed = 'X'
then ''
when OneTimeAccountBP.AccountingDocument is not null
then OneTimeAccountBP.TaxNumberType
else Customer.TaxNumberType
end as TaxNumberType,
case
when JournalEntry.IsReversed = 'X'
then ''
when OneTimeAccountBP.AccountingDocument is not null
then OneTimeAccountBP.TaxID1
else Customer.TaxNumber1
end as TaxNumber1,
case
when JournalEntry.IsReversed = 'X'
then ReversedDocumentsText.DomainText
when OneTimeAccountBP.BusinessPartnerName1 is not null
then OneTimeAccountBP.BusinessPartnerName1
else Customer.OrganizationBPName1
end as CustomerName,
cast(
case
when JournalEntry.IsReversed = 'X'
then ''
else Country.CountryCurrency
end
as waers_005 ) as CountryCurrency,
cast(
case
when JournalEntry.IsReversed = 'X'
then ''
else JournalEntry.TransactionCurrency
end
as waers) as TransactionCurrency,
JournalEntry.ExchangeRateType,
case
when JournalEntry.TransactionCurrency <> 'PEN'
then max( ExchangeRate.ExchangeRateEffectiveDate )
else JournalEntry.DocumentDate
end as ExchangeRateEffectiveDate,
cast ( case
when OriginalDocument.DocumentDate is not initial
then OriginalDocument.DocumentDate
end
as fipe_original_document_date ) as PE_OriginalDocumentDate,
cast( case
when OriginalDocument.DocumentReferenceID is not initial
then substring(OriginalDocument.DocumentReferenceID,1,2)
else ''
end
as fipe_original_document_type ) as PE_OriginalDocumentType,
cast( case
when OriginalDocument.DocumentReferenceID is not initial
then case instr(substring(OriginalDocument.DocumentReferenceID,4,13), '-')
when 2
then substring(OriginalDocument.DocumentReferenceID,4,1)
when 3
then substring(OriginalDocument.DocumentReferenceID,4,2)
when 4
then substring(OriginalDocument.DocumentReferenceID,4,3)
when 5
then substring(OriginalDocument.DocumentReferenceID,4,4)
else ''
end
else ''
end
as fipe_original_document_series ) as PE_OriginalDocumentSeries,
cast( case instr(substring(OriginalDocument.DocumentReferenceID,4,13), '-')
when 2
then substring(OriginalDocument.DocumentReferenceID,6,11)
when 3
then substring(OriginalDocument.DocumentReferenceID,7,10)
when 4
then substring(OriginalDocument.DocumentReferenceID,8,9)
when 5
then substring(OriginalDocument.DocumentReferenceID,9,8)
else ''
end
as fipe_original_document_number ) as PE_OriginalDocumentNumber
}
where
JournalEntryItem.FinancialAccountType = 'D'
and JournalEntry.IsReversal = ''
group by
JournalEntry.CompanyCode,
JournalEntry.FiscalYear,
JournalEntry.AccountingDocument,
JournalEntryItem.Ledger,
JournalEntry.DocumentDate,
JournalEntry.FiscalPeriod,
JournalEntry.LogicalSystem,
JournalEntry.OriginalReferenceDocument,
Country.TaxCalculationProcedure,
Country.CountryCurrency,
JournalEntryItem.NetDueDate,
CompanyCodeInfo.CompanyCodeParameterType,
CompanyCodeInfo.CompanyCodeParameterValue,
_CompanyCode.CompanyCodeName,
JournalEntry.DocumentReferenceID,
OneTimeAccountBP.AccountingDocument,
OneTimeAccountBP.TaxNumberType,
OneTimeAccountBP.TaxID1,
OneTimeAccountBP.BusinessPartnerName1,
Customer.TaxNumberType,
Customer.TaxNumber1,
Customer.OrganizationBPName1,
JournalEntry.TransactionCurrency,
OriginalDocument.DocumentDate,
OriginalDocument.DocumentReferenceID,
JournalEntry.CompanyCodeCurrency,
JournalEntry.ExchangeRateType,
JournalEntry.IsReversed,
ReversedDocumentsText.DomainText
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ADDLCOMPANYCODEINFORMATION",
"I_COMPANYCODE",
"I_COUNTRY",
"I_CUSTOMER",
"I_DOMAINFIXEDVALUETEXT",
"I_EXCHANGERATE",
"I_JOURNALENTRY",
"I_JOURNALENTRYITEM",
"I_ONETIMEACCOUNTBP",
"P_PE_SALESORIGINALJRNLENTRY"
],
"ASSOCIATED":
[
"I_COMPANYCODE"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/
Learn More
- What Is a CDS View in SAP S/4HANA?
- Types of CDS Views: Basic, Composite, Consumption, and Transactional
- SAP Tables vs CDS Views — Key Differences
- Understanding Data Lineage in SAP S/4HANA
- VDM (Virtual Data Model) in SAP S/4HANA Explained
- CDS View Annotations — A Complete Guide
- CDS View Field Mapping and Associations
- Understanding the SAP S/4HANA Data Model
- CDS View Extensions and Custom Fields in SAP S/4HANA
- Released APIs and Stability Contracts in SAP S/4HANA