@AbapCatalog.sqlViewName: 'CSROPACCTDOCITCU'
@AbapCatalog.preserveKey:true
@VDM.viewType: #CONSUMPTION
@Analytics: { dataCategory: #CUBE }
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.personalData.blocking:#BLOCKED_DATA_EXCLUDED
@EndUserText.label: 'Opl Acc.Doc.Item Cube for Stat.Reporting'
@Metadata.allowExtensions:true
define view C_StRpOplAcctgDocumentItemCube as select from I_OperationalAcctgDocItem
association [0..*] to I_StRpJournalEntryLog as _ReportedItemsLog
on _ReportedItemsLog.CompanyCode = $projection.CompanyCode
and _ReportedItemsLog.AccountingDocument = $projection.AccountingDocument
and _ReportedItemsLog.FiscalYear = $projection.FiscalYear
{
@ObjectModel.foreignKey.association: '_CompanyCode'
key CompanyCode,
//@ObjectModel.foreignKey.association: '_JournalEntry'
//If annotation _JournalEntry is used the analytical query returns the AccountingDocument number into ABAP in format CCCCYYYYNNNNNNNNNN
//however in CHAR10 field (this is CCCCYYYYNN) and the original document number can't be retrieved from such field
key AccountingDocument,
@ObjectModel.foreignKey.association: '_FiscalYear'
key FiscalYear,
key AccountingDocumentItem,
key _ReportedItemsLog.StatryRptgEntity as StatryRptgEntity,
key _ReportedItemsLog.StatryRptCategory as StatryRptCategory,
key _ReportedItemsLog.StatryRptRunID as StatryRptRunID,
//Dates
PostingDate,
DocumentDate,
@ObjectModel.foreignKey.association: '_ChartOfAccounts'
ChartOfAccounts,
//GLAccount, Supplier, Customer
//@ObjectModel.foreignKey.association: '_GLAccountInCompanyCode'
@ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
GLAccount,
_GLAccountInChartOfAccounts._Text[1: Language = $session.system_language].GLAccountLongName as GLAccountLongName,
//_GLAccountInChartOfAccounts._Text[1: Language = $session.system_language].GLAccountLongName as GLAccountLongName,
@ObjectModel.foreignKey.association: '_Supplier'
Supplier,
_Supplier.SupplierName,
@ObjectModel.foreignKey.association: '_Customer'
Customer,
_Customer.CustomerName,
//Important fields
@ObjectModel.foreignKey.association: '_AccountingDocumentType'
AccountingDocumentType,
@ObjectModel.foreignKey.association: '_PostingKey'
PostingKey, //BSCHL
@ObjectModel.foreignKey.association: '_FinancialAccountType'
FinancialAccountType, //KOART
@ObjectModel.foreignKey.association: '_SpecialGLCode'
SpecialGLCode, //UMSKZ
@ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
AccountingDocumentCategory, //BSTAT
@ObjectModel.foreignKey.association: '_DebitCreditCode'
DebitCreditCode, //SHKZG
AssignmentReference, //ZUONR
DocumentItemText, //SGTXT
//BKPF fields
_JournalEntry.DocumentReferenceID,
_JournalEntry.AccountingDocCreatedByUser,
cast( coalesce( _JournalEntry.JrnlEntryCntrySpecificDate1, '' ) as datum ) as TransactionDate,
//Amounts in Transaction currency
@Semantics.currencyCode:true
@ObjectModel.foreignKey.association: '_TransactionCurrency'
TransactionCurrency,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
case DebitCreditCode
when 'S' then AmountInTransactionCurrency
else cast( '0' as abap.curr( 23,2))
end as DebitAmountInTransCrcy, //Debit amount
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
case DebitCreditCode
when 'H' then -AmountInTransactionCurrency
else cast( '0' as abap.curr( 23,2))
end as CreditAmountInTransCrcy, //Credit transactions
//Amounts in Company code currency
@Semantics.currencyCode:true
@ObjectModel.foreignKey.association: '_CompanyCodeCurrency'
CompanyCodeCurrency,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
case DebitCreditCode
when 'S' then AmountInCompanyCodeCurrency
else cast( '0' as abap.curr( 23,2))
end as DebitAmountInCoCodeCrcy, //Debit amount
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
case DebitCreditCode
when 'H' then -AmountInCompanyCodeCurrency
else cast( '0' as abap.curr( 23,2))
end as CreditAmountInCoCodeCrcy, //Credit transactions
//Clearing
ClearingDate,
@API.element.releaseState: #DEPRECATED
@API.element.successor: 'ClearingJournalEntry'
@VDM.lifecycle.status: #DEPRECATED
@VDM.lifecycle.successor: 'ClearingJournalEntry'
@ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
ClearingAccountingDocument,
@API.element.releaseState: #DEPRECATED
@API.element.successor: 'ClearingJournalEntryFiscalYear'
@VDM.lifecycle.status: #DEPRECATED
@VDM.lifecycle.successor: 'ClearingJournalEntryFiscalYear'
@Semantics.fiscal.year: true
ClearingDocFiscalYear,
@Analytics.internalName: #LOCAL
@ObjectModel.foreignKey.association: '_ClearingJournalEntry'
ClearingJournalEntry,
@Analytics.internalName: #LOCAL
@ObjectModel.foreignKey.association: '_ClearingJrnlEntryFiscalYear'
ClearingJournalEntryFiscalYear,
/*_ReportedItemsLog.StatryRptgEntity as StatryRptgEntity,
_ReportedItemsLog.StatryRptCategory as StatryRptCategory,
_ReportedItemsLog.StatryRptRunID as StatryRptRunID,
*/
//Associations
_CompanyCode,
_FiscalYear,
_JournalEntry,
_ChartOfAccounts,
_GLAccountInChartOfAccounts,
_GLAccountInCompanyCode,
_Supplier,
_Customer,
_AccountingDocumentType,
_PostingKey,
_FinancialAccountType,
_SpecialGLCode,
_AccountingDocumentCategory,
_DebitCreditCode,
_TransactionCurrency,
_CompanyCodeCurrency,
_ClearingJrnlEntryFiscalYear,
_ClearingJournalEntry,
@API.element.releaseState: #DEPRECATED
@API.element.successor: '_ClearingJournalEntry'
@VDM.lifecycle.status: #DEPRECATED
@VDM.lifecycle.successor: '_ClearingJournalEntry'
_ClearingAccountingDocument,
_ReportedItemsLog
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CUSTOMER",
"I_GLACCOUNTINCHARTOFACCOUNTS",
"I_GLACCOUNTTEXT",
"I_JOURNALENTRY",
"I_OPERATIONALACCTGDOCITEM",
"I_STRPJOURNALENTRYLOG",
"I_SUPPLIER"
],
"ASSOCIATED":
[
"I_ACCOUNTINGDOCUMENT",
"I_ACCOUNTINGDOCUMENTCATEGORY",
"I_ACCOUNTINGDOCUMENTTYPE",
"I_CHARTOFACCOUNTS",
"I_COMPANYCODE",
"I_CURRENCY",
"I_CUSTOMER",
"I_DEBITCREDITCODE",
"I_FINANCIALACCOUNTTYPE",
"I_FISCALYEARFORCOMPANYCODE",
"I_GLACCOUNTINCHARTOFACCOUNTS",
"I_GLACCOUNTINCOMPANYCODE",
"I_JOURNALENTRY",
"I_POSTINGKEY",
"I_SPECIALGLCODE",
"I_STRPJOURNALENTRYLOG",
"I_SUPPLIER"
],
"BASE":
[
"I_OPERATIONALACCTGDOCITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/