@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'OrglChg: Fill RT for Real Estate Contr.'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #C,
sizeCategory: #L,
dataClass: #TRANSACTIONAL
}
// For real estate contracts, several controlling objects can be assigned - all potential candidates
// for profit center derivation. Nevertheless, the real estate application takes care that the prctr
// is equal for all those objects. Hence, it is enough to establish a profit center derivation from
// one of these objects.
// This means, when looking for an upper object, tese objects are checked:
// * Cost Center
// * WBS Element
// * Internal Order
// key to abbreviations: vt = valuation term, oc = organizational change, rec = real estate contract
define view entity FINOC_RT_REC_FILL
as
select from vicncn as rec
inner join finoc_orglchg as oc on oc.processing_status <> 'CMP'
// organizational fields
inner join vicaintreno as rec_bukrs on rec_bukrs.intreno = rec.intreno
inner join tka02 as contrlg_area on contrlg_area.bukrs = rec_bukrs.bukrs
// upper objects from valuation terms
inner join FINOC_RT_REC_FILL_ACCTOBJ as rules_table on rules_table.intreno = rec.intreno
and rules_table.orgl_change = oc.orgl_change
left outer join finoc_rt_ccr as cost_center_rt on cost_center_rt.orgl_change = oc.orgl_change
and cost_center_rt.objnr = rules_table.objnr
left outer join finoc_rt_wbs as wbs_element_rt on wbs_element_rt.orgl_change = oc.orgl_change
and wbs_element_rt.objnr = rules_table.objnr
left outer join finoc_rt_ord as order_rt on order_rt.orgl_change = oc.orgl_change
and order_rt.objnr = rules_table.objnr
// rec runtime
left outer join finoc_rt_rec as real_estate_rt on real_estate_rt.intreno = rec.intreno
and real_estate_rt.orgl_change = oc.orgl_change
// status is yet active
left outer join jest as status_active on status_active.objnr = rec.objnr
and status_active.stat = 'I0119'
and status_active.inact = ''
left outer join jest as status_inactive on status_inactive.objnr = rec.objnr
and(
status_inactive.inact = ''
and(
status_inactive.stat = 'I0046' // closed
or status_inactive.stat = 'I0076' // deletion flag
or status_inactive.stat = 'I0013' // deletion indicator
)
)
{
key rec.intreno as InternalRealEstateNumber,
oc.orgl_change as OrganizationalChange,
contrlg_area.kokrs as ControllingArea,
rec_bukrs.bukrs as CompanyCode,
coalesce(
real_estate_rt.prctr_old,
case
when cost_center_rt.kostl is not null then cost_center_rt.prctr_old
when wbs_element_rt.ps_psp_pnr is not null then wbs_element_rt.prctr_old
when order_rt.aufnr is not null then order_rt.prctr_old
else cast(' ' as finoc_prctr_before_orgl_change preserving type ) end ) as ProfitCenterBeforeOrglChange,
case
when cost_center_rt.kostl is not null then cost_center_rt.prctr
when wbs_element_rt.ps_psp_pnr is not null then wbs_element_rt.prctr
when order_rt.aufnr is not null then order_rt.prctr
else cast(' ' as finoc_prctr_new preserving type ) end as ProfitCenterByOrglChange,
// profit center derivation source type
case
when cost_center_rt.kostl is not null then 'KS'
when wbs_element_rt.ps_psp_pnr is not null and wbs_element_rt.prctr_drvtn_source_type = '' then 'PR'
when wbs_element_rt.ps_psp_pnr is not null and wbs_element_rt.prctr_drvtn_source_type <> '' then wbs_element_rt.prctr_drvtn_source_type
when order_rt.aufnr is not null and order_rt.prctr_drvtn_source_type = '' then 'OR'
when order_rt.aufnr is not null and order_rt.prctr_drvtn_source_type <> '' then order_rt.prctr_drvtn_source_type
else cast(' ' as finoc_prctr_drvtn_source_type preserving type ) end as ProfitCenterDerivationSrceType,
// Source Fields
case
when cost_center_rt.kostl is not null then cost_center_rt.kostl
when order_rt.aufnr is not null then order_rt.srce_kostl
else cast( ' ' as finoc_srce_kostl preserving type ) end as SourceCostCenter,
case
when cost_center_rt.kostl is null
and wbs_element_rt.ps_psp_pnr is not null
and wbs_element_rt.prctr_drvtn_source_type = '' then wbs_element_rt.ps_psp_pnr
when cost_center_rt.kostl is null
and wbs_element_rt.ps_psp_pnr is not null
and wbs_element_rt.prctr_drvtn_source_type <> '' then wbs_element_rt.srce_ps_psp_pnr
when cost_center_rt.kostl is null
and wbs_element_rt.ps_psp_pnr is null
and order_rt.aufnr is not null then order_rt.srce_ps_psp_pnr
else cast('00000000' as finoc_srce_ps_psp_pnr preserving type) end as SourceWBSElementInternalID,
case
when cost_center_rt.kostl is null
and wbs_element_rt.ps_psp_pnr is not null then wbs_element_rt.srce_ps_prj_pnr
when cost_center_rt.kostl is null
and wbs_element_rt.ps_psp_pnr is null
and order_rt.aufnr is not null then order_rt.srce_ps_prj_pnr
else cast('00000000' as finoc_srce_ps_prj_pnr preserving type) end as SourceProjectInternalID,
case
when cost_center_rt.kostl is null
and wbs_element_rt.ps_psp_pnr is null
and order_rt.aufnr is not null
and order_rt.prctr_drvtn_source_type = ''
then order_rt.aufnr
else cast(' ' as finoc_srce_aufnr preserving type) end as SourceOrder,
// additional identifiers
rec.objnr as ObjectNumber,
rec.recnnr as RealEstateContract,
rec.imkey as RealEstateInternalFinNumber
}
where
(
cost_center_rt.kostl is not null
or wbs_element_rt.ps_psp_pnr is not null
or order_rt.aufnr is not null
)
and status_inactive.stat is null // not closed or having deletion flag or indicator
and status_active.stat is not null // having reached status active
and rec.recnendabs >= oc.effective_date // SAP Note 3552354; absolute end date extends over effective date