C_MngJournalEntryTotalAmount

DDL: C_MNGJOURNALENTRYTOTALAMOUNT Type: view_entity CONSUMPTION

Journal Entry Total Amount

C_MngJournalEntryTotalAmount is a Consumption CDS View that provides data about "Journal Entry Total Amount" in SAP S/4HANA. It reads from 4 data sources (R_ManageJournalEntryLedgerView, R_ManageJournalEntryItem, R_MngJrnlEntrTechLedgerView, R_MngJrnlEntrPrkdDocumentItem) and exposes 182 fields with key fields SourceLedger, CompanyCode, FiscalYear, AccountingDocument, TransactionCurrency.

Data Sources (4)

SourceAliasJoin Type
R_ManageJournalEntryLedgerView _Item from
R_ManageJournalEntryItem _Item union_all
R_MngJrnlEntrTechLedgerView _Item union_all
R_MngJrnlEntrPrkdDocumentItem _Item union_all

Annotations (8)

NameValueLevelField
AccessControl.authorizationCheck #MANDATORY view
EndUserText.label Journal Entry Total Amount view
ObjectModel.query.implementedBy ABAP:CL_MJE_TOTAL_AMOUNT view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
VDM.viewType #CONSUMPTION view

Fields (182)

KeyFieldSource TableSource FieldDescription
KEY SourceLedger SourceLedger
KEY CompanyCode CompanyCode
KEY FiscalYear FiscalYear
KEY AccountingDocument AccountingDocument
KEY TransactionCurrency TransactionCurrency
KEY CompanyCodeCurrency CompanyCodeCurrency
KEY GlobalCurrency GlobalCurrency
KEY FunctionalCurrency FunctionalCurrency
KEY FreeDefinedCurrency1 FreeDefinedCurrency1
KEY FreeDefinedCurrency2 FreeDefinedCurrency2
KEY FreeDefinedCurrency3 FreeDefinedCurrency3
KEY FreeDefinedCurrency4 FreeDefinedCurrency4
KEY FreeDefinedCurrency5 FreeDefinedCurrency5
KEY FreeDefinedCurrency6 FreeDefinedCurrency6
KEY FreeDefinedCurrency7 FreeDefinedCurrency7
KEY FreeDefinedCurrency8 FreeDefinedCurrency8
KEY AdditionalCurrency1
KEY AdditionalCurrency2
CreditAmountInTransCrcy
CreditAmountInCoCodeCrcy
CreditAmountInGlobalCrcy
CreditAmountInFunctionalCrcy
CreditAmountInFreeDfndCrcy1
CreditAmountInFreeDfndCrcy2
CreditAmountInFreeDfndCrcy3
CreditAmountInFreeDfndCrcy4
CreditAmountInFreeDfndCrcy5
CreditAmountInFreeDfndCrcy6
CreditAmountInFreeDfndCrcy7
CreditAmountInFreeDfndCrcy8
CreditAmountInAddlCrcy1
CreditAmountInAddlCrcy2
DebitAmountInTransCrcy
DebitAmountInCoCodeCrcy
DebitAmountInGlobalCrcy
DebitAmountInFunctionalCrcy
DebitAmountInFreeDfndCrcy1
DebitAmountInFreeDfndCrcy2
DebitAmountInFreeDfndCrcy3
DebitAmountInFreeDfndCrcy4
DebitAmountInFreeDfndCrcy5
DebitAmountInFreeDfndCrcy6
DebitAmountInFreeDfndCrcy7
DebitAmountInFreeDfndCrcy8
DebitAmountInAddlCrcy1
DebitAmountInAddlCrcy2
KEY CompanyCode CompanyCode
KEY FiscalYear FiscalYear
KEY AccountingDocument AccountingDocument
KEY TransactionCurrency TransactionCurrency
KEY CompanyCodeCurrency CompanyCodeCurrency
KEY GlobalCurrency
KEY FunctionalCurrency FunctionalCurrency
KEY FreeDefinedCurrency1
KEY FreeDefinedCurrency2
KEY FreeDefinedCurrency3
KEY FreeDefinedCurrency4
KEY FreeDefinedCurrency5
KEY FreeDefinedCurrency6
KEY FreeDefinedCurrency7
KEY FreeDefinedCurrency8
KEY AdditionalCurrency1 AdditionalCurrency1
KEY AdditionalCurrency2 AdditionalCurrency2
CreditAmountInTransCrcy
CreditAmountInCoCodeCrcy
CreditAmountInGlobalCrcy
CreditAmountInFunctionalCrcy
CreditAmountInFreeDfndCrcy1
CreditAmountInFreeDfndCrcy2
CreditAmountInFreeDfndCrcy3
CreditAmountInFreeDfndCrcy4
CreditAmountInFreeDfndCrcy5
CreditAmountInFreeDfndCrcy6
CreditAmountInFreeDfndCrcy7
CreditAmountInFreeDfndCrcy8
CreditAmountInAddlCrcy1
CreditAmountInAddlCrcy2
DebitAmountInTransCrcy
DebitAmountInCoCodeCrcy
DebitAmountInGlobalCrcy
DebitAmountInFunctionalCrcy
DebitAmountInFreeDfndCrcy1
DebitAmountInFreeDfndCrcy2
DebitAmountInFreeDfndCrcy3
DebitAmountInFreeDfndCrcy4
DebitAmountInFreeDfndCrcy5
DebitAmountInFreeDfndCrcy6
DebitAmountInFreeDfndCrcy7
DebitAmountInFreeDfndCrcy8
DebitAmountInAddlCrcy1
DebitAmountInAddlCrcy2
KEY CompanyCode CompanyCode
KEY FiscalYear FiscalYear
KEY AccountingDocument AccountingDocument
KEY TransactionCurrency TransactionCurrency
KEY CompanyCodeCurrency CompanyCodeCurrency
KEY GlobalCurrency GlobalCurrency
KEY FunctionalCurrency FunctionalCurrency
KEY FreeDefinedCurrency1 FreeDefinedCurrency1
KEY FreeDefinedCurrency2 FreeDefinedCurrency2
KEY FreeDefinedCurrency3 FreeDefinedCurrency3
KEY FreeDefinedCurrency4 FreeDefinedCurrency4
KEY FreeDefinedCurrency5 FreeDefinedCurrency5
KEY FreeDefinedCurrency6 FreeDefinedCurrency6
KEY FreeDefinedCurrency7 FreeDefinedCurrency7
KEY FreeDefinedCurrency8 FreeDefinedCurrency8
KEY AdditionalCurrency1
KEY AdditionalCurrency2
CreditAmountInTransCrcy
CreditAmountInCoCodeCrcy
CreditAmountInGlobalCrcy
CreditAmountInFunctionalCrcy
CreditAmountInFreeDfndCrcy1
CreditAmountInFreeDfndCrcy2
CreditAmountInFreeDfndCrcy3
CreditAmountInFreeDfndCrcy4
CreditAmountInFreeDfndCrcy5
CreditAmountInFreeDfndCrcy6
CreditAmountInFreeDfndCrcy7
CreditAmountInFreeDfndCrcy8
CreditAmountInAddlCrcy1
CreditAmountInAddlCrcy2
DebitAmountInTransCrcy
DebitAmountInCoCodeCrcy
DebitAmountInGlobalCrcy
DebitAmountInFunctionalCrcy
DebitAmountInFreeDfndCrcy1
DebitAmountInFreeDfndCrcy2
DebitAmountInFreeDfndCrcy3
DebitAmountInFreeDfndCrcy4
DebitAmountInFreeDfndCrcy5
DebitAmountInFreeDfndCrcy6
DebitAmountInFreeDfndCrcy7
DebitAmountInFreeDfndCrcy8
DebitAmountInAddlCrcy1
DebitAmountInAddlCrcy2
KEY CompanyCode SourceCompanyCode
KEY FiscalYear SourceFiscalYear
KEY AccountingDocument SourceAccountingDocument
KEY TransactionCurrency TransactionCurrency
KEY CompanyCodeCurrency CompanyCodeCurrency
KEY GlobalCurrency
KEY FunctionalCurrency
KEY FreeDefinedCurrency1
KEY FreeDefinedCurrency2
KEY FreeDefinedCurrency3
KEY FreeDefinedCurrency4
KEY FreeDefinedCurrency5
KEY FreeDefinedCurrency6
KEY FreeDefinedCurrency7
KEY FreeDefinedCurrency8
KEY AdditionalCurrency1 AdditionalCurrency1
KEY AdditionalCurrency2 AdditionalCurrency2
CreditAmountInTransCrcy
CreditAmountInCoCodeCrcy
CreditAmountInGlobalCrcy
CreditAmountInFunctionalCrcy
CreditAmountInFreeDfndCrcy1
CreditAmountInFreeDfndCrcy2
CreditAmountInFreeDfndCrcy3
CreditAmountInFreeDfndCrcy4
CreditAmountInFreeDfndCrcy5
CreditAmountInFreeDfndCrcy6
CreditAmountInFreeDfndCrcy7
CreditAmountInFreeDfndCrcy8
CreditAmountInAddlCrcy1
CreditAmountInAddlCrcy2
DebitAmountInTransCrcy
DebitAmountInCoCodeCrcy
DebitAmountInGlobalCrcy
DebitAmountInFunctionalCrcy
DebitAmountInFreeDfndCrcy1
DebitAmountInFreeDfndCrcy2
DebitAmountInFreeDfndCrcy3
DebitAmountInFreeDfndCrcy4
DebitAmountInFreeDfndCrcy5
DebitAmountInFreeDfndCrcy6
DebitAmountInFreeDfndCrcy7
DebitAmountInFreeDfndCrcy8
DebitAmountInAddlCrcy1
DebitAmountInAddlCrcy2
DatabaseTable
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #MANDATORY
@EndUserText.label: 'Journal Entry Total Amount'

