P_CN_CADEAssetRetirement

DDL: P_CN_CADEASSETRETIREMENT SQL: PCADEASSETRETIRE Type: view CONSUMPTION

P_CN_CADEAssetRetirement is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (I_CN_CADEGeneralInformation, I_FixedAssetTransaction) and exposes 33 fields with key fields CompanyCode, CN_CADENatlStdRelVersion, MasterFixedAsset, FixedAsset, FiscalYear. It has 2 associations to related views.

Data Sources (2)

SourceAliasJoin Type
I_CN_CADEGeneralInformation DepreciationArea inner
I_FixedAssetTransaction I_FixedAssetTransaction from

Parameters (3)

NameTypeDefault
P_FiscalYear fis_gjahr
P_FromFiscalPeriod fins_fiscalperiod
P_ToFiscalPeriod fins_fiscalperiod

Associations (2)

CardinalityTargetAliasCondition
[0..1] I_GLAccountLineItem _Quantity _Quantity.CompanyCode = JournalEntry.CompanyCode and _Quantity.Ledger = JournalEntry.Ledger and _Quantity.AccountingDocument = JournalEntry.AccountingDocument and _Quantity.ReferenceDocument = JournalEntry.ReferenceDocument and ( _Quantity.SubLedgerAcctLineItemType = '07040' or _Quantity.SubLedgerAcctLineItemType = '07000') and _Quantity.MasterFixedAsset = JournalEntry.MasterFixedAsset and _Quantity.FixedAsset = JournalEntry.FixedAsset and _Quantity.AssetDepreciationArea = JournalEntry.AssetDepreciationArea
[0..1] I_AssetValuationForLedger _ScrapAmount _ScrapAmount.CompanyCode = JournalEntry.CompanyCode and _ScrapAmount.MasterFixedAsset = JournalEntry.MasterFixedAsset and _ScrapAmount.FixedAsset = JournalEntry.FixedAsset and _ScrapAmount.AssetRealDepreciationArea = JournalEntry.AssetDepreciationArea and _ScrapAmount.ValidityStartDate <= JournalEntry.PostingDate and _ScrapAmount.ValidityEndDate >= JournalEntry.PostingDate

Annotations (7)

NameValueLevelField
AbapCatalog.preserveKey true view
AbapCatalog.sqlViewName PCADEASSETRETIRE view
AbapCatalog.compiler.compareFilter true view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.viewType #CONSUMPTION view
VDM.private true view
AccessControl.authorizationCheck #NOT_REQUIRED view

Fields (33)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode JournalEntry CompanyCode
KEY CN_CADENatlStdRelVersion I_CN_CADEGeneralInformation CN_CADENatlStdRelVersion
KEY MasterFixedAsset MasterFixedAsset
KEY FixedAsset FixedAsset
KEY FiscalYear FiscalYear
KEY FiscalPeriod FiscalPeriod
KEY AssetDepreciationArea JournalEntry AssetDepreciationArea
KEY LedgerGroup LedgerGroup
KEY Ledger JournalEntry Ledger
KEY ReferenceDocument JournalEntry ReferenceDocument
FixedAssetExternalID FixedAssetExternalID
AssetSerialNumberendasAssetSerialNumber
Inventory _FixedAsset Inventory
FixedAssetDescription _FixedAsset FixedAssetDescription
AssetClass _FixedAsset AssetClass
ChartOfDepreciation ChartOfDepreciation
PostingDate PostingDate
AssetTransactionVariant AssetTransactionVariant
AcqnProdnCostScrapPercent _ScrapAmount AcqnProdnCostScrapPercent
BaseUnit _Quantity BaseUnit
AssetValueDate
Quantity
DisplayCurrency DisplayCurrency
AcqnProdnAmtInDspCrcy
RetirementRevenueAmtInDspCrcy
RetirementCostsAmtInDspCrcy
RetirementDeprAmtInDspCrcy
RetirementAmountInDspCrcy
OrdinaryDeprAmtInDspCrcy
SpecialDeprAmtInDspCrcy
UnplannedDeprAmtInDspCrcy
AssetTransactionType
DocumentItemText
@AbapCatalog.preserveKey: true
@AbapCatalog.sqlViewName: 'PCADEASSETRETIRE'
@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.viewType: #CONSUMPTION
@VDM.private: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view P_CN_CADEAssetRetirement with parameters
    @EndUserText.label: 'Fiscal Year'
    P_FiscalYear   : fis_gjahr,
    @EndUserText.label: 'To Fiscal Period'
    P_FromFiscalPeriod   : fins_fiscalperiod,
    @EndUserText.label: 'To Fiscal Period'
    P_ToFiscalPeriod   : fins_fiscalperiod
as select from I_FixedAssetTransaction ( P_KeyDate: $session.system_date, P_AssetAccountingKeyFigureSet: 'TRANS_ALL' ) as JournalEntry
inner join I_CN_CADEGeneralInformation as DepreciationArea on DepreciationArea.AssetDepreciationArea = JournalEntry.AssetDepreciationArea
                                                           and DepreciationArea.CompanyCode = JournalEntry.CompanyCode
                                                           and DepreciationArea.Ledger = JournalEntry.Ledger
left outer to one join I_LedgerCompanyCodeCrcyRoles as _LedgerCompanyCodeCrcyRole on _LedgerCompanyCodeCrcyRole.CompanyCode = JournalEntry.CompanyCode
                                                                                 and _LedgerCompanyCodeCrcyRole.Ledger = JournalEntry.Ledger
