@AbapCatalog.sqlViewName: 'PPESRJENTRYITEM'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.private:true
@VDM.viewType: #CONSUMPTION
@EndUserText.label: 'Journal Entry Item for Peru in StRp'
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #P
define view P_PE_StRpJournalEntryItem
with parameters
P_ReportingCurrency : glo_reporting_currency
as select from I_JournalEntryItem as JournalEntryItem
inner join P_PE_JrnlEntryWthOfclDocClass as JrnlEntryWthOfclDocClass on JournalEntryItem.CompanyCode = JrnlEntryWthOfclDocClass.CompanyCode
and JournalEntryItem.AccountingDocument = JrnlEntryWthOfclDocClass.AccountingDocument
and JournalEntryItem.FiscalYear = JrnlEntryWthOfclDocClass.FiscalYear
inner join I_StRpJournalEntryLog as StRpJournalEntryLog on JournalEntryItem.CompanyCode = StRpJournalEntryLog.CompanyCode
and JournalEntryItem.AccountingDocument = StRpJournalEntryLog.AccountingDocument
and JournalEntryItem.FiscalYear = StRpJournalEntryLog.FiscalYear
inner join I_AddlCompanyCodeInformation as CompanyCodeInfo on CompanyCodeInfo.CompanyCode = JournalEntryItem.CompanyCode
and CompanyCodeInfo.CompanyCodeParameterType = 'TAXNR'
left outer join I_OneTimeAccountBP as OneTimeAccountBP on JournalEntryItem.CompanyCode = OneTimeAccountBP.CompanyCode
and JournalEntryItem.FiscalYear = OneTimeAccountBP.FiscalYear
and JournalEntryItem.AccountingDocument = OneTimeAccountBP.AccountingDocument
and JournalEntryItem.AccountingDocumentItem = OneTimeAccountBP.AccountingDocumentItem
{
key SourceLedger,
key JournalEntryItem.CompanyCode,
key JournalEntryItem.FiscalYear,
key JournalEntryItem.AccountingDocument,
key LedgerGLLineItem,
key JournalEntryItem.Ledger,
key StRpJournalEntryLog.StatryRptCategory,
key StRpJournalEntryLog.StatryRptgEntity,
key StRpJournalEntryLog.StatryRptRunID,
cast( ( JournalEntryItem.AccountingDocument )
as fipe_unique_identifier ) as AccountingDocumentExtendedID,
cast(( concat( 'M', LedgerGLLineItem )) as fipe_external_item_id ) as ExternalItemID,
cast( concat( substring( ReportingDate, 1, 6 ) , '00' ) as fipe_calendar_year_month_day ) as CalendarYearMonth,
JournalEntryItem.AccountingDocumentItem,
LedgerFiscalYear,
FiscalYearVariant,
ChartOfAccounts,
CountryChartOfAccounts,
ControllingArea,
JournalEntryItem.AccountingDocumentType,
FinancialTransactionType,
JournalEntryItem.BusinessTransactionType,
ReferenceDocument,
ReferenceDocumentItem,
ReferenceDocumentItemGroup,
JournalEntryItem.IsReversal,
JournalEntryItem.IsReversed,
JournalEntryItem.ReversalReferenceDocumentCntxt,
JournalEntryItem.ReversalReferenceDocument,
JrnlEntryWthOfclDocClass.DocumentReferenceID,
cast( case
when JrnlEntryWthOfclDocClass.DocumentReferenceID is not initial
then case instr(substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,1,3), '-')
when 3
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,1,2)
else ''
end
else JrnlEntryWthOfclDocClass.ODNDocumentClass
end
as fipe_document_type ) as PE_OfficialDocumentType,
cast( case
when JrnlEntryWthOfclDocClass.DocumentReferenceID is not initial
then
case instr(substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,13), '-')
when 2
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,1)
when 3
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,2)
when 4
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,3)
when 5
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,4)
end
end
as fipe_serial_number) as PE_DocumentSerialNumber,
cast( case substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,1,2)
when '50'
then
case
when JrnlEntryWthOfclDocClass.DocumentReferenceID is not initial
then
case instr(substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,13), '-')
when 2
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,11,6)
when 3
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,12,5)
when 4
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,13,4)
when 5
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,14,3)
end
end
when '51'
then
case
when JrnlEntryWthOfclDocClass.DocumentReferenceID is not initial
then
case instr(substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,13), '-')
when 2
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,11,6)
when 3
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,12,5)
when 4
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,13,4)
when 5
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,14,3)
end
end
else
case instr(substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,4,13), '-')
when 2
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,6,11)
when 3
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,7,10)
when 4
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,8,9)
when 5
then substring(JrnlEntryWthOfclDocClass.DocumentReferenceID,9,8)
end
end
as fipe_official_doc_number) as PE_OfficialDocumentNumber,
Customer,
Supplier,
cast( case
when OneTimeAccountBP.AccountingDocument is not null
then OneTimeAccountBP.TaxNumberType
when FinancialAccountType = 'K'
then _Supplier.TaxNumberType
when FinancialAccountType = 'D'
then _Customer.TaxNumberType
else
''
end
as j_1atoid ) as TaxNumberType,
cast( case
when OneTimeAccountBP.AccountingDocument is not null
then OneTimeAccountBP.TaxID1
when FinancialAccountType = 'K'
then _Supplier.TaxNumber1
when FinancialAccountType = 'D'
then _Customer.TaxNumber1
else
''
end
as stcd1 ) as TaxNumber1,
cast( case
when OneTimeAccountBP.AccountingDocument is not null
then OneTimeAccountBP.Country
when FinancialAccountType = 'K'
then _Supplier.Country
when FinancialAccountType = 'D'
then _Customer.Country
else
''
end
as glo_partner_country ) as BusinessPartnerCountry,
DocumentItemText,
GLAccount,
AlternativeGLAccount,
FinancialAccountType,
CostCenter,
ProfitCenter,
FunctionalArea,
BusinessArea,
Segment,
PartnerCostCenter,
PartnerProfitCenter,
PartnerBusinessArea,
JrnlEntryWthOfclDocClass.ODNDocumentClass,
JrnlEntryWthOfclDocClass.DocumentDate,
JrnlEntryWthOfclDocClass.PostingDate,
JrnlEntryWthOfclDocClass.ReportingDate,
ClearingDate,
JournalEntryItem.CompanyCodeCurrency,
JournalEntryItem.TransactionCurrency,
GlobalCurrency,
BalanceTransactionCurrency,
cast( $parameters.P_ReportingCurrency as glo_reporting_currency ) as ReportingCurrency,
@Semantics.amount.currencyCode: 'ReportingCurrency'
cast(
case $parameters.P_ReportingCurrency
when JournalEntryItem.CompanyCodeCurrency
then JournalEntryItem.CreditAmountInCoCodeCrcy
when JournalEntryItem.TransactionCurrency
then JournalEntryItem.CreditAmountInTransCrcy
when JournalEntryItem.GlobalCurrency
then JournalEntryItem.CreditAmountInGlobalCrcy
when JournalEntryItem.BalanceTransactionCurrency
then JournalEntryItem.CreditAmountInBalanceTransCrcy
when JournalEntryItem.FreeDefinedCurrency1
then JournalEntryItem.CreditAmountInFreeDefinedCrcy1
when JournalEntryItem.FreeDefinedCurrency2
then JournalEntryItem.CreditAmountInFreeDefinedCrcy2
when JournalEntryItem.FreeDefinedCurrency3
then JournalEntryItem.CreditAmountInFreeDefinedCrcy3
when JournalEntryItem.FreeDefinedCurrency4
then JournalEntryItem.CreditAmountInFreeDefinedCrcy4
when JournalEntryItem.FreeDefinedCurrency5
then JournalEntryItem.CreditAmountInFreeDefinedCrcy5
when JournalEntryItem.FreeDefinedCurrency6
then JournalEntryItem.CreditAmountInFreeDefinedCrcy6
when JournalEntryItem.FreeDefinedCurrency7
then JournalEntryItem.CreditAmountInFreeDefinedCrcy7
when JournalEntryItem.FreeDefinedCurrency8
then JournalEntryItem.CreditAmountInFreeDefinedCrcy8
else
0
end as glo_credit_amount_rptg_crcy ) as CreditAmountInReportingCrcy,
@Semantics.amount.currencyCode: 'ReportingCurrency'
cast(
case $parameters.P_ReportingCurrency
when JournalEntryItem.CompanyCodeCurrency
then JournalEntryItem.DebitAmountInCoCodeCrcy
when JournalEntryItem.TransactionCurrency
then JournalEntryItem.DebitAmountInTransCrcy
when JournalEntryItem.GlobalCurrency
then JournalEntryItem.DebitAmountInGlobalCrcy
when JournalEntryItem.BalanceTransactionCurrency
then JournalEntryItem.DebitAmountInBalanceTransCrcy
when JournalEntryItem.FreeDefinedCurrency1
then JournalEntryItem.DebitAmountInFreeDefinedCrcy1
when JournalEntryItem.FreeDefinedCurrency2
then JournalEntryItem.DebitAmountInFreeDefinedCrcy2
when JournalEntryItem.FreeDefinedCurrency3
then JournalEntryItem.DebitAmountInFreeDefinedCrcy3
when JournalEntryItem.FreeDefinedCurrency4
then JournalEntryItem.DebitAmountInFreeDefinedCrcy4
when JournalEntryItem.FreeDefinedCurrency5
then JournalEntryItem.DebitAmountInFreeDefinedCrcy5
when JournalEntryItem.FreeDefinedCurrency6
then JournalEntryItem.DebitAmountInFreeDefinedCrcy6
when JournalEntryItem.FreeDefinedCurrency7
then JournalEntryItem.DebitAmountInFreeDefinedCrcy7
when JournalEntryItem.FreeDefinedCurrency8
then JournalEntryItem.DebitAmountInFreeDefinedCrcy8
else
0
end
as glo_debit_amount_rptg_crcy ) as DebitAmountInReportingCurrency,
CompanyCodeInfo.CompanyCodeParameterValue as PE_CompanyCodeTaxNumber,
CreditAmountInCoCodeCrcy,
CreditAmountInTransCrcy,
CreditAmountInGlobalCrcy,
CreditAmountInBalanceTransCrcy,
DebitAmountInCoCodeCrcy,
DebitAmountInTransCrcy,
DebitAmountInGlobalCrcy,
DebitAmountInBalanceTransCrcy,
_SourceLedger,
JournalEntryItem._CompanyCode,
JournalEntryItem._FiscalYear,
_FiscalYearVariant,
_JournalEntry,
JournalEntryItem._Ledger,
_LedgerFiscalYearForVariant,
_ChartOfAccounts,
_CountryChartOfAccounts,
_ControllingArea,
JournalEntryItem._AccountingDocumentType,
_FinancialTransactionType,
JournalEntryItem._BusinessTransactionType,
_Customer,
_Supplier,
_GLAccountInChartOfAccounts,
_AlternativeGLAccount,
_FinancialAccountType,
_CostCenter,
_ProfitCenter,
_FunctionalArea,
_BusinessArea,
_PartnerBusinessArea,
_Segment,
_PartnerCostCenter,
_PartnerProfitCenter,
JournalEntryItem._CompanyCodeCurrency,
JournalEntryItem._TransactionCurrency,
_GlobalCurrency,
_BalanceTransactionCurrency,
JournalEntryItem.AssignmentReference
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ADDLCOMPANYCODEINFORMATION",
"I_CUSTOMER",
"I_JOURNALENTRYITEM",
"I_ONETIMEACCOUNTBP",
"I_STRPJOURNALENTRYLOG",
"I_SUPPLIER",
"P_PE_JRNLENTRYWTHOFCLDOCCLASS"
],
"ASSOCIATED":
[
"I_ACCOUNTINGDOCUMENTTYPE",
"I_BUSINESSAREA",
"I_BUSINESSTRANSACTIONTYPE",
"I_CHARTOFACCOUNTS",
"I_COMPANYCODE",
"I_CONTROLLINGAREA",
"I_COSTCENTER",
"I_CURRENCY",
"I_CUSTOMER",
"I_FINANCIALACCOUNTTYPE",
"I_FINANCIALTRANSACTIONTYPE",
"I_FISCALYEARFORCOMPANYCODE",
"I_FISCALYEARFORVARIANT",
"I_FISCALYEARVARIANT",
"I_FUNCTIONALAREA",
"I_GLACCOUNTINCHARTOFACCOUNTS",
"I_JOURNALENTRY",
"I_LEDGER",
"I_PROFITCENTER",
"I_SEGMENT",
"I_SUPPLIER"
],
"BASE":
[
"I_JOURNALENTRYITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/