@AbapCatalog.sqlViewName: 'CPEPRLDFRC'
@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: 'Purchase Ledger Foreign Vendors - Cube'
@Metadata.allowExtensions:true
define view C_PE_StRpPurLdgrFrgnSuplrC
with parameters
P_PE_ClassfctnRevenueType : hryid,
P_PE_ClassfctnServiceType : hryid
as select from P_PE_PurFrgnSuplrEntryAggrgd as JournalEntry
inner join I_StRpJournalEntryLog as StRpJournalEntryLog on StRpJournalEntryLog.CompanyCode = JournalEntry.CompanyCode
and StRpJournalEntryLog.AccountingDocument = JournalEntry.AccountingDocument
and StRpJournalEntryLog.FiscalYear = JournalEntry.FiscalYear
inner join P_PE_JrnlEntryWthOfclDocClass as JrnlEntryWthOfclDocClass on JrnlEntryWthOfclDocClass.CompanyCode = JournalEntry.CompanyCode
and JrnlEntryWthOfclDocClass.AccountingDocument = JournalEntry.AccountingDocument
and JrnlEntryWthOfclDocClass.FiscalYear = JournalEntry.FiscalYear
left outer to one join I_ExchangeRate as ExchangeRate on ExchangeRate.SourceCurrency = JournalEntry.TransactionCurrency
and ExchangeRate.TargetCurrency = JournalEntry.CountryCurrency
and JournalEntry.TransactionCurrency <> JournalEntry.CountryCurrency
and ExchangeRate.ExchangeRateType = JournalEntry.ExchangeRateType
and ExchangeRate.ExchangeRateEffectiveDate = JournalEntry.ExchangeRateEffectiveDate
left outer to one join P_PE_JournalEntryFSStructure as FinancialStatement1 on FinancialStatement1.CompanyCode = JournalEntry.CompanyCode
and FinancialStatement1.FiscalYear = JournalEntry.FiscalYear
and FinancialStatement1.AccountingDocument = JournalEntry.AccountingDocument
and FinancialStatement1.Ledger = JournalEntry.Ledger
and FinancialStatement1.FinancialStatementHierarchy = $parameters.P_PE_ClassfctnRevenueType
left outer to one join P_PE_JournalEntryFSStructure as FinancialStatement2 on FinancialStatement2.CompanyCode = JournalEntry.CompanyCode
and FinancialStatement2.FiscalYear = JournalEntry.FiscalYear
and FinancialStatement2.AccountingDocument = JournalEntry.AccountingDocument
and FinancialStatement2.Ledger = JournalEntry.Ledger
and FinancialStatement2.FinancialStatementHierarchy = $parameters.P_PE_ClassfctnServiceType
{
key JournalEntry.CompanyCode,
key JournalEntry.FiscalYear,
key JournalEntry.AccountingDocument,
key StRpJournalEntryLog.StatryRptCategory,
key StRpJournalEntryLog.StatryRptgEntity,
key StRpJournalEntryLog.StatryRptRunID,
key JournalEntry.Ledger,
JournalEntry.ReportingDate,
JournalEntry.FiscalPeriod,
JournalEntry.CalendarYearMonth,
JournalEntry.FiscalPeriodDate,
cast( case
when JournalEntry.PE_OfficialDocumentType is not initial
then concat( JournalEntry.PE_OfficialDocumentType ,
concat( JournalEntry.PE_DocumentSerialNumber,
JournalEntry.PE_OfficialDocumentNumber ) )
else concat( JournalEntry.ODNDocumentClass,
concat( JournalEntry.PE_DocumentSerialNumber,
JournalEntry.PE_OfficialDocumentNumber ) )
end
as fipe_car_sunat ) as PE_CARIdentifier,
JournalEntry.DocumentDate,
cast( case
when JournalEntry.PE_OfficialDocumentType is not initial
then JournalEntry.PE_OfficialDocumentType
else JournalEntry.ODNDocumentClass
end
as fipe_document_type ) as PE_OfficialDocumentType,
JournalEntry.PE_DocumentSerialNumber,
JournalEntry.PE_OfficialDocumentNumber,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( currency_conversion( amount => JournalEntry.TaxBaseAmountInTransCrcy,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ExchangeRateEffectiveDate,
error_handling => 'SET_TO_NULL' )
as fipe_value_of_acquisition_amt ) as PE_ValOfAcqnAmtInCtryCrcy,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( currency_conversion( amount => JournalEntry.PE_AddlConceptAmtInCtryCrcy,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ExchangeRateEffectiveDate,
error_handling => 'SET_TO_NULL' )
as fipe_other_taxes_charges ) as PE_OthTxAndChrgsAmtInCtryCrcy,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( currency_conversion( amount => JournalEntry.AmountInTransactionCurrency,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ExchangeRateEffectiveDate,
error_handling => 'SET_TO_NULL' )
as fipe_total_acquisition_amount ) as PE_TotAcqnAmtInCtryCrcy,
@Semantics.currencyCode:true
JournalEntry.TransactionCurrency,
@Semantics.currencyCode:true
JournalEntry.CountryCurrency,
cast( case JournalEntry.TransactionCurrency
when 'PEN'
then 1
else ExchangeRate.ExchangeRate
end
as fipe_exchange_rate ) as ExchangeRate,
JournalEntry.PE_SUNATCountryCode,
JournalEntry.SupplierName,
JournalEntry.TaxNumber1,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( case
when JournalEntry.ClearingDate is not initial
then
currency_conversion( amount => JournalEntry.TaxBaseAmountInTransCrcy,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ClearingDate,
error_handling => 'SET_TO_NULL' )
else
0
end
as hwbas_shl ) as TaxBaseAmountInCoCodeCrcy,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( case
when JournalEntry.ClearingDate is not initial
then
currency_conversion( amount => JournalEntry.PE_AddlConceptAmtInCtryCrcy,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ClearingDate,
error_handling => 'SET_TO_NULL' )
else
0
end
as fipe_deduction_amount ) as PE_DeductionAmtInCtryCrcy,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( case
when JournalEntry.ClearingDate is not initial
then
currency_conversion( amount => JournalEntry.AmountInTransactionCurrency,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ClearingDate,
error_handling => 'SET_TO_NULL' )
else
0
end
as fis_hsl ) as AmountInCompanyCodeCurrency,
cast( case
when JournalEntry.ClearingDate is initial
then
0
else
JournalEntry.WithholdingTaxPercent
end
as qsatz ) as WithholdingTaxPercent,
@Semantics.amount.currencyCode: 'CountryCurrency'
cast( case
when JournalEntry.ClearingDate is not initial
then
currency_conversion( amount => JournalEntry.WhldgTaxAmtInTransacCrcy,
source_currency => JournalEntry.TransactionCurrency,
target_currency => JournalEntry.CountryCurrency,
exchange_rate_date => JournalEntry.ClearingDate,
error_handling => 'SET_TO_NULL' )
else
0
end
as fis_qbshh ) as WhldgTaxAmtInCoCodeCrcy,
JournalEntry.PE_ConventionAvoidDoubleTxn,
cast( case
when FinancialStatement1.FinancialStatementHierarchy = $parameters.P_PE_ClassfctnRevenueType
then FinancialStatement1.HierarchyParentNodeVal
else ''
end
as fipe_classfctn_revenue_type ) as PE_ClassificationRevenueType,
cast( case
when FinancialStatement2.FinancialStatementHierarchy = $parameters.P_PE_ClassfctnServiceType
then FinancialStatement2.HierarchyParentNodeVal
else ''
end
as fipe_classfctn_service_type ) as PE_ClassificationServiceType,
@Semantics.amount.currencyCode: 'CountryCurrency'
JournalEntry.WhldgTaxBaseAmtInCoCodeCrcy
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_EXCHANGERATE",
"I_STRPJOURNALENTRYLOG",
"P_PE_JOURNALENTRYFSSTRUCTURE",
"P_PE_JRNLENTRYWTHOFCLDOCCLASS",
"P_PE_PURFRGNSUPLRENTRYAGGRGD"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/