@ObjectModel.query.implementedBy: 'ABAP:CL_MJE_TOTAL_AMOUNT'

@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
  serviceQuality: #C,
  sizeCategory: #XXL,
  dataClass: #MIXED
}
@VDM.viewType: #CONSUMPTION

define view entity C_MngJournalEntryTotalAmount
as select from R_ManageJournalEntryLedgerView as _Item

{ key SourceLedger,
  key CompanyCode,
  key FiscalYear,
  key AccountingDocument,
  key TransactionCurrency,
  key CompanyCodeCurrency,
  key GlobalCurrency,
  key FunctionalCurrency,
  key FreeDefinedCurrency1,
  key FreeDefinedCurrency2,
  key FreeDefinedCurrency3,
  key FreeDefinedCurrency4,
  key FreeDefinedCurrency5,
  key FreeDefinedCurrency6,
  key FreeDefinedCurrency7,
  key FreeDefinedCurrency8,
  key cast('' as fis_hwae2) as AdditionalCurrency1,
  key cast('' as fis_hwae3) as AdditionalCurrency2,

      ///

      // Credit Amounts

      ///

//      @Semantics: { amount : {currencyCode: 'BalanceTransactionCurrency'} }

//      sum(CreditAmountInBalanceTransCrcy) as CreditAmountInBalanceTransCrcy,

      @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
      sum(CreditAmountInTransCrcy) as CreditAmountInTransCrcy,
      @Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
      sum(CreditAmountInCoCodeCrcy) as CreditAmountInCoCodeCrcy,
      @Semantics: { amount : {currencyCode: 'GlobalCurrency'} }
      sum(CreditAmountInGlobalCrcy) as CreditAmountInGlobalCrcy,
      @Semantics: { amount : {currencyCode: 'FunctionalCurrency'} }
      sum(CreditAmountInFunctionalCrcy) as CreditAmountInFunctionalCrcy,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency1'} }
      sum(CreditAmountInFreeDfndCrcy1) as CreditAmountInFreeDfndCrcy1,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency2'} }
      sum(CreditAmountInFreeDfndCrcy2) as CreditAmountInFreeDfndCrcy2,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency3'} }
      sum(CreditAmountInFreeDfndCrcy3) as CreditAmountInFreeDfndCrcy3,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency4'} }
      sum(CreditAmountInFreeDfndCrcy4) as CreditAmountInFreeDfndCrcy4,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency5'} }
      sum(CreditAmountInFreeDfndCrcy5) as CreditAmountInFreeDfndCrcy5,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency6'} }
      sum(CreditAmountInFreeDfndCrcy6) as CreditAmountInFreeDfndCrcy6,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency7'} }
      sum(CreditAmountInFreeDfndCrcy7) as CreditAmountInFreeDfndCrcy7,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency8'} }
      sum(CreditAmountInFreeDfndCrcy8) as CreditAmountInFreeDfndCrcy8,
      @Semantics: { amount : {currencyCode: 'AdditionalCurrency1'} }
      cast(abap.curr'0.00' as fis_dmbe2) as CreditAmountInAddlCrcy1,
      @Semantics: { amount : {currencyCode: 'AdditionalCurrency2'} }
      cast(abap.curr'0.00' as fis_dmbe3) as CreditAmountInAddlCrcy2,

      ///

      // Debit Amounts

      ///

//      @Semantics: { amount : {currencyCode: 'BalanceTransactionCurrency'} }

//      sum(DebitAmountInBalanceTransCrcy) as DebitAmountInBalanceTransCrcy,

      @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
      sum(DebitAmountInTransCrcy) as DebitAmountInTransCrcy,
      @Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
      sum(DebitAmountInCoCodeCrcy) as DebitAmountInCoCodeCrcy,
      @Semantics: { amount : {currencyCode: 'GlobalCurrency'} }
      sum(DebitAmountInGlobalCrcy) as DebitAmountInGlobalCrcy,
      @Semantics: { amount : {currencyCode: 'FunctionalCurrency'} }
      sum(DebitAmountInFunctionalCrcy) as DebitAmountInFunctionalCrcy,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency1'} }
      sum(DebitAmountInFreeDfndCrcy1) as DebitAmountInFreeDfndCrcy1,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency2'} }
      sum(DebitAmountInFreeDfndCrcy2) as DebitAmountInFreeDfndCrcy2,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency3'} }
      sum(DebitAmountInFreeDfndCrcy3) as DebitAmountInFreeDfndCrcy3,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency4'} }
      sum(DebitAmountInFreeDfndCrcy4) as DebitAmountInFreeDfndCrcy4,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency5'} }
      sum(DebitAmountInFreeDfndCrcy5) as DebitAmountInFreeDfndCrcy5,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency6'} }
      sum(DebitAmountInFreeDfndCrcy6) as DebitAmountInFreeDfndCrcy6,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency7'} }
      sum(DebitAmountInFreeDfndCrcy7) as DebitAmountInFreeDfndCrcy7,
      @Semantics: { amount : {currencyCode: 'FreeDefinedCurrency8'} }
      sum(DebitAmountInFreeDfndCrcy8) as DebitAmountInFreeDfndCrcy8,
      @Semantics: { amount : {currencyCode: 'AdditionalCurrency1'} }
      cast(abap.curr'0.00' as fis_dmbe2) as DebitAmountInAddlCrcy1,
      @Semantics: { amount : {currencyCode: 'AdditionalCurrency2'} }
      cast(abap.curr'0.00' as fis_dmbe3) as DebitAmountInAddlCrcy2,

//      BalanceTransactionCurrency,

      @Environment.sql.passValue: true
      cast('ACDOCA' as tabname) as DatabaseTable


}
group by
SourceLedger,
CompanyCode,
FiscalYear,
AccountingDocument,
//BalanceTransactionCurrency,

