@AbapCatalog.sqlViewName: 'FAAV_ANLC1_PADOC'
@EndUserText.label: 'Periodisches Verdichten auf SLALITTYPE'
@ClientHandling.algorithm: #SESSION_VARIABLE
@Metadata.ignorePropagatedAnnotations: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.serviceQuality: #P
// this view is to condense the data on slalittype level
-------------------------------------------------------------
define view Faa_Anlc1_P_Adoc
as select from Faa_Rep_Ledger as ldnr
inner join acdoca as adoc
on ldnr.bukrs = adoc.rbukrs
and ldnr.rep_ledger = adoc.rldnr
and ldnr.lead_afabe = adoc.afabe
and ldnr.xstore = 'X'
{ rclnt as mandt,
rbukrs as bukrs,
anln1,
anln2,
// gjahr,
ryear as gjahr,
afabe,
rldnr,
slalittype,
movcat,
case when ( slalittype >= '07203' and slalittype <= '07209' ) and adoc.depr_period >= '001'
then adoc.depr_period
else adoc.poper
end as poperx, // ->nafap & ->parameter for ANLC ext. with period
case when ( slalittype >= '07203' and slalittype <= '07209' ) and adoc.poper >= '001'
then adoc.poper
else adoc.poper // there should be always a filled poper in ACDOCA
end as poperg, //->nafag
case when ( bstat = 'C' and movcat <> '06' )
or ( movcat = 'C7' )
or ( movcat = '77' or movcat = '87' or movcat = '97' )
then '000' // balance carried forward
else '999' end as poper, // current year
sum ( hsl ) as hsl,
sum ( ksl ) as ksl,
sum ( osl ) as osl,
sum ( vsl ) as vsl,
sum ( bsl ) as bsl,
sum ( csl ) as csl,
sum ( dsl ) as dsl,
sum ( esl ) as esl,
sum ( fsl ) as fsl,
sum ( gsl ) as gsl }
where anln1 <> ''
and ( mig_source = 'A' or mig_source = '' )
and ( slalittype = '07000' or
slalittype = '07001' or slalittype = '07002' or slalittype = '07003' or slalittype = '07004' or
slalittype = '07005' or slalittype = '07006' or slalittype = '07007' or slalittype = '07008' or
slalittype = '07009' or slalittype = '07022' or slalittype = '07023' or slalittype = '07024' or // note 2609067
slalittype = '07025' or slalittype = '07026' or slalittype = '07027' or slalittype = '07028' or
slalittype = '07040' or
slalittype = '07041' or slalittype = '07042' or slalittype = '07043' or slalittype = '07044' or
slalittype = '07045' or slalittype = '07046' or slalittype = '07047' or slalittype = '07048' or
slalittype = '07203' or slalittype = '07204' or
slalittype = '07205' or slalittype = '07206' or slalittype = '07207' or slalittype = '07208' or
slalittype = '07209' )
group by rclnt,
rbukrs,
anln1,
anln2,
// gjahr,
ryear,
afabe,
rldnr,
slalittype,
movcat,
poper,
depr_period,
bstat
union all
// the same for group assets
-----------------------------
select from Faa_Rep_Ledger as ldnr
inner join acdoca as adoc
on ldnr.bukrs = adoc.rbukrs
and ldnr.rep_ledger = adoc.rldnr
and ldnr.lead_afabe = adoc.afabe
and ldnr.xstore = 'X'
{ rclnt as mandt,
rbukrs as bukrs,
anlgr as anln1,
anlgr2 as anln2,
// gjahr,
ryear as gjahr,
afabe,
rldnr,
slalittype,
movcat,
case when ( slalittype >= '07203' and slalittype <= '07209' ) and adoc.depr_period >= '001'
then adoc.depr_period
else adoc.poper
end as poperx,
case when ( slalittype >= '07203' and slalittype <= '07209' ) and adoc.poper >= '001'
then adoc.poper
else adoc.poper
end as poperg,
case when ( bstat = 'C' and movcat <> '06' )
or ( movcat = 'C7' ) // 'C7' = unterjährige Altdatenübernahme
or ( movcat = '77' or movcat = '87' or movcat = '97' ) // note 2252940
then '000' // balance carried forward
else '999' end as poper, // current year
sum ( hsl ) as hsl,
sum ( ksl ) as ksl,
sum ( osl ) as osl,
sum ( vsl ) as vsl,
sum ( bsl ) as bsl,
sum ( csl ) as csl,
sum ( dsl ) as dsl,
sum ( esl ) as esl,
sum ( fsl ) as fsl,
sum ( gsl ) as gsl }
where anlgr <> ''
and ( mig_source = 'A' or mig_source = '' )
and ( ( adoc.anlgr <> adoc.anln1 )
or ( adoc.anlgr = adoc.anln1 and adoc.anlgr2 <> adoc.anln2 ) )
and ( slalittype = '07000' or
slalittype = '07001' or slalittype = '07002' or slalittype = '07003' or slalittype = '07004' or
slalittype = '07005' or slalittype = '07006' or slalittype = '07007' or slalittype = '07008' or
slalittype = '07009' or slalittype = '07022' or slalittype = '07023' or slalittype = '07024' or // note 2609067
slalittype = '07025' or slalittype = '07026' or slalittype = '07027' or slalittype = '07028' or
slalittype = '07040' or
slalittype = '07041' or slalittype = '07042' or slalittype = '07043' or slalittype = '07044' or
slalittype = '07045' or slalittype = '07046' or slalittype = '07047' or slalittype = '07048' or
slalittype = '07203' or slalittype = '07204' or
slalittype = '07205' or slalittype = '07206' or slalittype = '07207' or slalittype = '07208' or
slalittype = '07209' )
group by rclnt,
rbukrs,
anlgr,
anlgr2,
// gjahr,
ryear,
afabe,
rldnr,
slalittype,
movcat,
poper,
depr_period,
bstat
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"FAA_REP_LEDGER",
"ACDOCA"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/