@AbapCatalog.sqlViewName: 'PMFGORDPLNSTDCU1'
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.buffering.status: #NOT_ALLOWED
@Metadata.ignorePropagatedAnnotations: true
@VDM.private:true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
//@EndUserText.label: 'Plan and Standard Costs Cube for Manufacturing Orders'
//Planning category to distinguish order plan costs and standard costs
//No fiscal year period restricition, for target costs calculation
define view P_COMfgOrderPlanStdCube1
with parameters
P_FromFiscalYearPeriod : fis_jahrper,
P_ToFiscalYearPeriod : fis_jahrper
as select from I_FinancialPlanningEntryItem as _PlanningEntryItem
inner join I_Ledger as _Ledger on _PlanningEntryItem.Ledger = _Ledger.Ledger and _Ledger.IsLeadingLedger = 'X'
inner join I_MfgOrdPlngCat as _PlngCat on _PlanningEntryItem.PlanningCategory = _PlngCat.PlanningCategory
{
key '' as ControllingObject,
key '' as ControllingObjectForOutput,
key ControllingDebitCreditCode,
key _PlanningEntryItem.PlanningCategory, // plan cost & standard cost category
key OrderID,
key OrderItem,
//units
key CostSourceUnit,
key GlobalCurrency,
key CompanyCodeCurrency,
// Lot-size independent indicator for target cost calculation
key FiscalYearPeriod,
CompanyCode,
Plant,
ProducedProduct,
IsLotSizeIndependent,
PlngCatIsForOrdReltdPlnCost,
PlngCatIsForMatlCostEstPlnCost,
sum(case when ControllingDebitCreditCode = 'A' or ControllingDebitCreditCode = 'L'
then AmountInGlobalCurrency
else 0
end) as CreditPlanCostInGlobalCrcy,
sum(case when ControllingDebitCreditCode = 'H' or ControllingDebitCreditCode = 'S'
then AmountInGlobalCurrency
else 0
end) as DebitPlanCostInGlobalCrcy,
sum(case when ControllingDebitCreditCode = 'A' or ControllingDebitCreditCode = 'L'
then FixedAmountInGlobalCrcy
else 0
end) as CreditPlanFxdCostInGlobalCrcy,
sum(case when ControllingDebitCreditCode = 'H' or ControllingDebitCreditCode = 'S'
then FixedAmountInGlobalCrcy
else 0
end) as DebitPlanFxdCostInGlobalCrcy,
sum(case when ControllingDebitCreditCode = 'A' or ControllingDebitCreditCode = 'L'
then AmountInCompanyCodeCurrency
else 0
end) as CreditPlanCostInCoCodeCrcy,
sum(case when ControllingDebitCreditCode = 'H' or ControllingDebitCreditCode = 'S'
then AmountInCompanyCodeCurrency
else 0
end) as DebitPlanCostInCoCodeCrcy,
sum(case when ControllingDebitCreditCode = 'A' or ControllingDebitCreditCode = 'L'
then case
when AmountInGlobalCurrency <> 0
then cast( round(cast(division(FixedAmountInGlobalCrcy, AmountInGlobalCurrency, 6) as abap.dec(14, 6)) //fixed amount is always less than total amount here
* AmountInCompanyCodeCurrency, 2)
as abap.curr(23, 2) )
else 0
end
else 0
end ) as CreditPlanFxdCostInCoCodeCrcy,
sum(case when ControllingDebitCreditCode = 'H' or ControllingDebitCreditCode = 'S'
then case
when AmountInGlobalCurrency <> 0
then cast( round(cast(division(FixedAmountInGlobalCrcy, AmountInGlobalCurrency, 6) as abap.dec(14, 6)) //fixed amount is always less than total amount here
* AmountInCompanyCodeCurrency, 2)
as abap.curr(23, 2) )
else 0
end
else 0
end ) as DebitPlanFxdCostInCoCodeCrcy
}
where
(
AccountAssignmentType = 'OR'
or AccountAssignmentType = 'OP'
)
and OrderID <> ''
group by
AccountAssignmentType,
OrderID,
OrderItem,
ControllingDebitCreditCode,
_PlanningEntryItem.PlanningCategory,
CostSourceUnit,
GlobalCurrency,
CompanyCodeCurrency,
FiscalYearPeriod,
IsLotSizeIndependent,
PlngCatIsForOrdReltdPlnCost,
PlngCatIsForMatlCostEstPlnCost,
CompanyCode,
Plant,
ProducedProduct
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_FINANCIALPLANNINGENTRYITEM",
"I_LEDGER",
"I_MFGORDPLNGCAT"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/