TransactionCurrency,
CompanyCodeCurrency,
GlobalCurrency,
FunctionalCurrency,
FreeDefinedCurrency1,
FreeDefinedCurrency2,
FreeDefinedCurrency3,
FreeDefinedCurrency4,
FreeDefinedCurrency5,
FreeDefinedCurrency6,
FreeDefinedCurrency7,
FreeDefinedCurrency8

union all
  select from R_ManageJournalEntryItem as _Item

{
  key cast('' as fins_ledger) as SourceLedger,
  key CompanyCode,
  key FiscalYear,
  key AccountingDocument,
  key TransactionCurrency,
  key CompanyCodeCurrency,
  key cast('' as fis_rkcur) as GlobalCurrency,
  key FunctionalCurrency,
  key cast('' as fis_rocur) as FreeDefinedCurrency1,
  key cast('' as fis_rvcur) as FreeDefinedCurrency2,
  key cast('' as fis_curr3) as FreeDefinedCurrency3,
  key cast('' as fis_curr4) as FreeDefinedCurrency4,
  key cast('' as fis_curr5) as FreeDefinedCurrency5,
  key cast('' as fis_curr6) as FreeDefinedCurrency6,
  key cast('' as fis_rfcur) as FreeDefinedCurrency7,
  key cast('' as fis_curr8) as FreeDefinedCurrency8,
  key AdditionalCurrency1,
  key AdditionalCurrency2,

      ///

      // Credit Amounts

      ///

//      sum(CreditAmountInBalanceTransCrcy) as CreditAmountInBalanceTransCrcy,

      sum(CreditAmountInTransCrcy) as CreditAmountInTransCrcy,
      sum(CreditAmountInCoCodeCrcy) as CreditAmountInCoCodeCrcy,
      cast(abap.curr'0.00' as fis_cr_ksl) as CreditAmountInGlobalCrcy,
      sum(CreditAmountInFunctionalCrcy) as CreditAmountInFunctionalCrcy,
      cast(abap.curr'0.00' as fis_cr_osl) as CreditAmountInFreeDfndCrcy1,
      cast(abap.curr'0.00' as fis_cr_vsl) as CreditAmountInFreeDfndCrcy2,
      cast(abap.curr'0.00' as fis_cr_bsl) as CreditAmountInFreeDfndCrcy3,
      cast(abap.curr'0.00' as fis_cr_csl) as CreditAmountInFreeDfndCrcy4,
      cast(abap.curr'0.00' as fis_cr_dsl) as CreditAmountInFreeDfndCrcy5,
      cast(abap.curr'0.00' as fis_cr_esl) as CreditAmountInFreeDfndCrcy6,
      cast(abap.curr'0.00' as fis_cr_fsl) as CreditAmountInFreeDfndCrcy7,
      cast(abap.curr'0.00' as fis_cr_gsl) as CreditAmountInFreeDfndCrcy8,
      sum(CreditAmountInAddlCrcy1) as CreditAmountInAddlCrcy1,
      sum(CreditAmountInAddlCrcy2) as CreditAmountInAddlCrcy2,

      ///

      // Debit Amounts

      ///

//      sum(DebitAmountInBalanceTransCrcy) as DebitAmountInBalanceTransCrcy,

      sum(DebitAmountInTransCrcy) as DebitAmountInTransCrcy,
      sum(DebitAmountInCoCodeCrcy) as DebitAmountInCoCodeCrcy,
      cast(abap.curr'0.00' as fis_dr_ksl) as DebitAmountInGlobalCrcy,
      sum(DebitAmountInFunctionalCrcy) as DebitAmountInFunctionalCrcy,
      cast(abap.curr'0.00' as fis_dr_osl) as DebitAmountInFreeDfndCrcy1,
      cast(abap.curr'0.00' as fis_dr_vsl) as DebitAmountInFreeDfndCrcy2,
      cast(abap.curr'0.00' as fis_dr_bsl) as DebitAmountInFreeDfndCrcy3,
      cast(abap.curr'0.00' as fis_dr_csl) as DebitAmountInFreeDfndCrcy4,
      cast(abap.curr'0.00' as fis_dr_dsl) as DebitAmountInFreeDfndCrcy5,
      cast(abap.curr'0.00' as fis_dr_esl) as DebitAmountInFreeDfndCrcy6,
      cast(abap.curr'0.00' as fis_dr_fsl) as DebitAmountInFreeDfndCrcy7,
      cast(abap.curr'0.00' as fis_dr_gsl) as DebitAmountInFreeDfndCrcy8,
      sum(DebitAmountInAddlCrcy1) as DebitAmountInAddlCrcy1,
      sum(DebitAmountInAddlCrcy2) as DebitAmountInAddlCrcy2,

//      BalanceTransactionCurrency,

      cast('BSEG' as tabname) as DatabaseTable

}
group by
CompanyCode,
FiscalYear,
AccountingDocument,
//BalanceTransactionCurrency,

