fco_abr_bel_04_a

DDL: FCO_ABR_BEL_04_A SQL: FCOV_ABR_BEL_04A Type: view Package: KABR

Settlement actual costs

fco_abr_bel_04_a is a CDS View that provides data about "Settlement actual costs" in SAP S/4HANA. It reads from 3 data sources (t000, tka01, finsc_cmp_versnc). Part of development package KABR.

Data Sources (3)

SourceAliasJoin Type
t000 s inner
tka01 t inner
finsc_cmp_versnc v inner

Parameters (2)

NameTypeDefault
akP abap.char(3)
akG abap.char(4)

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName FCOV_ABR_BEL_04A view
EndUserText.label Settlement actual costs view
ClientHandling.algorithm #SESSION_VARIABLE view
Metadata.ignorePropagatedAnnotations true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ObjectModel.usageType.serviceQuality #P view
@AbapCatalog.sqlViewName: 'FCOV_ABR_BEL_04A'
@EndUserText.label      : 'Settlement actual costs'

@ClientHandling.algorithm: #SESSION_VARIABLE
@Metadata.ignorePropagatedAnnotations: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.serviceQuality: #P

define view fco_abr_bel_04_a

   with parameters akP : abap.char(3),     // Settlement period      auak-perio

                   akG : abap.char(4) as   // Settlement fiscal year auak-gjahr

   select
          objnr,
          ryear    as gjahr,
          v.versn  as versn,
          racct    as kstar,
          hrkft,
          vrgng,
          case when parobsrc = '1' then parob1     else case
               when parobsrc = '2' then paccasty
               else ''                             end end
                   as parob, // COSS only

          uspob,             // COSS only

          rassc    as vbund, // COSP only

          sbusa    as pargb, // COSP only

          co_beknz as beknz,
          rwcur    as twaer,
          co_meinh as meinh,
          bemot,
          beltp,

          case when ryear < :akG or poper <= :akP then case when v.wtgbtr = 'WSL'  then wsl 
                                                            when v.wtgbtr = 'WSL2' then wsl2
                                                            when v.wtgbtr = 'WSL3' then wsl3
                                                            else 0 end else 0 end
               as wtgbtr,
          case when ryear = :akG and poper = :akP then case when v.wtgbtr = 'WSL'  then wsl
                                                            when v.wtgbtr = 'WSL2' then wsl2
                                                            when v.wtgbtr = 'WSL3' then wsl3
                                                            else 0 end else 0 end
               as wtgper,

          case when ryear < :akG or poper <= :akP then case when t.xwbuk = '' and 
                                                               ( ( ( mig_source =  'C' and bstat =  'C' ) and co_osl <> 0 ) or
                                                                 ( ( mig_source <> 'C' or  bstat <> 'C' ) and rco_ocur <> '' ) ) then co_osl
                                                            when v.wogbtr = 'HSL'    then hsl 
                                                            when v.wogbtr = 'OSL'    then osl
                                                            when v.wogbtr = 'KSL'    then ksl
                                                            when v.wogbtr = 'VSL'    then vsl
                                                            when v.wogbtr = 'BSL'    then bsl
                                                            when v.wogbtr = 'CSL'    then csl
                                                            when v.wogbtr = 'DSL'    then dsl
                                                            when v.wogbtr = 'ESL'    then esl
                                                            when v.wogbtr = 'FSL'    then fsl
                                                            when v.wogbtr = 'GSL'    then gsl
                                                            else 0 end else 0 end 
               as wogbtr,
          case when ryear = :akG and poper = :akP then case when t.xwbuk = '' and 
                                                               ( ( ( mig_source =  'C' and bstat =  'C' ) and co_osl <> 0 ) or
                                                                 ( ( mig_source <> 'C' or  bstat <> 'C' ) and rco_ocur <> '' ) ) then co_osl
                                                            when v.wogbtr = 'HSL'    then hsl 
                                                            when v.wogbtr = 'OSL'    then osl
                                                            when v.wogbtr = 'KSL'    then ksl
                                                            when v.wogbtr = 'VSL'    then vsl
                                                            when v.wogbtr = 'BSL'    then bsl
                                                            when v.wogbtr = 'CSL'    then csl
                                                            when v.wogbtr = 'DSL'    then dsl
                                                            when v.wogbtr = 'ESL'    then esl
                                                            when v.wogbtr = 'FSL'    then fsl
                                                            when v.wogbtr = 'GSL'    then gsl
                                                            else 0 end else 0 end
               as wogper,

          case when ryear < :akG or poper <= :akP then case when v.wkgbtr = 'HSL' then hsl
                                                            when v.wkgbtr = 'OSL' then osl
                                                            when v.wkgbtr = 'KSL' then ksl
                                                            when v.wkgbtr = 'VSL' then vsl
                                                            when v.wkgbtr = 'BSL' then bsl
                                                            when v.wkgbtr = 'CSL' then csl
                                                            when v.wkgbtr = 'DSL' then dsl
                                                            when v.wkgbtr = 'ESL' then esl
                                                            when v.wkgbtr = 'FSL' then fsl
                                                            when v.wkgbtr = 'GSL' then gsl
                                                            else 0 end else 0 end
               as wkgbtr,
          case when ryear = :akG and poper = :akP then case when v.wkgbtr = 'HSL' then hsl
                                                            when v.wkgbtr = 'OSL' then osl
                                                            when v.wkgbtr = 'KSL' then ksl
                                                            when v.wkgbtr = 'VSL' then vsl
                                                            when v.wkgbtr = 'BSL' then bsl
                                                            when v.wkgbtr = 'CSL' then csl
                                                            when v.wkgbtr = 'DSL' then dsl
                                                            when v.wkgbtr = 'ESL' then esl
                                                            when v.wkgbtr = 'FSL' then fsl
                                                            when v.wkgbtr = 'GSL' then gsl
                                                            else 0 end else 0 end
               as wkgper,
               
          case when ryear < :akG or poper <= :akP then case when v.wkfbtr = 'KFSL'  then kfsl
                                                            when v.wkfbtr = 'KFSL2' then kfsl2
                                                            when v.wkfbtr = 'KFSL3' then kfsl3
                                                            else 0 end else 0 end
               as wkfbtr,
          case when ryear = :akG and poper = :akP then case when v.wkfbtr = 'KFSL'  then kfsl
                                                            when v.wkfbtr = 'KFSL2' then kfsl2
                                                            when v.wkfbtr = 'KFSL3' then kfsl3
                                                            else 0 end else 0 end
               as wkfper,

          case when ryear < :akG or poper <= :akP then case when v.pagbtr = 'PSL'  then psl
                                                            when v.pagbtr = 'PSL2' then psl2
                                                            when v.pagbtr = 'PSL3' then psl3
                                                            else 0 end else 0 end
               as pagbtr,
          case when ryear = :akG and poper = :akP then case when v.pagbtr = 'PSL'  then psl
                                                            when v.pagbtr = 'PSL2' then psl2
                                                            when v.pagbtr = 'PSL3' then psl3
                                                            else 0 end else 0 end
               as pagper,

          case when ryear < :akG or poper <= :akP then case when v.pafbtr = 'PFSL'  then pfsl
                                                            when v.pafbtr = 'PFSL2' then pfsl2
                                                            when v.pafbtr = 'PFSL3' then pfsl3
                                                            else 0 end else 0 end
               as pafbtr,
          case when ryear = :akG and poper = :akP then case when v.pafbtr = 'PFSL'  then pfsl
                                                            when v.pafbtr = 'PFSL2' then pfsl2
                                                            when v.pafbtr = 'PFSL3' then pfsl3
                                                            else 0 end else 0 end
               as pafper,

          case when (ryear < :akG or poper <= :akP) and v.versn = '000' then co_megbtr else 0 end
               as megbtr,
          case when (ryear = :akG and poper = :akP) and v.versn = '000' then co_megbtr else 0 end
               as megper,

          case when (ryear < :akG or poper <= :akP) and v.versn = '000' then co_mefbtr else 0 end
               as mefbtr,
          case when (ryear = :akG and poper = :akP) and v.versn = '000' then co_mefbtr else 0 end
               as mefper,

          case when co_meinh = '' // see fill_bel_cos*a

                 or v.versn <> '000'                then cast(0      as abap.int4) else case               
               when (ryear < :akG or poper <= :akP) then cast(muvflg as abap.int4) else
                                                         cast(0      as abap.int4) end end
               as muvbtr,
          case when co_meinh = '' // see fill_bel_cos*a

                 or v.versn <> '000'                then cast(0      as abap.int4) else case               
               when (ryear = :akG and poper = :akP) then cast(muvflg as abap.int4) else 
                                                         cast(0      as abap.int4) end end
               as muvper
               
    from acdoca  as a

    inner join finsc_cmp_versnc as v  on     a.rbukrs = v.bukrs
                                         and a.rldnr  = v.rldnr

    inner join t000             as s  on   s.mandt  = a.rclnt
                                     and ( s.logsys = a.logsyso
                                                   or a.logsyso  = '' )
                                                   
    inner join tka01            as t  on   t.mandt  = a.rclnt
                                     and   t.kokrs  = a.kokrs                                      

    where a.accasty <> '' and ( ( a.co_belnr <> '' and a.co_buzei <> '000' ) or
                                ( a.mig_source = 'C' and a.bstat = 'C' ) )    
    ;