association [0..1] to I_GLAccountLineItem as _Quantity on _Quantity.CompanyCode = JournalEntry.CompanyCode
                                                      and _Quantity.Ledger = JournalEntry.Ledger
                                                      and _Quantity.AccountingDocument = JournalEntry.AccountingDocument
                                                      and _Quantity.ReferenceDocument = JournalEntry.ReferenceDocument
                                                      and ( _Quantity.SubLedgerAcctLineItemType = '07040' or _Quantity.SubLedgerAcctLineItemType = '07000')
                                                      and _Quantity.MasterFixedAsset = JournalEntry.MasterFixedAsset
                                                      and _Quantity.FixedAsset = JournalEntry.FixedAsset
                                                      and _Quantity.AssetDepreciationArea = JournalEntry.AssetDepreciationArea
association [0..1] to I_AssetValuationForLedger as _ScrapAmount on _ScrapAmount.CompanyCode = JournalEntry.CompanyCode
                                                          and _ScrapAmount.MasterFixedAsset = JournalEntry.MasterFixedAsset
                                                          and _ScrapAmount.FixedAsset = JournalEntry.FixedAsset
                                                          and _ScrapAmount.AssetRealDepreciationArea = JournalEntry.AssetDepreciationArea
                                                          and _ScrapAmount.ValidityStartDate <= JournalEntry.PostingDate
                                                          and _ScrapAmount.ValidityEndDate >= JournalEntry.PostingDate
{
    key JournalEntry.CompanyCode,
    key DepreciationArea.CN_CADENatlStdRelVersion,
    key MasterFixedAsset,
    key FixedAsset,
    key FiscalYear,
    key FiscalPeriod,
    key JournalEntry.AssetDepreciationArea,
    key LedgerGroup,
    key JournalEntry.Ledger,
    key JournalEntry.ReferenceDocument,
        FixedAssetExternalID,
        case when _FixedAsset.AssetSerialNumber = ''
          then _FixedAsset.Inventory
          else _FixedAsset.AssetSerialNumber
        end as AssetSerialNumber,
        _FixedAsset.Inventory,
        _FixedAsset.FixedAssetDescription,
        _FixedAsset.AssetClass,
        ChartOfDepreciation,
        PostingDate,
        AssetTransactionVariant,
        _ScrapAmount.AcqnProdnCostScrapPercent,
      //  @ObjectModel.foreignKey.association: '_BaseUnit'

        @Semantics.unitOfMeasure:true
        _Quantity.BaseUnit,
        
        max( AssetValueDate ) as AssetValueDate,
        @Semantics: { quantity : {unitOfMeasure: 'BaseUnit'} }
        max( _Quantity.Quantity ) as Quantity,
        
        @Semantics.currencyCode:true
        DisplayCurrency,
        
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum( AcqnProdnAmtInDspCrcy ) as AcqnProdnAmtInDspCrcy,
        
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum( case when JournalEntry.SubLedgerAcctLineItemType = '07003' or JournalEntry.SubLedgerAcctLineItemType = '07043' or JournalEntry.SubLedgerAcctLineItemType = '07203' //revaluation amount

               then AcqnProdnAmtInDspCrcy
               else cast(0 as fis_valueadjamt)
             end ) as ValueAdjustmentAmtInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(RetirementRevenueAmtInDspCrcy) as RetirementRevenueAmtInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(RetirementCostsAmtInDspCrcy) as RetirementCostsAmtInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(RetirementDeprAmtInDspCrcy) as RetirementDeprAmtInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(RetirementAmountInDspCrcy) as RetirementAmountInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(OrdinaryDeprAmtInDspCrcy) as OrdinaryDeprAmtInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(SpecialDeprAmtInDspCrcy) as SpecialDeprAmtInDspCrcy,
        @DefaultAggregation:#SUM
        @Semantics.amount.currencyCode: 'DisplayCurrency'
        sum(UnplannedDeprAmtInDspCrcy) as UnplannedDeprAmtInDspCrcy,
        max(JournalEntry.AssetTransactionType) as AssetTransactionType,
        max(JournalEntry.DocumentItemText) as DocumentItemText
}
where
CurrencyRole = _LedgerCompanyCodeCrcyRole.CompanyCodeCurrencyRole
and AssetTransactionVariant = '2'
and FiscalYear = :P_FiscalYear
and FiscalPeriod >= :P_FromFiscalPeriod
and FiscalPeriod <= :P_ToFiscalPeriod
group by 
JournalEntry.CompanyCode,
DepreciationArea.CN_CADENatlStdRelVersion,
MasterFixedAsset,
FixedAsset,
FiscalYear,
FiscalPeriod,
JournalEntry.AssetDepreciationArea,
LedgerGroup,
JournalEntry.Ledger,
JournalEntry.ReferenceDocument,
FixedAssetExternalID,
_FixedAsset.AssetSerialNumber,
_FixedAsset.Inventory,
_FixedAsset.FixedAssetDescription,
_FixedAsset.AssetClass,
_FixedAsset.OriglAcqnAmtInCoCodeCrcy,
_FixedAsset.Quantity,
ChartOfDepreciation,
PostingDate,
AssetTransactionVariant,
DisplayCurrency,
_ScrapAmount.AcqnProdnCostScrapPercent,
_Quantity.BaseUnit

/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ASSETVALUATIONFORLEDGER",
"I_CN_CADEGENERALINFORMATION",
"I_FIXEDASSET",
"I_FIXEDASSETTRANSACTION",
"I_GLACCOUNTLINEITEM",
"I_LEDGERCOMPANYCODECRCYROLES"
],
"ASSOCIATED":
[
"I_ASSETVALUATIONFORLEDGER",
"I_GLACCOUNTLINEITEM"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/