TransactionCurrency,
CompanyCodeCurrency,
FunctionalCurrency,
AdditionalCurrency1,
AdditionalCurrency2

union all
  select from R_MngJrnlEntrTechLedgerView as _Item

{ key SourceLedger,
  key CompanyCode,
  key FiscalYear,
  key AccountingDocument,
  key TransactionCurrency,
  key CompanyCodeCurrency,
  key GlobalCurrency,
  key FunctionalCurrency,
  key FreeDefinedCurrency1,
  key FreeDefinedCurrency2,
  key FreeDefinedCurrency3,
  key FreeDefinedCurrency4,
  key FreeDefinedCurrency5,
  key FreeDefinedCurrency6,
  key FreeDefinedCurrency7,
  key FreeDefinedCurrency8,
  key cast('' as fis_hwae2) as AdditionalCurrency1,
  key cast('' as fis_hwae3) as AdditionalCurrency2,
      ///

      // Credit Amounts

      ///

//      sum(CreditAmountInBalanceTransCrcy) as CreditAmountInBalanceTransCrcy,

      sum(CreditAmountInTransCrcy) as CreditAmountInTransCrcy,
      sum(CreditAmountInCoCodeCrcy) as CreditAmountInCoCodeCrcy,
      sum(CreditAmountInGlobalCrcy) as CreditAmountInGlobalCrcy,
      sum(CreditAmountInFunctionalCrcy) as CreditAmountInFunctionalCrcy,
      sum(CreditAmountInFreeDfndCrcy1) as CreditAmountInFreeDfndCrcy1,
      sum(CreditAmountInFreeDfndCrcy2) as CreditAmountInFreeDfndCrcy2,
      sum(CreditAmountInFreeDfndCrcy3) as CreditAmountInFreeDfndCrcy3,
      sum(CreditAmountInFreeDfndCrcy4) as CreditAmountInFreeDfndCrcy4,
      sum(CreditAmountInFreeDfndCrcy5) as CreditAmountInFreeDfndCrcy5,
      sum(CreditAmountInFreeDfndCrcy6) as CreditAmountInFreeDfndCrcy6,
      sum(CreditAmountInFreeDfndCrcy7) as CreditAmountInFreeDfndCrcy7,
      sum(CreditAmountInFreeDfndCrcy8) as CreditAmountInFreeDfndCrcy8,
      cast(abap.curr'0.00' as fis_dmbe2) as CreditAmountInAddlCrcy1,
      cast(abap.curr'0.00' as fis_dmbe3) as CreditAmountInAddlCrcy2,

      ///

      // Debit Amounts

      ///

//      sum(DebitAmountInBalanceTransCrcy) as DebitAmountInBalanceTransCrcy,

      sum(DebitAmountInTransCrcy) as DebitAmountInTransCrcy,
      sum(DebitAmountInCoCodeCrcy) as DebitAmountInCoCodeCrcy,
      sum(DebitAmountInGlobalCrcy) as DebitAmountInGlobalCrcy,
      sum(DebitAmountInFunctionalCrcy) as DebitAmountInFunctionalCrcy,
      sum(DebitAmountInFreeDfndCrcy1) as DebitAmountInFreeDfndCrcy1,
      sum(DebitAmountInFreeDfndCrcy2) as DebitAmountInFreeDfndCrcy2,
      sum(DebitAmountInFreeDfndCrcy3) as DebitAmountInFreeDfndCrcy3,
      sum(DebitAmountInFreeDfndCrcy4) as DebitAmountInFreeDfndCrcy4,
      sum(DebitAmountInFreeDfndCrcy5) as DebitAmountInFreeDfndCrcy5,
      sum(DebitAmountInFreeDfndCrcy6) as DebitAmountInFreeDfndCrcy6,
      sum(DebitAmountInFreeDfndCrcy7) as DebitAmountInFreeDfndCrcy7,
      sum(DebitAmountInFreeDfndCrcy8) as DebitAmountInFreeDfndCrcy8,
      cast(abap.curr'0.00' as fis_dmbe2) as DebitAmountInAddlCrcy1,
      cast(abap.curr'0.00' as fis_dmbe3) as DebitAmountInAddlCrcy2,

//      BalanceTransactionCurrency,

      cast('TECHACDOCA' as tabname) as DatabaseTable


}
group by
SourceLedger,
CompanyCode,
FiscalYear,
AccountingDocument,
//BalanceTransactionCurrency,

