@AbapCatalog.sqlViewName: 'PRUFINSTMNTITEM'
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.viewType: #CONSUMPTION
@VDM.private: true
@AbapCatalog.compiler.compareFilter: true
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.authorizationCheck: #CHECK
@AccessControl.personalData.blocking:#BLOCKED_DATA_INCLUDED
@EndUserText.label: 'Financial Statement for Russia'
define view P_RU_FinancialStatementItem
with parameters
P_FinancialStatementHierarchy : hryid, //BRFB
P_StatryRptgEntity : srf_reporting_entity,
P_StatryRptCategory : srf_rep_cat_id,
P_StatryRptRunID : srf_report_run_id,
P_AlternativeGLAccountIsUsed : char1,
@Environment.systemField: #SYSTEM_LANGUAGE
P_Language : sylangu,
P_Ledger : fins_ledger
as select from I_RU_FinStmntRptgItems as FIRUD
join I_FinStmntExpandedHierNode as Hierarchy on Hierarchy.FinancialStatementLeafItem = FIRUD.FinancialStatementLeafItem
and Hierarchy.FinancialStatementHierarchy = $parameters.P_FinancialStatementHierarchy
and Hierarchy.ValidityEndDate = '99991231'
and Hierarchy.NodeType = 'L'
and Hierarchy.ParentNode != '00NOTASSGND'
// and Hierarchy.GLAccountInfo = FIRUD.GLAccountInfo
left outer join I_GLAccountLineItem as AccountingDocumentItem on FIRUD.AccountingDocument = AccountingDocumentItem.AccountingDocument
and FIRUD.FiscalYear = AccountingDocumentItem.FiscalYear
and FIRUD.CompanyCode = AccountingDocumentItem.CompanyCode
and AccountingDocumentItem.Ledger = $parameters.P_Ledger
and AccountingDocumentItem.LedgerGLLineItem = FIRUD.LedgerGLLineItem
left outer join I_GLAccountInCompanyCode as GLAccountInCompanyCode on FIRUD.CompanyCode = GLAccountInCompanyCode.CompanyCode
and Hierarchy.FinStatementHierarchyNodeValue = GLAccountInCompanyCode.GLAccount
left outer join I_GLAccountInCompanyCode as AltGLAccountInCompanyCode on FIRUD.CompanyCode = AltGLAccountInCompanyCode.CompanyCode
and Hierarchy.FinStatementHierarchyNodeValue = AltGLAccountInCompanyCode.AlternativeGLAccount
and AccountingDocumentItem.GLAccount = AltGLAccountInCompanyCode.GLAccount
left outer join P_RU_FinancialStatementDC( P_FinancialStatementHierarchy: $parameters.P_FinancialStatementHierarchy,
P_StatryRptgEntity: $parameters.P_StatryRptgEntity,
P_StatryRptCategory: $parameters.P_StatryRptCategory,
P_StatryRptRunID: $parameters.P_StatryRptRunID
) on Hierarchy.ParentNode = P_RU_FinancialStatementDC.ParentNode
and Hierarchy.FinancialStatementLeafItem = P_RU_FinancialStatementDC.FinancialStatementLeafItem
and
//P_RU_FinancialStatementDC.AccountingDocument = FIRUD.AccountingDocument and
//P_RU_FinancialStatementDC.CompanyCode = FIRUD.CompanyCode and
P_RU_FinancialStatementDC.FiscalYear = FIRUD.FiscalYear
join I_FinancialStatementHierNodeT as _ParentText on _ParentText.FinancialStatementHierarchy = Hierarchy.FinancialStatementHierarchy
and _ParentText.HierarchyNode = Hierarchy.ParentNode
and _ParentText.ValidityEndDate = '99991231'
and _ParentText.Language = $session.system_language
//association [0..1]
association [1..1] to I_CompanyCode as _CompanyCode on $projection.CompanyCode = _CompanyCode.CompanyCode
association [0..1] to I_FiscalYearForCompanyCode as _FiscalYear on $projection.FiscalYear = _FiscalYear.FiscalYear
and $projection.CompanyCode = _FiscalYear.CompanyCode
association [0..1] to I_ChartOfAccounts as _ChartOfAccounts on $projection.ChartOfAccounts = _ChartOfAccounts.ChartOfAccounts
// association [0..1] to I_GLAccountInChartOfAccounts as _GLAccountInChartOfAccounts on $projection.ChartOfAccounts = _GLAccountInChartOfAccounts.ChartOfAccounts
// and $projection.GLAccount = _GLAccountInChartOfAccounts.GLAccount
// association [0..1] to I_GLAccountInCompanyCode as _GLAccountInCompanyCode on $projection.CompanyCode = _GLAccountInCompanyCode.CompanyCode
// and (
// (
// $projection.GLAccount = _GLAccountInCompanyCode.GLAccount
// //and $projection.AlternativeGLAccount is null
// and $projection.AlternativeGLAccountIsUsed <> '1'
// )
// or(
// $projection.GLAccount = _GLAccountInCompanyCode.AlternativeGLAccount
// and $projection.RealGLAccount = _GLAccountInCompanyCode.GLAccount
// //and $projection.AlternativeGLAccount is not null
// and $projection.AlternativeGLAccountIsUsed = '1'
// )
// )
// //and $projection.RealGLAccount = _GLAccountInCompanyCode.GLAccount
association [1..1] to I_GLAccountLineItem as _GLAccountLineItem on $projection.AccountingDocument = _GLAccountLineItem.AccountingDocument
and $projection.FiscalYear = _GLAccountLineItem.FiscalYear
and $projection.CompanyCode = _GLAccountLineItem.CompanyCode
and _GLAccountLineItem.Ledger = $parameters.P_Ledger
and _GLAccountLineItem.LedgerGLLineItem = FIRUD.LedgerGLLineItem
and (
GLAccountInCompanyCode.GLAccount = _GLAccountLineItem.GLAccount
and AltGLAccountInCompanyCode.AlternativeGLAccount is null
or AltGLAccountInCompanyCode.AlternativeGLAccount = _GLAccountLineItem.AlternativeGLAccount
)
//and _GLAccountLineItem.SourceLedger = $parameters.P_Ledger
//association [0..1] to I_BusinessArea as _BusinessArea on $projection.businessarea = _BusinessArea.BusinessArea
{
Hierarchy.FinancialStatementHierarchy,
Hierarchy.HierarchyNode,
Hierarchy.ValidityEndDate,
@ObjectModel.foreignKey.association: '_CompanyCode'
FIRUD.CompanyCode,
FIRUD.FiscalYear,
FIRUD.AccountingDocument,
// FIRUD.GlAccountInfo,
LTRIM( Hierarchy.ParentNode, '0' ) as ParentNode,
Hierarchy.ParentNode as HierarchyParentNode,
@ObjectModel.foreignKey.association: '_FinancialStatementLeafItem'
Hierarchy.FinancialStatementLeafItem,
Hierarchy.NodeType,
Hierarchy.FinStatementHierarchyNodeValue,
Hierarchy.FunctionalAreaIsUsed,
Hierarchy.DebitCreditCode,
@ObjectModel.foreignKey.association: '_ChartOfAccounts'
cast( substring(Hierarchy.ChartOfAccounts,1,4) as ktopl preserving type ) as ChartOfAccounts,
//@ObjectModel.foreignKey.association: '_GLAccountInCompanyCode'
case $parameters.P_AlternativeGLAccountIsUsed
when '1' then
AltGLAccountInCompanyCode.AlternativeGLAccount
else GLAccountInCompanyCode.GLAccount
end as GLAccount,
case $parameters.P_AlternativeGLAccountIsUsed
when '1' then
AltGLAccountInCompanyCode.GLAccount
else GLAccountInCompanyCode.GLAccount
end as RealGLAccount,
AltGLAccountInCompanyCode.AlternativeGLAccount as AlternativeGLAccount,
@Semantics.currencyCode:true
FIRUD.Currency as Currency,
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'Currency'
@EndUserText.label: 'Period Balance Amount'
case when Hierarchy.DebitCreditCode is null or Hierarchy.DebitCreditCode = ' '
then FIRUD.PeriodBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy > 0
then FIRUD.PeriodBalAmtInDspCrcy //P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy < 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy > 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy < 0
then FIRUD.PeriodBalAmtInDspCrcy //P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy
else
0
end as PeriodBalAmtInDspCrcy, // Period Balance
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'Currency'
case when Hierarchy.DebitCreditCode is null or Hierarchy.DebitCreditCode = ' '
then FIRUD.DebitAmountInDisplayCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy > 0
then FIRUD.DebitAmountInDisplayCrcy //P_RU_FinancialStatementDC.DebitAmountInDisplayCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy < 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy > 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy < 0
then FIRUD.DebitAmountInDisplayCrcy //P_RU_FinancialStatementDC.DebitAmountInDisplayCrcy // Debit period Balance
else
0
end as DebitAmountInDisplayCrcy,
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'Currency'
case when Hierarchy.DebitCreditCode is null or Hierarchy.DebitCreditCode = ' '
then FIRUD.CreditAmountInDisplayCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy > 0
then FIRUD.CreditAmountInDisplayCrcy //P_RU_FinancialStatementDC.CreditAmountInDisplayCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy < 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy > 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.PeriodBalAmtInDspCrcy < 0
then FIRUD.CreditAmountInDisplayCrcy //P_RU_FinancialStatementDC.CreditAmountInDisplayCrcy // Credit period Balance
else
0
end as CreditAmountInDisplayCrcy,
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'Currency'
case when Hierarchy.DebitCreditCode is null or Hierarchy.DebitCreditCode = ' '
then FIRUD.YearlyBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.YearlyBalAmtInDspCrcy > 0
then FIRUD.YearlyBalAmtInDspCrcy //P_RU_FinancialStatementDC.YearlyBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.YearlyBalAmtInDspCrcy < 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.YearlyBalAmtInDspCrcy > 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.YearlyBalAmtInDspCrcy < 0
then FIRUD.YearlyBalAmtInDspCrcy //P_RU_FinancialStatementDC.YearlyBalAmtInDspCrcy
else
0
end as YearlyBalAmtInDspCrcy, //'Year Opening Balance Amount'
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'Currency'
case when Hierarchy.DebitCreditCode is null or Hierarchy.DebitCreditCode = ' '
then FIRUD.StartingBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.StartingBalAmtInDspCrcy > 0
then FIRUD.StartingBalAmtInDspCrcy //P_RU_FinancialStatementDC.StartingBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.StartingBalAmtInDspCrcy < 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.StartingBalAmtInDspCrcy > 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.StartingBalAmtInDspCrcy < 0
then FIRUD.StartingBalAmtInDspCrcy //P_RU_FinancialStatementDC.StartingBalAmtInDspCrcy
else
0
end as StartingBalAmtInDspCrcy, //'Opening Balance Amount'
@Semantics.amount.currencyCode: 'Currency'
@DefaultAggregation: #SUM
case when Hierarchy.DebitCreditCode is null or Hierarchy.DebitCreditCode = ' '
then FIRUD.EndingBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.EndingBalAmtInDspCrcy > 0
then FIRUD.EndingBalAmtInDspCrcy //P_RU_FinancialStatementDC.EndingBalAmtInDspCrcy
when Hierarchy.DebitCreditCode = 'S' and P_RU_FinancialStatementDC.EndingBalAmtInDspCrcy < 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.EndingBalAmtInDspCrcy > 0
then 0
when Hierarchy.DebitCreditCode = 'H' and P_RU_FinancialStatementDC.EndingBalAmtInDspCrcy < 0
then FIRUD.EndingBalAmtInDspCrcy //P_RU_FinancialStatementDC.EndingBalAmtInDspCrcy
else
0
end as EndingBalAmtInDspCrcy, //'Closing Balance Amount'
//Hierarchy._Text[1:Language = $parameters.P_Language].HierarchyNodeText,
_FinancialStatementLeafItem,
_CompanyCode,
_FiscalYear,
_ChartOfAccounts,
//_GLAccountInChartOfAccounts,
//_GLAccountInCompanyCode,
_GLAccountLineItem.ControllingArea as ControllingArea,
_GLAccountLineItem.Segment as Segment,
_GLAccountLineItem.ProfitCenter as ProfitCenter,
_GLAccountLineItem.CostCenter as CostCenter,
_GLAccountLineItem.BusinessArea as BusinessArea,
_GLAccountLineItem.Supplier as Supplier,
_GLAccountLineItem.Customer as Customer,
_GLAccountLineItem.AccountingDocumentType as AccountingDocumentType,
_GLAccountLineItem.FiscalPeriod as FiscalPeriod,
_GLAccountLineItem.MasterFixedAsset as MasterFixedAsset,
_GLAccountLineItem.FixedAsset as FixedAsset,
_GLAccountLineItem.AssetClass as AssetClass,
_GLAccountLineItem.AssignmentReference as AssignmentReference,
_GLAccountLineItem.Plant as Plant,
_GLAccountLineItem.InventoryValuationType as InventoryValuationType,
_GLAccountLineItem.ValuationArea as ValuationArea,
_GLAccountLineItem.Product as Product,
_GLAccountLineItem.FunctionalArea as FunctionalArea,
'' as FinancialStatementExplanation,
_GLAccountLineItem.Material as Material,
FIRUD.LedgerGLLineItem,
_ParentText.HierarchyNodeText,
_GLAccountLineItem._Customer,
_GLAccountLineItem._Supplier,
_GLAccountLineItem._ProfitCenter,
_GLAccountLineItem._CostCenter,
_GLAccountLineItem._BusinessArea,
_GLAccountLineItem._FunctionalArea,
_GLAccountLineItem._ControllingArea,
_GLAccountLineItem._Segment,
_GLAccountLineItem._AccountingDocumentType,
//_GLAccountLineItem._MasterFixedAsset,
//_GLAccountLineItem._FixedAsset,
_GLAccountLineItem._InventoryValuationType,
_GLAccountLineItem._Product,
//_GLAccountLineItem._FixedAsset,
_GLAccountLineItem._PurReqValuationArea,
_GLAccountLineItem._Material,
_GLAccountLineItem._Customer.AuthorizationGroup as CustomerFinsAuthorizationGrp,
_GLAccountLineItem._Supplier.AuthorizationGroup as SupplierFinsAuthorizationGrp,
$parameters.P_AlternativeGLAccountIsUsed as AlternativeGLAccountIsUsed
}
where
FIRUD.StatryRptgEntity = $parameters.P_StatryRptgEntity
and FIRUD.StatryRptCategory = $parameters.P_StatryRptCategory
and FIRUD.StatryRptRunID = $parameters.P_StatryRptRunID
and FIRUD.FinancialStatementFormType = $parameters.P_FinancialStatementHierarchy
//and Hierarchy._ParentText [1:Language = $parameters.P_Language].ValidityEndDate = '99991231'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CUSTOMER",
"I_FINANCIALSTATEMENTHIERNODET",
"I_FINSTMNTEXPANDEDHIERNODE",
"I_GLACCOUNTINCOMPANYCODE",
"I_GLACCOUNTLINEITEM",
"I_RU_FINSTMNTRPTGITEMS",
"I_SUPPLIER",
"P_RU_FINANCIALSTATEMENTDC"
],
"ASSOCIATED":
[
"I_ACCOUNTINGDOCUMENTTYPE",
"I_BUSINESSAREA",
"I_CHARTOFACCOUNTS",
"I_COMPANYCODE",
"I_CONTROLLINGAREA",
"I_COSTCENTER",
"I_CUSTOMER",
"I_FINANCIALSTATEMENTLEAFITEM",
"I_FISCALYEARFORCOMPANYCODE",
"I_FUNCTIONALAREA",
"I_GLACCOUNTLINEITEM",
"I_INVENTORYVALUATIONTYPE",
"I_MATERIAL",
"I_PRODUCT",
"I_PROFITCENTER",
"I_PURREQVALUATIONAREA",
"I_SEGMENT",
"I_SUPPLIER"
],
"BASE":
[
"I_FINSTMNTEXPANDEDHIERNODE",
"I_GLACCOUNTLINEITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/