@AbapCatalog.sqlViewName: 'PFGLIOPRANLS'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.personalData.blocking: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true
@VDM.viewType: #COMPOSITE
@VDM.private: true
define view P_GLIncgOrdPrdtvAnalysisUnion
as select from
I_GLAccountLineItemRawData as _GL
inner join I_SemTagGLAccount
on I_SemTagGLAccount.GLAccount = _GL.GLAccount
and I_SemTagGLAccount.ChartOfAccounts = _GL.ChartOfAccounts
and I_SemTagGLAccount.ValidityStartDate <= $session.system_date
and I_SemTagGLAccount.ValidityEndDate >= $session.system_date
and (
I_SemTagGLAccount.SemanticTag = 'RECO_REV'
or I_SemTagGLAccount.SemanticTag = 'RECO_COS'
or I_SemTagGLAccount.SemanticTag = 'REC_MARGIN'
or I_SemTagGLAccount.SemanticTag = 'SALES_DED'
or I_SemTagGLAccount.SemanticTag = 'BILL_REV'
)
// P_GLAccountLineItemSemTagGLACC
and (
( _GL.FunctionalArea = ''
and I_SemTagGLAccount.IsFunctionalAreaPermitted = 'X'
) // Only line items without functional area permitted
or I_SemTagGLAccount.IsFunctionalAreaPermitted = ''
or I_SemTagGLAccount.IsFunctionalAreaPermitted is null
or GLAccountType = 'X'
or GLAccountType = 'C'
)
association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
$projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
{
key SourceLedger as Ledger,
key SourceLedger,
key CompanyCode,
key FiscalYear,
key AccountingDocument,
key LedgerGLLineItem,
key GLAccountHierarchy,
@ObjectModel.foreignKey.association: '_SemanticTag'
key SemanticTag,
key ValidityStartDate,
key ValidityEndDate,
DocumentDate,
SalesOrganization,
CustomerGroup,
Customer,
_FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
FiscalPeriod,
CompanyCodeCurrency,
GlobalCurrency,
FunctionalCurrency,
// check P_GLAccountLineItemSemTag
case when SemanticTag = 'RECO_REV' then cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_recrevn)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) end as RecognizedRevnAmtInCCCrcy,
case when SemanticTag = 'RECO_REV' then cast (AmountInGlobalCurrency * (-1) as fins_trr_recrevn)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) end as RecognizedRevnAmtInGlobCrcy,
case when SemanticTag = 'RECO_REV' then cast (AmountInCompanyCodeCurrency * (-1) as fis_revenue_hsl)
else cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) end as RevenueAmountInCompanyCodeCrcy,
case when SemanticTag = 'RECO_REV' then cast (AmountInGlobalCurrency * (-1) as fis_revenue_ksl)
else cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) end as RevenueInGlobalCurrency,
case when SemanticTag = 'RECO_COS' then cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_reccogs)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) end as RecognizedCOGSAmtInCCCrcy,
case when SemanticTag = 'RECO_COS' then cast (AmountInGlobalCurrency * (-1) as fins_cogs)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) end as CostOfGoodsSoldAmtInGlobCrcy,
case when SemanticTag = 'REC_MARGIN' then cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_recmargin)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) end as RecognizedMarginAmtInCCCrcy,
case when SemanticTag = 'REC_MARGIN' then cast (AmountInGlobalCurrency * (-1) as fins_trr_recmargin)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) end as RecognizedMarginAmount,
case when SemanticTag = 'SALES_DED' then cast (AmountInGlobalCurrency * (-1) as fins_sales_deduction)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) end as SalesDeductionAmountInGlobCrcy,
case when SemanticTag = 'SALES_DED' then cast (AmountInCompanyCodeCurrency * (-1) as fins_sales_deduction)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) end as SalesDeductionAmtInCoCodeCrcy,
case when SemanticTag = 'BILL_REV' then cast (AmountInGlobalCurrency * (-1) as fins_trr_actrevn)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) end as RecognizableRevnAmtInGlobCrcy,
cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
ProfitCenter,
ControllingArea,
SalesDistrict,
Segment,
cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
DistributionChannel,
SoldProduct as SoldMaterial,
_SalesDocumentBasic.OrganizationDivision as Division,
_SalesDocumentBasic.SalesDocumentType as OrderType,
BusinessTransactionType,
BusinessArea,
CostCenter,
CustomerSupplierCountry,
FiscalYearPeriod,
// Amount in CompanyCode Currency
cast(
case SemanticTag
when 'RECO_REV' then -AmountInCompanyCodeCurrency
when 'RECO_COS' then -AmountInCompanyCodeCurrency
when 'REC_MARGIN' then -AmountInCompanyCodeCurrency
when 'BILL_REV' then -AmountInCompanyCodeCurrency
when 'SALES_DED' then -AmountInCompanyCodeCurrency
else AmountInCompanyCodeCurrency
end as fis_hsl) as AmountInCompanyCodeCurrency,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInCompanyCodeCurrency
when 'RECO_COS' then AmountInCompanyCodeCurrency
when 'REC_MARGIN' then -AmountInCompanyCodeCurrency
when 'BILL_REV' then -AmountInCompanyCodeCurrency
when 'SALES_DED' then AmountInCompanyCodeCurrency
else AmountInCompanyCodeCurrency
end as fis_hsl) as InvertedAmtInCoCodeCurrency,
// Amount in Global Currency
cast(
case SemanticTag
when 'RECO_REV' then -AmountInGlobalCurrency
when 'RECO_COS' then AmountInGlobalCurrency
when 'REC_MARGIN' then -AmountInGlobalCurrency
when 'BILL_REV' then -AmountInGlobalCurrency
when 'SALES_DED' then AmountInGlobalCurrency
else AmountInGlobalCurrency
end as fis_ksl) as InvertedAmountInGlobalCurrency,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInGlobalCurrency
when 'RECO_COS' then -AmountInGlobalCurrency
when 'REC_MARGIN' then -AmountInGlobalCurrency
when 'BILL_REV' then -AmountInGlobalCurrency
when 'SALES_DED' then -AmountInGlobalCurrency
else AmountInGlobalCurrency
end as fis_ksl) as AmountInGlobalCurrency,
// Amount in Functional Currency
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFunctionalCurrency
when 'RECO_COS' then -AmountInFunctionalCurrency
when 'REC_MARGIN' then -AmountInFunctionalCurrency
when 'BILL_REV' then -AmountInFunctionalCurrency
when 'SALES_DED' then -AmountInFunctionalCurrency
else AmountInFunctionalCurrency
end as fis_vfccur12) as AmountInFunctionalCurrency,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFunctionalCurrency
when 'RECO_COS' then AmountInFunctionalCurrency
when 'REC_MARGIN' then -AmountInFunctionalCurrency
when 'BILL_REV' then -AmountInFunctionalCurrency
when 'SALES_DED' then AmountInFunctionalCurrency
else AmountInFunctionalCurrency
end as fis_vfccur12) as InvertedAmtInFuncnlCurrency,
@ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
AccountingDocumentCategory,
@ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
_GL.GLAccount,
PostingDate,
CreationDate,
@ObjectModel.foreignKey.association: '_ChartOfAccounts'
_GL.ChartOfAccounts,
LedgerFiscalYear,
@ObjectModel.foreignKey.association: '_FinancialTransactionType'
FinancialTransactionType,
@ObjectModel.foreignKey.association: '_TransactionCurrency'
@Semantics.currencyCode:true
TransactionCurrency,
// Amount in Transaction Currency
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
cast(
case SemanticTag
when 'RECO_REV' then -AmountInTransactionCurrency
when 'RECO_COS' then -AmountInTransactionCurrency
when 'REC_MARGIN' then -AmountInTransactionCurrency
when 'BILL_REV' then -AmountInTransactionCurrency
when 'SALES_DED' then -AmountInTransactionCurrency
else AmountInTransactionCurrency
end as fis_wsl) as AmountInTransactionCurrency,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
cast(
case SemanticTag
when 'RECO_REV' then -AmountInTransactionCurrency
when 'RECO_COS' then AmountInTransactionCurrency
when 'REC_MARGIN' then -AmountInTransactionCurrency
when 'BILL_REV' then -AmountInTransactionCurrency
when 'SALES_DED' then AmountInTransactionCurrency
else AmountInTransactionCurrency
end as fis_wsl) as InvertedAmtInTransCrcy,
@ObjectModel.foreignKey.association: '_BaseUnit'
@Semantics.unitOfMeasure:true
BaseUnit,
@DefaultAggregation: #SUM
@Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
Quantity,
@DefaultAggregation: #SUM
@Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
FixedQuantity,
@ObjectModel.foreignKey.association: '_DebitCreditCode'
DebitCreditCode,
AssignmentReference,
@ObjectModel.foreignKey.association: '_PostingKey'
PostingKey,
AccountingDocCreatedByUser,
@ObjectModel.foreignKey.association: '_GLAccountType'
GLAccountType,
@ObjectModel.foreignKey.association: '_Plant'
Plant,
@ObjectModel.foreignKey.association: '_FinancialAccountType'
FinancialAccountType,
@ObjectModel.foreignKey.association: '_SpecialGLCode'
SpecialGLCode,
ClearingDate,
@ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
ClearingAccountingDocument,
@ObjectModel.foreignKey.association: '_BillingDocumentType'
BillingDocumentType,
OrganizationDivision,
CustomerSupplierIndustry,
@ObjectModel.foreignKey.association: '_BillToParty'
BillToParty,
@ObjectModel.foreignKey.association: '_ShipToParty'
ShipToParty,
cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
SourceReferenceDocument,
SourceReferenceDocumentItem,
@ObjectModel.foreignKey.association: '_OperatingConcern'
cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
AccountingDocumentItem,
TransactionTypeDetermination,
@ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
@ObjectModel.foreignKey.association: '_AccountingDocumentType'
AccountingDocumentType,
@ObjectModel.foreignKey.association: '_ReferenceDocumentType'
ReferenceDocumentType,
FiscalYearVariant,
_DocumentFiscalCalendarDate.FiscalPeriodStartDate,
cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
cast(
cast(
_DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
) as fins_fiscalyearperiod_je
) as JrnlEntrDerivdFiscalYearPeriod,
cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
FreeDefinedCurrency1,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency1
when 'RECO_COS' then -AmountInFreeDefinedCurrency1
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency1
when 'BILL_REV' then -AmountInFreeDefinedCurrency1
when 'SALES_DED' then -AmountInFreeDefinedCurrency1
else AmountInFreeDefinedCurrency1
end as fis_osl) as AmountInFreeDefinedCurrency1,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency1
when 'RECO_COS' then AmountInFreeDefinedCurrency1
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency1
when 'BILL_REV' then -AmountInFreeDefinedCurrency1
when 'SALES_DED' then AmountInFreeDefinedCurrency1
else AmountInFreeDefinedCurrency1
end as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
FreeDefinedCurrency2,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency2
when 'RECO_COS' then -AmountInFreeDefinedCurrency2
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency2
when 'BILL_REV' then -AmountInFreeDefinedCurrency2
when 'SALES_DED' then -AmountInFreeDefinedCurrency2
else AmountInFreeDefinedCurrency2
end as fis_vsl) as AmountInFreeDefinedCurrency2,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency2
when 'RECO_COS' then AmountInFreeDefinedCurrency2
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency2
when 'BILL_REV' then -AmountInFreeDefinedCurrency2
when 'SALES_DED' then AmountInFreeDefinedCurrency2
else AmountInFreeDefinedCurrency2
end as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
FreeDefinedCurrency3,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency3
when 'RECO_COS' then -AmountInFreeDefinedCurrency3
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency3
when 'BILL_REV' then -AmountInFreeDefinedCurrency3
when 'SALES_DED' then -AmountInFreeDefinedCurrency3
else AmountInFreeDefinedCurrency3
end as fis_bsl) as AmountInFreeDefinedCurrency3,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency3
when 'RECO_COS' then AmountInFreeDefinedCurrency3
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency3
when 'BILL_REV' then -AmountInFreeDefinedCurrency3
when 'SALES_DED' then AmountInFreeDefinedCurrency3
else AmountInFreeDefinedCurrency3
end as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
FreeDefinedCurrency4,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency4
when 'RECO_COS' then -AmountInFreeDefinedCurrency4
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency4
when 'BILL_REV' then -AmountInFreeDefinedCurrency4
when 'SALES_DED' then -AmountInFreeDefinedCurrency4
else AmountInFreeDefinedCurrency4
end as fis_csl) as AmountInFreeDefinedCurrency4,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency4
when 'RECO_COS' then AmountInFreeDefinedCurrency4
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency4
when 'BILL_REV' then -AmountInFreeDefinedCurrency4
when 'SALES_DED' then AmountInFreeDefinedCurrency4
else AmountInFreeDefinedCurrency4
end as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
FreeDefinedCurrency5,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency5
when 'RECO_COS' then -AmountInFreeDefinedCurrency5
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency5
when 'BILL_REV' then -AmountInFreeDefinedCurrency5
when 'SALES_DED' then -AmountInFreeDefinedCurrency5
else AmountInFreeDefinedCurrency5
end as fis_dsl) as AmountInFreeDefinedCurrency5,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency5
when 'RECO_COS' then AmountInFreeDefinedCurrency5
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency5
when 'BILL_REV' then -AmountInFreeDefinedCurrency5
when 'SALES_DED' then AmountInFreeDefinedCurrency5
else AmountInFreeDefinedCurrency5
end as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
FreeDefinedCurrency6,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency6
when 'RECO_COS' then -AmountInFreeDefinedCurrency6
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency6
when 'BILL_REV' then -AmountInFreeDefinedCurrency6
when 'SALES_DED' then -AmountInFreeDefinedCurrency6
else AmountInFreeDefinedCurrency6
end as fis_esl) as AmountInFreeDefinedCurrency6,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency6
when 'RECO_COS' then AmountInFreeDefinedCurrency6
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency6
when 'BILL_REV' then -AmountInFreeDefinedCurrency6
when 'SALES_DED' then AmountInFreeDefinedCurrency6
else AmountInFreeDefinedCurrency6
end as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
FreeDefinedCurrency7,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency7
when 'RECO_COS' then -AmountInFreeDefinedCurrency7
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency7
when 'BILL_REV' then -AmountInFreeDefinedCurrency7
when 'SALES_DED' then -AmountInFreeDefinedCurrency7
else AmountInFreeDefinedCurrency7
end as fis_fsl) as AmountInFreeDefinedCurrency7,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency7
when 'RECO_COS' then AmountInFreeDefinedCurrency7
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency7
when 'BILL_REV' then -AmountInFreeDefinedCurrency7
when 'SALES_DED' then AmountInFreeDefinedCurrency7
else AmountInFreeDefinedCurrency7
end as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
FreeDefinedCurrency8,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency8
when 'RECO_COS' then -AmountInFreeDefinedCurrency8
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency8
when 'BILL_REV' then -AmountInFreeDefinedCurrency8
when 'SALES_DED' then -AmountInFreeDefinedCurrency8
else AmountInFreeDefinedCurrency8
end as fis_gsl) as AmountInFreeDefinedCurrency8,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency8
when 'RECO_COS' then AmountInFreeDefinedCurrency8
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency8
when 'BILL_REV' then -AmountInFreeDefinedCurrency8
when 'SALES_DED' then AmountInFreeDefinedCurrency8
else AmountInFreeDefinedCurrency8
end as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
IsCommitment,
// Added fields for DCL
ServiceDocument,
ServiceDocumentItem,
ServiceDocumentType,
ValuationArea,
Supplier,
SalesDocument,
FixedAsset,
MasterFixedAsset,
OrderID,
AssetClass,
_GL.FunctionalArea,
_ServiceDocument,
_Supplier,
_SalesDocument,
_FixedAsset,
_Order,
//
_FiscalYear,
_CompanyCodeCurrency,
_GlobalCurrency,
_SalesOrganization,
_Customer,
_SalesDistrict,
_Segment,
//_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
//_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
_DistributionChannel,
_BusinessTransactionType,
_BusinessArea,
_CostCenter,
_ControllingArea,
_CustomerSupplierCountry,
_SoldMaterial,
_CompanyCode,
_CustomerGroup,
_Ledger,
_SemanticTag,
_AccountingDocumentCategory,
_GLAccountInChartOfAccounts,
_ChartOfAccounts,
_LedgerFiscalYearForVariant,
_FiscalPeriodForVariant,
_FiscalYearPeriodForVariant,
_FinancialTransactionType,
_TransactionCurrency,
_BaseUnit,
_DebitCreditCode,
_PostingKey,
_GLAccountType,
_Plant,
_FinancialAccountType,
_SpecialGLCode,
_ClearingAccountingDocument,
_BillingDocumentType,
_BillToParty,
_ShipToParty,
_OperatingConcern,
_ControllingDebitCreditCode,
_AccountingDocumentType,
_ReferenceDocumentType,
_FiscalYearVariant,
_DocumentFiscalCalendarDate,
_GLAccountInCompanyCode,
_JournalEntry
}
where
SourceReferenceDocument <> ''
and
SourceReferenceDocumentType = 'VBAK'
and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
and AccountingDocumentCategory = 'P'
and IsCommitment <> 'X'
and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
union all
select from
I_GLAccountLineItemRawData as _GL
inner join I_SemTagFuncArea
on I_SemTagFuncArea.FunctionalArea = _GL.FunctionalArea
and I_SemTagFuncArea.ValidityStartDate <= $session.system_date
and I_SemTagFuncArea.ValidityEndDate >= $session.system_date
and (
I_SemTagFuncArea.SemanticTag = 'RECO_REV'
or I_SemTagFuncArea.SemanticTag = 'RECO_COS'
or I_SemTagFuncArea.SemanticTag = 'REC_MARGIN'
or I_SemTagFuncArea.SemanticTag = 'SALES_DED'
or I_SemTagFuncArea.SemanticTag = 'BILL_REV'
)
association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
$projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
{
key SourceLedger as Ledger,
key SourceLedger,
key CompanyCode,
key FiscalYear,
key AccountingDocument,
key LedgerGLLineItem,
key GLAccountHierarchy,
@ObjectModel.foreignKey.association: '_SemanticTag'
key SemanticTag,
key ValidityStartDate,
key ValidityEndDate,
DocumentDate,
SalesOrganization,
CustomerGroup,
Customer,
_FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
FiscalPeriod,
CompanyCodeCurrency,
GlobalCurrency,
FunctionalCurrency,
// check P_GLAccountLineItemSemTag
case when SemanticTag = 'RECO_REV' then cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_recrevn)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) end as RecognizedRevnAmtInCCCrcy,
case when SemanticTag = 'RECO_REV' then cast (AmountInGlobalCurrency * (-1) as fins_trr_recrevn)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) end as RecognizedRevnAmtInGlobCrcy,
case when SemanticTag = 'RECO_REV' then cast (AmountInCompanyCodeCurrency * (-1) as fis_revenue_hsl)
else cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) end as RevenueAmountInCompanyCodeCrcy,
case when SemanticTag = 'RECO_REV' then cast (AmountInGlobalCurrency * (-1) as fis_revenue_ksl)
else cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) end as RevenueInGlobalCurrency,
case when SemanticTag = 'RECO_COS' then cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_reccogs)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) end as RecognizedCOGSAmtInCCCrcy,
case when SemanticTag = 'RECO_COS' then cast (AmountInGlobalCurrency * (-1) as fins_cogs)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) end as CostOfGoodsSoldAmtInGlobCrcy,
case when SemanticTag = 'REC_MARGIN' then cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_recmargin)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) end as RecognizedMarginAmtInCCCrcy,
case when SemanticTag = 'REC_MARGIN' then cast (AmountInGlobalCurrency * (-1) as fins_trr_recmargin)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) end as RecognizedMarginAmount,
case when SemanticTag = 'SALES_DED' then cast (AmountInGlobalCurrency * (-1) as fins_sales_deduction)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) end as SalesDeductionAmountInGlobCrcy,
case when SemanticTag = 'SALES_DED' then cast (AmountInCompanyCodeCurrency * (-1) as fins_sales_deduction)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) end as SalesDeductionAmtInCoCodeCrcy,
case when SemanticTag = 'BILL_REV' then cast (AmountInGlobalCurrency * (-1) as fins_trr_actrevn)
else cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) end as RecognizableRevnAmtInGlobCrcy,
cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
ProfitCenter,
ControllingArea,
SalesDistrict,
Segment,
cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
DistributionChannel,
SoldProduct as SoldMaterial,
_SalesDocumentBasic.OrganizationDivision as Division,
_SalesDocumentBasic.SalesDocumentType as OrderType,
BusinessTransactionType,
BusinessArea,
CostCenter,
CustomerSupplierCountry,
FiscalYearPeriod,
// Amount in CompanyCode Currency
cast(
case SemanticTag
when 'RECO_REV' then -AmountInCompanyCodeCurrency
when 'RECO_COS' then -AmountInCompanyCodeCurrency
when 'REC_MARGIN' then -AmountInCompanyCodeCurrency
when 'BILL_REV' then -AmountInCompanyCodeCurrency
when 'SALES_DED' then -AmountInCompanyCodeCurrency
else AmountInCompanyCodeCurrency
end as fis_hsl) as AmountInCompanyCodeCurrency,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInCompanyCodeCurrency
when 'RECO_COS' then AmountInCompanyCodeCurrency
when 'REC_MARGIN' then -AmountInCompanyCodeCurrency
when 'BILL_REV' then -AmountInCompanyCodeCurrency
when 'SALES_DED' then AmountInCompanyCodeCurrency
else AmountInCompanyCodeCurrency
end as fis_hsl) as InvertedAmtInCoCodeCurrency,
// Amount in Global Currency
cast(
case SemanticTag
when 'RECO_REV' then -AmountInGlobalCurrency
when 'RECO_COS' then AmountInGlobalCurrency
when 'REC_MARGIN' then -AmountInGlobalCurrency
when 'BILL_REV' then -AmountInGlobalCurrency
when 'SALES_DED' then AmountInGlobalCurrency
else AmountInGlobalCurrency
end as fis_ksl) as InvertedAmountInGlobalCurrency,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInGlobalCurrency
when 'RECO_COS' then -AmountInGlobalCurrency
when 'REC_MARGIN' then -AmountInGlobalCurrency
when 'BILL_REV' then -AmountInGlobalCurrency
when 'SALES_DED' then -AmountInGlobalCurrency
else AmountInGlobalCurrency
end as fis_ksl) as AmountInGlobalCurrency,
// Amount in Functional Currency
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFunctionalCurrency
when 'RECO_COS' then -AmountInFunctionalCurrency
when 'REC_MARGIN' then -AmountInFunctionalCurrency
when 'BILL_REV' then -AmountInFunctionalCurrency
when 'SALES_DED' then -AmountInFunctionalCurrency
else AmountInFunctionalCurrency
end as fis_vfccur12) as AmountInFunctionalCurrency,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFunctionalCurrency
when 'RECO_COS' then AmountInFunctionalCurrency
when 'REC_MARGIN' then -AmountInFunctionalCurrency
when 'BILL_REV' then -AmountInFunctionalCurrency
when 'SALES_DED' then AmountInFunctionalCurrency
else AmountInFunctionalCurrency
end as fis_vfccur12) as InvertedAmtInFuncnlCurrency,
@ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
AccountingDocumentCategory,
@ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
_GL.GLAccount,
PostingDate,
CreationDate,
@ObjectModel.foreignKey.association: '_ChartOfAccounts'
_GL.ChartOfAccounts,
LedgerFiscalYear,
@ObjectModel.foreignKey.association: '_FinancialTransactionType'
FinancialTransactionType,
@ObjectModel.foreignKey.association: '_TransactionCurrency'
@Semantics.currencyCode:true
TransactionCurrency,
// Amount in Transaction Currency
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
cast(
case SemanticTag
when 'RECO_REV' then -AmountInTransactionCurrency
when 'RECO_COS' then -AmountInTransactionCurrency
when 'REC_MARGIN' then -AmountInTransactionCurrency
when 'BILL_REV' then -AmountInTransactionCurrency
when 'SALES_DED' then -AmountInTransactionCurrency
else AmountInTransactionCurrency
end as fis_wsl) as AmountInTransactionCurrency,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
cast(
case SemanticTag
when 'RECO_REV' then -AmountInTransactionCurrency
when 'RECO_COS' then AmountInTransactionCurrency
when 'REC_MARGIN' then -AmountInTransactionCurrency
when 'BILL_REV' then -AmountInTransactionCurrency
when 'SALES_DED' then AmountInTransactionCurrency
else AmountInTransactionCurrency
end as fis_wsl) as InvertedAmtInTransCrcy,
@ObjectModel.foreignKey.association: '_BaseUnit'
@Semantics.unitOfMeasure:true
BaseUnit,
@DefaultAggregation: #SUM
@Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
Quantity,
@DefaultAggregation: #SUM
@Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
FixedQuantity,
@ObjectModel.foreignKey.association: '_DebitCreditCode'
DebitCreditCode,
AssignmentReference,
@ObjectModel.foreignKey.association: '_PostingKey'
PostingKey,
AccountingDocCreatedByUser,
@ObjectModel.foreignKey.association: '_GLAccountType'
GLAccountType,
@ObjectModel.foreignKey.association: '_Plant'
Plant,
@ObjectModel.foreignKey.association: '_FinancialAccountType'
FinancialAccountType,
@ObjectModel.foreignKey.association: '_SpecialGLCode'
SpecialGLCode,
ClearingDate,
@ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
ClearingAccountingDocument,
@ObjectModel.foreignKey.association: '_BillingDocumentType'
BillingDocumentType,
OrganizationDivision,
CustomerSupplierIndustry,
@ObjectModel.foreignKey.association: '_BillToParty'
BillToParty,
@ObjectModel.foreignKey.association: '_ShipToParty'
ShipToParty,
cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
SourceReferenceDocument,
SourceReferenceDocumentItem,
@ObjectModel.foreignKey.association: '_OperatingConcern'
cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
AccountingDocumentItem,
TransactionTypeDetermination,
@ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
@ObjectModel.foreignKey.association: '_AccountingDocumentType'
AccountingDocumentType,
@ObjectModel.foreignKey.association: '_ReferenceDocumentType'
ReferenceDocumentType,
FiscalYearVariant,
_DocumentFiscalCalendarDate.FiscalPeriodStartDate,
cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
cast(
cast(
_DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
) as fins_fiscalyearperiod_je
) as JrnlEntrDerivdFiscalYearPeriod,
cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
FreeDefinedCurrency1,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency1
when 'RECO_COS' then -AmountInFreeDefinedCurrency1
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency1
when 'BILL_REV' then -AmountInFreeDefinedCurrency1
when 'SALES_DED' then -AmountInFreeDefinedCurrency1
else AmountInFreeDefinedCurrency1
end as fis_osl) as AmountInFreeDefinedCurrency1,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency1
when 'RECO_COS' then AmountInFreeDefinedCurrency1
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency1
when 'BILL_REV' then -AmountInFreeDefinedCurrency1
when 'SALES_DED' then AmountInFreeDefinedCurrency1
else AmountInFreeDefinedCurrency1
end as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
FreeDefinedCurrency2,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency2
when 'RECO_COS' then -AmountInFreeDefinedCurrency2
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency2
when 'BILL_REV' then -AmountInFreeDefinedCurrency2
when 'SALES_DED' then -AmountInFreeDefinedCurrency2
else AmountInFreeDefinedCurrency2
end as fis_vsl) as AmountInFreeDefinedCurrency2,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency2
when 'RECO_COS' then AmountInFreeDefinedCurrency2
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency2
when 'BILL_REV' then -AmountInFreeDefinedCurrency2
when 'SALES_DED' then AmountInFreeDefinedCurrency2
else AmountInFreeDefinedCurrency2
end as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
FreeDefinedCurrency3,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency3
when 'RECO_COS' then -AmountInFreeDefinedCurrency3
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency3
when 'BILL_REV' then -AmountInFreeDefinedCurrency3
when 'SALES_DED' then -AmountInFreeDefinedCurrency3
else AmountInFreeDefinedCurrency3
end as fis_bsl) as AmountInFreeDefinedCurrency3,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency3
when 'RECO_COS' then AmountInFreeDefinedCurrency3
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency3
when 'BILL_REV' then -AmountInFreeDefinedCurrency3
when 'SALES_DED' then AmountInFreeDefinedCurrency3
else AmountInFreeDefinedCurrency3
end as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
FreeDefinedCurrency4,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency4
when 'RECO_COS' then -AmountInFreeDefinedCurrency4
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency4
when 'BILL_REV' then -AmountInFreeDefinedCurrency4
when 'SALES_DED' then -AmountInFreeDefinedCurrency4
else AmountInFreeDefinedCurrency4
end as fis_csl) as AmountInFreeDefinedCurrency4,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency4
when 'RECO_COS' then AmountInFreeDefinedCurrency4
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency4
when 'BILL_REV' then -AmountInFreeDefinedCurrency4
when 'SALES_DED' then AmountInFreeDefinedCurrency4
else AmountInFreeDefinedCurrency4
end as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
FreeDefinedCurrency5,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency5
when 'RECO_COS' then -AmountInFreeDefinedCurrency5
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency5
when 'BILL_REV' then -AmountInFreeDefinedCurrency5
when 'SALES_DED' then -AmountInFreeDefinedCurrency5
else AmountInFreeDefinedCurrency5
end as fis_dsl) as AmountInFreeDefinedCurrency5,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency5
when 'RECO_COS' then AmountInFreeDefinedCurrency5
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency5
when 'BILL_REV' then -AmountInFreeDefinedCurrency5
when 'SALES_DED' then AmountInFreeDefinedCurrency5
else AmountInFreeDefinedCurrency5
end as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
FreeDefinedCurrency6,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency6
when 'RECO_COS' then -AmountInFreeDefinedCurrency6
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency6
when 'BILL_REV' then -AmountInFreeDefinedCurrency6
when 'SALES_DED' then -AmountInFreeDefinedCurrency6
else AmountInFreeDefinedCurrency6
end as fis_esl) as AmountInFreeDefinedCurrency6,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency6
when 'RECO_COS' then AmountInFreeDefinedCurrency6
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency6
when 'BILL_REV' then -AmountInFreeDefinedCurrency6
when 'SALES_DED' then AmountInFreeDefinedCurrency6
else AmountInFreeDefinedCurrency6
end as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
FreeDefinedCurrency7,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency7
when 'RECO_COS' then -AmountInFreeDefinedCurrency7
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency7
when 'BILL_REV' then -AmountInFreeDefinedCurrency7
when 'SALES_DED' then -AmountInFreeDefinedCurrency7
else AmountInFreeDefinedCurrency7
end as fis_fsl) as AmountInFreeDefinedCurrency7,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency7
when 'RECO_COS' then AmountInFreeDefinedCurrency7
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency7
when 'BILL_REV' then -AmountInFreeDefinedCurrency7
when 'SALES_DED' then AmountInFreeDefinedCurrency7
else AmountInFreeDefinedCurrency7
end as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
FreeDefinedCurrency8,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency8
when 'RECO_COS' then -AmountInFreeDefinedCurrency8
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency8
when 'BILL_REV' then -AmountInFreeDefinedCurrency8
when 'SALES_DED' then -AmountInFreeDefinedCurrency8
else AmountInFreeDefinedCurrency8
end as fis_gsl) as AmountInFreeDefinedCurrency8,
cast(
case SemanticTag
when 'RECO_REV' then -AmountInFreeDefinedCurrency8
when 'RECO_COS' then AmountInFreeDefinedCurrency8
when 'REC_MARGIN' then -AmountInFreeDefinedCurrency8
when 'BILL_REV' then -AmountInFreeDefinedCurrency8
when 'SALES_DED' then AmountInFreeDefinedCurrency8
else AmountInFreeDefinedCurrency8
end as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
IsCommitment,
// Added fields for DCL
ServiceDocument,
ServiceDocumentItem,
ServiceDocumentType,
ValuationArea,
Supplier,
SalesDocument,
FixedAsset,
MasterFixedAsset,
OrderID,
AssetClass,
_GL.FunctionalArea,
_ServiceDocument,
_Supplier,
_SalesDocument,
_FixedAsset,
_Order,
_FiscalYear,
_CompanyCodeCurrency,
_GlobalCurrency,
_SalesOrganization,
_Customer,
_SalesDistrict,
_Segment,
//_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
//_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
_DistributionChannel,
_BusinessTransactionType,
_BusinessArea,
_CostCenter,
_ControllingArea,
_CustomerSupplierCountry,
_SoldMaterial,
_CompanyCode,
_CustomerGroup,
_Ledger,
_SemanticTag,
_AccountingDocumentCategory,
_GLAccountInChartOfAccounts,
_ChartOfAccounts,
_LedgerFiscalYearForVariant,
_FiscalPeriodForVariant,
_FiscalYearPeriodForVariant,
_FinancialTransactionType,
_TransactionCurrency,
_BaseUnit,
_DebitCreditCode,
_PostingKey,
_GLAccountType,
_Plant,
_FinancialAccountType,
_SpecialGLCode,
_ClearingAccountingDocument,
_BillingDocumentType,
_BillToParty,
_ShipToParty,
_OperatingConcern,
_ControllingDebitCreditCode,
_AccountingDocumentType,
_ReferenceDocumentType,
_FiscalYearVariant,
_DocumentFiscalCalendarDate,
_GLAccountInCompanyCode,
_JournalEntry
}
where
SourceReferenceDocument <> ''
and
SourceReferenceDocumentType = 'VBAK'
and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
and AccountingDocumentCategory = 'P'
and IsCommitment <> 'X'
and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
// P_GLAccountLineItemSemTagFArea
and (
GLAccountType = 'S' // Secondary Costs
or GLAccountType = 'P' // Primary Costs or Revenue
or GLAccountType = 'N' // Nonoperating Expense or Income
)
// as select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagGLAccount
// on I_SemTagGLAccount.GLAccount = _GL.GLAccount
// and I_SemTagGLAccount.ValidityStartDate <= $session.system_date
// and I_SemTagGLAccount.ValidityEndDate >= $session.system_date
// and I_SemTagGLAccount.ChartOfAccounts = _GL.ChartOfAccounts
// and I_SemTagGLAccount.SemanticTag = 'RECO_REV'
// and (
// ( _GL.FunctionalArea = ''
// and I_SemTagGLAccount.IsFunctionalAreaPermitted = 'X'
// ) // Only line items without functional area permitted
// or I_SemTagGLAccount.IsFunctionalAreaPermitted = ''
// or I_SemTagGLAccount.IsFunctionalAreaPermitted is null
// )
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL // slow
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast (AmountInGlobalCurrency * (-1) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast (AmountInCompanyCodeCurrency * (-1) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast (AmountInGlobalCurrency * (-1) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and (SemanticTag = 'RECO_REV')
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagGLAccount
// on I_SemTagGLAccount.GLAccount = _GL.GLAccount
// and I_SemTagGLAccount.ValidityStartDate <= $session.system_date
// and I_SemTagGLAccount.ValidityEndDate >= $session.system_date
// and I_SemTagGLAccount.ChartOfAccounts = _GL.ChartOfAccounts
// and I_SemTagGLAccount.SemanticTag = 'BILL_REV'
// and (
// ( _GL.FunctionalArea = ''
// and I_SemTagGLAccount.IsFunctionalAreaPermitted = 'X'
// ) // Only line items without functional area permitted
// or I_SemTagGLAccount.IsFunctionalAreaPermitted = ''
// or I_SemTagGLAccount.IsFunctionalAreaPermitted is null
// )
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( AmountInGlobalCurrency * (-1) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and (SemanticTag = 'BILL_REV')
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagGLAccount
// on I_SemTagGLAccount.GLAccount = _GL.GLAccount
// and I_SemTagGLAccount.ValidityStartDate <= $session.system_date
// and I_SemTagGLAccount.ValidityEndDate >= $session.system_date
// and I_SemTagGLAccount.ChartOfAccounts = _GL.ChartOfAccounts
// and I_SemTagGLAccount.SemanticTag = 'RECO_COS'
// and (
// ( _GL.FunctionalArea = ''
// and I_SemTagGLAccount.IsFunctionalAreaPermitted = 'X'
// ) // Only line items without functional area permitted
// or I_SemTagGLAccount.IsFunctionalAreaPermitted = ''
// or I_SemTagGLAccount.IsFunctionalAreaPermitted is null
// )
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( AmountInCompanyCodeCurrency * (-1) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( AmountInGlobalCurrency * (-1) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast (AmountInCompanyCodeCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast (AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast (AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast (AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast (AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast (AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast (AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast (AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast (AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast (AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast (AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and SemanticTag = 'RECO_COS'
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagGLAccount
// on I_SemTagGLAccount.GLAccount = _GL.GLAccount
// and I_SemTagGLAccount.ValidityStartDate <= $session.system_date
// and I_SemTagGLAccount.ValidityEndDate >= $session.system_date
// and I_SemTagGLAccount.ChartOfAccounts = _GL.ChartOfAccounts
// and I_SemTagGLAccount.SemanticTag = 'SALES_DED'
// and (
// ( _GL.FunctionalArea = ''
// and I_SemTagGLAccount.IsFunctionalAreaPermitted = 'X'
// ) // Only line items without functional area permitted
// or I_SemTagGLAccount.IsFunctionalAreaPermitted = ''
// or I_SemTagGLAccount.IsFunctionalAreaPermitted is null
// )
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( AmountInGlobalCurrency * (-1) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( AmountInCompanyCodeCurrency * (-1) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast (AmountInCompanyCodeCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast (AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast (AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast (AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast (AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast (AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast (AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast (AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast (AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast (AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast (AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and SemanticTag = 'SALES_DED'
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagGLAccount
// on I_SemTagGLAccount.GLAccount = _GL.GLAccount
// and I_SemTagGLAccount.ValidityStartDate <= $session.system_date
// and I_SemTagGLAccount.ValidityEndDate >= $session.system_date
// and I_SemTagGLAccount.ChartOfAccounts = _GL.ChartOfAccounts
// and I_SemTagGLAccount.SemanticTag = 'REC_MARGIN'
// and (
// ( _GL.FunctionalArea = ''
// and I_SemTagGLAccount.IsFunctionalAreaPermitted = 'X'
// ) // Only line items without functional area permitted
// or I_SemTagGLAccount.IsFunctionalAreaPermitted = ''
// or I_SemTagGLAccount.IsFunctionalAreaPermitted is null
// )
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( AmountInCompanyCodeCurrency * (-1) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( AmountInGlobalCurrency * (-1) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast((-1) * AmountInCompanyCodeCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast((-1) * AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and SemanticTag = 'REC_MARGIN'
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
//
//
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagFuncArea
// on I_SemTagFuncArea.FunctionalArea = _GL.FunctionalArea
// and I_SemTagFuncArea.ValidityStartDate <= $session.system_date
// and I_SemTagFuncArea.ValidityEndDate >= $session.system_date
// and I_SemTagFuncArea.SemanticTag = 'RECO_REV'
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL // slow
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast (AmountInCompanyCodeCurrency * (-1) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast (AmountInGlobalCurrency * (-1) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast (AmountInCompanyCodeCurrency * (-1) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast (AmountInGlobalCurrency * (-1) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and (SemanticTag = 'RECO_REV')
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagFuncArea
// on I_SemTagFuncArea.FunctionalArea = _GL.FunctionalArea
// and I_SemTagFuncArea.ValidityStartDate <= $session.system_date
// and I_SemTagFuncArea.ValidityEndDate >= $session.system_date
// and I_SemTagFuncArea.SemanticTag = 'BILL_REV'
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( AmountInGlobalCurrency * (-1) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast ((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast ((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and (SemanticTag = 'BILL_REV')
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagFuncArea
// on I_SemTagFuncArea.FunctionalArea = _GL.FunctionalArea
// and I_SemTagFuncArea.ValidityStartDate <= $session.system_date
// and I_SemTagFuncArea.ValidityEndDate >= $session.system_date
// and I_SemTagFuncArea.SemanticTag = 'RECO_COS'
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( AmountInCompanyCodeCurrency * (-1) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( AmountInGlobalCurrency * (-1) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast (AmountInCompanyCodeCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast (AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast (AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast (AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast (AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast (AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast (AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast (AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast (AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast (AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast (AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and SemanticTag = 'RECO_COS'
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagFuncArea
// on I_SemTagFuncArea.FunctionalArea = _GL.FunctionalArea
// and I_SemTagFuncArea.ValidityStartDate <= $session.system_date
// and I_SemTagFuncArea.ValidityEndDate >= $session.system_date
// and I_SemTagFuncArea.SemanticTag = 'SALES_DED'
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( AmountInGlobalCurrency * (-1) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( AmountInCompanyCodeCurrency * (-1) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast (AmountInCompanyCodeCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast (AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast ((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast (AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast ((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast (AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast ((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast (AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast ((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast (AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast ((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast (AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast ((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast (AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast ((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast (AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast (AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast (AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and SemanticTag = 'SALES_DED'
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//
//
// union all select from
// I_GLAccountLineItem as _GL
// inner join I_SemTagFuncArea
// on I_SemTagFuncArea.FunctionalArea = _GL.FunctionalArea
// and I_SemTagFuncArea.ValidityStartDate <= $session.system_date
// and I_SemTagFuncArea.ValidityEndDate >= $session.system_date
// and I_SemTagFuncArea.SemanticTag = 'REC_MARGIN'
//
// //P_GLAccountLineItemSemTagGLACC as _GL
// //P_GLAccountLineItemSemTagUnion as _GL
// //I_GLAccountLineItemSemTag as _GL
//
// association [1..1] to I_FiscalCalendarDate as _DocumentFiscalCalendarDate
// on $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and
// $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant
//
// association [0..1] to I_SalesDocumentBasic as _SalesDocumentBasic on $projection.SourceReferenceDocument = _SalesDocumentBasic.SalesDocument
//
// association [0..1] to I_Product as _SoldMaterial on $projection.SoldMaterial = _SoldMaterial.Product
//
//{
// key Ledger,
// key SourceLedger,
// key CompanyCode,
// key FiscalYear,
// key AccountingDocument,
// key LedgerGLLineItem,
//
// key GLAccountHierarchy,
//
// @ObjectModel.foreignKey.association: '_SemanticTag'
// key SemanticTag,
// key ValidityStartDate,
// key ValidityEndDate,
//
// DocumentDate,
// SalesOrganization,
// CustomerGroup,
// Customer,
// _FiscalCalendarDate.FiscalQuarter as FiscalQuarter,
// FiscalPeriod,
// CompanyCodeCurrency,
// GlobalCurrency,
//
// // check P_GLAccountLineItemSemTag
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_recrevn) as RecognizedRevnAmtInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_hsl) as RevenueAmountInCompanyCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fis_revenue_ksl) as RevenueInGlobalCurrency,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_reccogs) as RecognizedCOGSAmtInCCCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_cogs) as CostOfGoodsSoldAmtInGlobCrcy,
// cast ( AmountInCompanyCodeCurrency * (-1) as fins_trr_recmargin) as RecognizedMarginAmtInCCCrcy,
// cast ( AmountInGlobalCurrency * (-1) as fins_trr_recmargin) as RecognizedMarginAmount,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmountInGlobCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_sales_deduction) as SalesDeductionAmtInCoCodeCrcy,
// cast ( cast ('0' as abap.curr( 23,2)) as fins_trr_actrevn) as RecognizableRevnAmtInGlobCrcy,
//
// cast(SoldProductGroup as fins_matkl_pa) as MaterialGroup,
// ProfitCenter,
// ControllingArea,
//
// SalesDistrict,
// Segment,
// cast(SourceReferenceDocument as vdm_sales_order) as SalesOrder,
// cast(SourceReferenceDocumentItem as fac_kdpos) as SalesOrderItem,
// DistributionChannel,
//
//
// SoldProduct as SoldMaterial,
// _SalesDocumentBasic.OrganizationDivision as Division,
// _SalesDocumentBasic.SalesDocumentType as OrderType,
//
// BusinessTransactionType,
// BusinessArea,
// CostCenter,
// CustomerSupplierCountry,
// FiscalYearPeriod,
//
//// Amount in CompanyCode Currency
// cast ((-1) * AmountInCompanyCodeCurrency as fis_hsl) as AmountInCompanyCodeCurrency,
// cast((-1) * AmountInCompanyCodeCurrency as fis_hsl) as InvertedAmtInCoCodeCurrency,
//
//// Amount in Global Currency
// cast((-1) * AmountInGlobalCurrency as fis_ksl) as InvertedAmountInGlobalCurrency,
// cast((-1) * AmountInGlobalCurrency as fis_ksl) as AmountInGlobalCurrency,
//
//
// @ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
// AccountingDocumentCategory,
//
// @ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
// _GL.GLAccount,
//
// PostingDate,
// CreationDate,
// @ObjectModel.foreignKey.association: '_ChartOfAccounts'
// _GL.ChartOfAccounts,
// @ObjectModel.foreignKey.association: '_LedgerFiscalYear'
// LedgerFiscalYear,
// @ObjectModel.foreignKey.association: '_FinancialTransactionType'
// FinancialTransactionType,
// @ObjectModel.foreignKey.association: '_TransactionCurrency'
// @Semantics.currencyCode:true
// TransactionCurrency,
//
//// Amount in Transaction Currency
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as AmountInTransactionCurrency,
//
// @DefaultAggregation: #SUM
// @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
// cast ((-1) * AmountInTransactionCurrency as fis_wsl) as InvertedAmtInTransCrcy,
//
// @ObjectModel.foreignKey.association: '_BaseUnit'
// @Semantics.unitOfMeasure:true
// BaseUnit,
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// Quantity,
//
// @DefaultAggregation: #SUM
// @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
// FixedQuantity,
// @ObjectModel.foreignKey.association: '_DebitCreditCode'
// DebitCreditCode,
// AssignmentReference,
// @ObjectModel.foreignKey.association: '_PostingKey'
// PostingKey,
// AccountingDocCreatedByUser,
// @ObjectModel.foreignKey.association: '_GLAccountType'
// GLAccountType,
// @ObjectModel.foreignKey.association: '_Plant'
// Plant,
// @ObjectModel.foreignKey.association: '_FinancialAccountType'
// FinancialAccountType,
// @ObjectModel.foreignKey.association: '_SpecialGLCode'
// SpecialGLCode,
// ClearingDate,
// @ObjectModel.foreignKey.association: '_ClearingAccountingDocument'
// ClearingAccountingDocument,
// @ObjectModel.foreignKey.association: '_BillingDocumentType'
// BillingDocumentType,
// OrganizationDivision,
// CustomerSupplierIndustry,
// @ObjectModel.foreignKey.association: '_BillToParty'
// BillToParty,
// @ObjectModel.foreignKey.association: '_ShipToParty'
// ShipToParty,
// cast(SourceReferenceDocumentType as fins_src_awtyp) as SourceReferenceDocumentType,
// SourceReferenceDocument,
// SourceReferenceDocumentItem,
// @ObjectModel.foreignKey.association: '_OperatingConcern'
// cast(_GL.OperatingConcern as fins_erkrs preserving type) as OperatingConcern,
//
// AccountingDocumentItem,
// TransactionTypeDetermination,
// @ObjectModel.foreignKey.association: '_ControllingDebitCreditCode'
// cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) as ControllingDebitCreditCode,
// @ObjectModel.foreignKey.association: '_AccountingDocumentType'
// AccountingDocumentType,
// @ObjectModel.foreignKey.association: '_ReferenceDocumentType'
// ReferenceDocumentType,
//
// FiscalYearVariant,
// _DocumentFiscalCalendarDate.FiscalPeriodStartDate,
// cast(_DocumentFiscalCalendarDate.FiscalYear as fins_gjahr_je) as JrnlEntrDerivedFiscalYear,
// cast(_DocumentFiscalCalendarDate.FiscalQuarter as fins_fscalquarter_je) as JrnlEntrDerivedFiscalQuarter,
// cast(_DocumentFiscalCalendarDate.FiscalPeriod as fins_fiscalperiod_je) as JrnlEntrDerivedFiscalPeriod,
// cast(
// cast(
// _DocumentFiscalCalendarDate.FiscalYearPeriod as abap.char( 7 )
// ) as fins_fiscalyearperiod_je
// ) as JrnlEntrDerivdFiscalYearPeriod,
//
// cast(JrnlEntryItemObsoleteReason as fins_obs_reason) as JrnlEntryItemObsoleteReason,
//
// FreeDefinedCurrency1,
// cast((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as AmountInFreeDefinedCurrency1,
// cast((-1) * AmountInFreeDefinedCurrency1 as fis_osl) as InvertedAmtInFreeDefinedCrcy1,
//
// FreeDefinedCurrency2,
// cast((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as AmountInFreeDefinedCurrency2,
// cast((-1) * AmountInFreeDefinedCurrency2 as fis_vsl) as InvertedAmtInFreeDefinedCrcy2,
//
// FreeDefinedCurrency3,
// cast((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as AmountInFreeDefinedCurrency3,
// cast((-1) * AmountInFreeDefinedCurrency3 as fis_bsl) as InvertedAmtInFreeDefinedCrcy3,
//
// FreeDefinedCurrency4,
// cast((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as AmountInFreeDefinedCurrency4,
// cast((-1) * AmountInFreeDefinedCurrency4 as fis_csl) as InvertedAmtInFreeDefinedCrcy4,
//
// FreeDefinedCurrency5,
// cast((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as AmountInFreeDefinedCurrency5,
// cast((-1) * AmountInFreeDefinedCurrency5 as fis_dsl) as InvertedAmtInFreeDefinedCrcy5,
//
// FreeDefinedCurrency6,
// cast((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as AmountInFreeDefinedCurrency6,
// cast((-1) * AmountInFreeDefinedCurrency6 as fis_esl) as InvertedAmtInFreeDefinedCrcy6,
//
// FreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as AmountInFreeDefinedCurrency7,
// cast((-1) * AmountInFreeDefinedCurrency7 as fis_fsl) as InvertedAmtInFreeDefinedCrcy7,
//
// FreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as AmountInFreeDefinedCurrency8,
// cast((-1) * AmountInFreeDefinedCurrency8 as fis_gsl) as InvertedAmtInFreeDefinedCrcy8,
//
//
// @Aggregation.default: #COUNT_DISTINCT
// @Aggregation.referenceElement: ['SalesOrder']
// cast( 1 as abap.int4 ) as NumberOfSalesOrders,
//
//// Added fields for DCL
//
// ServiceDocument,
// ServiceDocumentItem,
// ServiceDocumentType,
// ValuationArea,
// Supplier,
// SalesDocument,
// FixedAsset,
// MasterFixedAsset,
// OrderID,
// AssetClass,
// _ServiceDocument,
// _Supplier,
// _CurrentCostCenter,
// _SalesDocument,
// _FixedAsset,
// _Order,
////
// _FiscalYear,
// _CompanyCodeCurrency,
// _GlobalCurrency,
// _SalesOrganization,
// _Customer,
// _SalesDistrict,
// _Segment,
// //_SalesOrder, // we are using SourceReferenceDocument as SalesOrder
// //_SalesOrderItem, // we are using SourceReferenceDocumentItem as SalesOrderItem
// _DistributionChannel,
// _BusinessTransactionType,
// _BusinessArea,
// _CostCenter,
// _ControllingArea,
// _CustomerSupplierCountry,
// _SoldMaterial,
// _CompanyCode,
// _CustomerGroup,
// _Ledger,
// _SemanticTag,
// _AccountingDocumentCategory,
//
// _GLAccountInChartOfAccounts,
// _ChartOfAccounts,
// _LedgerFiscalYear,
// _LedgerFiscalYearForVariant,
// _FiscalPeriod,
// _FiscalPeriodForVariant,
// _FiscalYearPeriod,
// _FiscalYearPeriodForVariant,
// _FinancialTransactionType,
// _TransactionCurrency,
// _BaseUnit,
// _DebitCreditCode,
// _PostingKey,
// _GLAccountType,
// _Plant,
// _FinancialAccountType,
// _SpecialGLCode,
// _ClearingAccountingDocument,
// _BillingDocumentType,
// _BillToParty,
// _ShipToParty,
// _OperatingConcern,
// _ControllingDebitCreditCode,
// _AccountingDocumentType,
// _ReferenceDocumentType,
//
// _FiscalYearVariant,
// _DocumentFiscalCalendarDate,
// _CurrentProfitCenter,
// _GLAccountInCompanyCode,
// _SourceLedger,
// _JournalEntry
//}
// where
// // ValidityStartDate <= $parameters.P_KeyDate
// //and ValidityEndDate >= $parameters.P_KeyDate
//
// //and
// //SourceReferenceDocument <> ''
// //and
// SourceReferenceDocumentType = 'VBAK'
// and BusinessTransactionType <> 'TBRR' // * Order Entry: Ledger = <Prediction Ledger> and SourceLedger = <Prediction Ledger> and SalesOrder <> '' and BusinessTransactionType <> 'TBRR'
// and AccountingDocumentCategory = 'P'
// //and SemanticTag = 'REC_MARGIN'
// and IsCommitment <> 'X'
// and (JrnlEntryItemObsoleteReason = ' ' or JrnlEntryItemObsoleteReason = '1' or JrnlEntryItemObsoleteReason = '2' or JrnlEntryItemObsoleteReason = '3')
//