TransactionCurrency,
CompanyCodeCurrency,
GlobalCurrency,
FunctionalCurrency,
FreeDefinedCurrency1,
FreeDefinedCurrency2,
FreeDefinedCurrency3,
FreeDefinedCurrency4,
FreeDefinedCurrency5,
FreeDefinedCurrency6,
FreeDefinedCurrency7,
FreeDefinedCurrency8

union all
  select from R_MngJrnlEntrPrkdDocumentItem as _Item

{
  key cast('' as fins_ledger) as SourceLedger,
  key SourceCompanyCode as CompanyCode,
  key SourceFiscalYear as FiscalYear,
  key SourceAccountingDocument as AccountingDocument,
  key TransactionCurrency,
  key CompanyCodeCurrency,
  key cast('' as fis_rkcur) as GlobalCurrency,
  key cast('' as fins_currf) as FunctionalCurrency,
  key cast('' as fis_rocur) as FreeDefinedCurrency1,
  key cast('' as fis_rvcur) as FreeDefinedCurrency2,
  key cast('' as fis_curr3) as FreeDefinedCurrency3,
  key cast('' as fis_curr4) as FreeDefinedCurrency4,
  key cast('' as fis_curr5) as FreeDefinedCurrency5,
  key cast('' as fis_curr6) as FreeDefinedCurrency6,
  key cast('' as fis_rfcur) as FreeDefinedCurrency7,
  key cast('' as fis_curr8) as FreeDefinedCurrency8,
  key AdditionalCurrency1,
  key AdditionalCurrency2,

      ///

      // Credit Amounts

      ///

//      sum(CreditAmountInBalanceTransCrcy) as CreditAmountInBalanceTransCrcy,

      sum(CreditAmountInTransCrcy) as CreditAmountInTransCrcy,
      sum(CreditAmountInCoCodeCrcy) as CreditAmountInCoCodeCrcy,
      cast(abap.curr'0.00' as fis_cr_ksl) as CreditAmountInGlobalCrcy,
      cast(abap.curr'0.00' as fis_cr_amt_funccrcy) as CreditAmountInFunctionalCrcy,
      cast(abap.curr'0.00' as fis_cr_osl) as CreditAmountInFreeDfndCrcy1,
      cast(abap.curr'0.00' as fis_cr_vsl) as CreditAmountInFreeDfndCrcy2,
      cast(abap.curr'0.00' as fis_cr_bsl) as CreditAmountInFreeDfndCrcy3,
      cast(abap.curr'0.00' as fis_cr_csl) as CreditAmountInFreeDfndCrcy4,
      cast(abap.curr'0.00' as fis_cr_dsl) as CreditAmountInFreeDfndCrcy5,
      cast(abap.curr'0.00' as fis_cr_esl) as CreditAmountInFreeDfndCrcy6,
      cast(abap.curr'0.00' as fis_cr_fsl) as CreditAmountInFreeDfndCrcy7,
      cast(abap.curr'0.00' as fis_cr_gsl) as CreditAmountInFreeDfndCrcy8,
      sum(CreditAmountInAddlCrcy1) as CreditAmountInAddlCrcy1,
      sum(CreditAmountInAddlCrcy2) as CreditAmountInAddlCrcy2,

      ///

      // Debit Amounts

      ///

//      sum(DebitAmountInBalanceTransCrcy) as DebitAmountInBalanceTransCrcy,

      sum(DebitAmountInTransCrcy) as DebitAmountInTransCrcy,
      sum(DebitAmountInCoCodeCrcy) as DebitAmountInCoCodeCrcy,
      cast(abap.curr'0.00' as fis_dr_ksl) as DebitAmountInGlobalCrcy,
      cast(abap.curr'0.00' as fis_dr_amt_funccrcy) as DebitAmountInFunctionalCrcy,
      cast(abap.curr'0.00' as fis_dr_osl) as DebitAmountInFreeDfndCrcy1,
      cast(abap.curr'0.00' as fis_dr_vsl) as DebitAmountInFreeDfndCrcy2,
      cast(abap.curr'0.00' as fis_dr_bsl) as DebitAmountInFreeDfndCrcy3,
      cast(abap.curr'0.00' as fis_dr_csl) as DebitAmountInFreeDfndCrcy4,
      cast(abap.curr'0.00' as fis_dr_dsl) as DebitAmountInFreeDfndCrcy5,
      cast(abap.curr'0.00' as fis_dr_esl) as DebitAmountInFreeDfndCrcy6,
      cast(abap.curr'0.00' as fis_dr_fsl) as DebitAmountInFreeDfndCrcy7,
      cast(abap.curr'0.00' as fis_dr_gsl) as DebitAmountInFreeDfndCrcy8,
      sum(DebitAmountInAddlCrcy1) as DebitAmountInAddlCrcy1,
      sum(DebitAmountInAddlCrcy2) as DebitAmountInAddlCrcy2,

//      BalanceTransactionCurrency,

      cast('BSEG' as tabname) as DatabaseTable

}
group by
SourceCompanyCode,
SourceFiscalYear,
SourceAccountingDocument,
TransactionCurrency,
CompanyCodeCurrency,
AdditionalCurrency1,
AdditionalCurrency2
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"R_MANAGEJOURNALENTRYITEM",
"R_MANAGEJOURNALENTRYLEDGERVIEW",
"R_MNGJRNLENTRPRKDDOCUMENTITEM",
"R_MNGJRNLENTRTECHLEDGERVIEW"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/