v_coep_acdoca_view

DDL: V_COEP_ACDOCA_DDL SQL: V_COEP_ACDOCA Type: view

Mapping from ACDOCA to COEP

v_coep_acdoca_view is a CDS View that provides data about "Mapping from ACDOCA to COEP" in SAP S/4HANA. It reads from 2 data sources (tka01, finsc_cmp_versnc).

Data Sources (2)

SourceAliasJoin Type
tka01 t inner
finsc_cmp_versnc v inner

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName V_COEP_ACDOCA view
EndUserText.label Mapping from ACDOCA to COEP view
ClientHandling.algorithm #SESSION_VARIABLE view
Metadata.ignorePropagatedAnnotations true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ObjectModel.usageType.serviceQuality #P view
@AbapCatalog.sqlViewName: 'V_COEP_ACDOCA'
@EndUserText.label: 'Mapping from ACDOCA to COEP'

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

define view v_coep_acdoca_view as
   select
          key a.rclnt  as mandt,
          key a.kokrs  as kokrs,
          key co_belnr as belnr,
          key 
            case when v.buzei = 'CO_BUZEI'  then a.co_buzei
                 when v.buzei = 'CO_BUZEI1' then a.co_buzei1           
                 when v.buzei = 'CO_BUZEI2' then a.co_buzei2
                 when v.buzei = 'CO_BUZEI5' then a.co_buzei5
                 when v.buzei = 'CO_BUZEI6' then a.co_buzei6
                 when v.buzei = 'CO_BUZEI7' then a.co_buzei7
                 else                            a.co_buzei
            end        as buzei, 
            
          budat,
          poper as PERIO,
          
          case         
            when wkgbtr   = 'KSL'  then rkcur
            when wkgbtr   = 'HSL'  then rhcur   
            when wkgbtr   = 'OSL'  then rocur            
            when wkgbtr   = 'VSL'  then rvcur
            when wkgbtr   = 'BSL'  then rbcur
            when wkgbtr   = 'CSL'  then rccur
            when wkgbtr   = 'DSL'  then rdcur
            when wkgbtr   = 'ESL'  then recur
            when wkgbtr   = 'FSL'  then rfcur
            when wkgbtr   = 'GSL'  then rgcur
            else             ''  
          end as kwaer,    

          rwcur as twaer,                        

          case 
            when rco_ocur <> ''  and  t.xwbuk = ''  then rco_ocur             
            when wogbtr   = 'KSL'  then rkcur
            when wogbtr   = 'HSL'  then rhcur   
            when wogbtr   = 'OSL'  then rocur            
            when wogbtr   = 'VSL'  then rvcur
            when wogbtr   = 'BSL'  then rbcur
            when wogbtr   = 'CSL'  then rccur
            when wogbtr   = 'DSL'  then rdcur
            when wogbtr   = 'ESL'  then recur
            when wogbtr   = 'FSL'  then rfcur
            when wogbtr   = 'GSL'  then rgcur
            else                        ''
          end as owaer,  
          
 
          case     
            when rco_ocur <> '' and  t.xwbuk = ''  then co_osl 
            when wogbtr   = 'KSL'  then ksl
            when wogbtr   = 'HSL'  then hsl   
            when wogbtr   = 'OSL'  then osl            
            when wogbtr   = 'VSL'  then vsl
            when wogbtr   = 'BSL'  then bsl
            when wogbtr   = 'CSL'  then csl
            when wogbtr   = 'DSL'  then dsl
            when wogbtr   = 'ESL'  then esl
            when wogbtr   = 'FSL'  then fsl
            when wogbtr   = 'GSL'  then gsl
            else                        0  
          end as wogbtr,  

          case wtgbtr
            when 'WSL'  then wsl        
            when 'WSL2' then wsl2
            when 'WSL3' then wsl3            
            else             0  
          end as wtgbtr,          

          case wkgbtr          
            when 'KSL'  then ksl
            when 'HSL'  then hsl             
            when 'OSL'  then osl            
            when 'VSL'  then vsl
            when 'BSL'  then bsl
            when 'CSL'  then csl
            when 'DSL'  then dsl
            when 'ESL'  then esl
            when 'FSL'  then fsl
            when 'GSL'  then gsl
            else             0  
          end as wkgbtr,  
                              
          case  wkfbtr
            when 'KFSL'   then kfsl
            when 'KFSL2'  then kfsl2
            when 'KFSL3'  then kfsl3  
            else               0        
          end as wkfbtr,
                                    

          case  pagbtr
            when 'PSL'  then psl
            when 'PSL2' then psl2
            when 'PSL3' then psl3  
            else             0        
          end as pagbtr,
                    
          case  pafbtr
            when 'PFSL'  then pfsl
            when 'PFSL2' then pfsl2
            when 'PFSL3' then pfsl3  
            else             0        
          end as pafbtr,
          
          
          co_megbtr as MEGBTR,
          co_mefbtr as MEFBTR,
          msl as MBGBTR,
          mfsl as MBFBTR,
          '00' as LEDNR,
          objnr,
          ryear as GJAHR,     ---  ryear as GJAHR,
          case when ( accasty is null or accasty = '' ) then '11' else '04' end as WRTTP,      --- logic according to Cost element type 90: statistical lines (11) are calculated outside; value type (04, 11) will be determined outside
          v.versn as VERSN,   --- default: '000'
          racct as KSTAR,
          hrkft,
          a.vrgng,
          case when parobsrc = '1' then parob1 else case when parobsrc = '2' then paccasty else '' end end as PAROB,
          parob1,
          uspob,
          rassc as VBUND,
          sbusa as PARGB,
/*          case when ( t.vrgng is not null
                    or
                                    -- a.vrgng = 'COIN' or a.vrgng = 'RKU1' or a.vrgng = 'COIE'
                                    -- or a.vrgng = 'RKU2' or a.vrgng = 'RKU3'
                                    -- or a.vrgng = 'KZRI' or
                                     a.vrgng  = 'KSI1' or a.vrgng = 'KSP1'
                                    -- or a.vrgng = 'RKIB' or a.vrgng = 'RKPB' or a.vrgng = 'RRIB'
                                    -- or a.vrgng = 'KZRP' or a.vrgng = 'KSP1'
                    )
                    and ( co_belkz <> 'L' and co_belkz <> 'A' )
                then drcrk else co_belkz end as BEKNZ,      --- other VRGNG's ?-> see FUNCTION romu_om_fill_belkz.
*/
          co_beknz as beknz,

          co_meinh as MEINH,
          case when ( runit is null or runit = '' ) then '' else runit end as MEINB,
          muvflg,   --- Note: that's not compatible with COEP-MVFLG. Calculation of MVFLG will be done in V_COEP
          sgtxt,
--          case when awtyp <> 'COBK'                                             then substring(awitem,4,3)      else
--          case when (awtyp = 'COBK' and ( bttype = 'RKU3' or bttype = 'RKLU' )) then substring(prec_awitem,4,3) else
--                    '000' end end
--               as   REFBZ,
          co_refbz as refbz,
          co_zlenr as zlenr,
          co_buzei as BW_REFBZ,
          //note 2551806

          case when ( a.vrgng = 'COIN' or a.vrgng = 'COIE' or a.vrgng = 'KZRI' or
                      a.vrgng = 'INV1' or a.vrgng = 'INV2' or a.vrgng = 'INV3' or
                      a.vrgng = 'INV4' or a.vrgng = 'INV5' or a.vrgng = 'INV6' or
                      a.vrgng = 'RKU3' )
               then gkont else '' end as gkont,
          case when ( a.vrgng = 'COIN' or a.vrgng = 'COIE' or a.vrgng = 'KZRI' or
                      a.vrgng = 'INV1' or a.vrgng = 'INV2' or a.vrgng = 'INV3' or
                      a.vrgng = 'INV4' or a.vrgng = 'INV5' or a.vrgng = 'INV6' or
                      a.vrgng = 'RKU3' )
               then gkoar else '' end as gkoar,                
          //gkont,

          //gkoar,

          werks,
          matnr,
          rbest,
          ebeln,
          ebelp,
          zekkn,
          erlkz,
          pernr,
---          BTRKL,         obsolete
---          OBJNR_N1, --- calculate outside
---          OBJNR_N2, --- calculate outside
---          OBJNR_N3, --- calculate outside
          case when xpaobjnr_co_rel = 'X' then paobjnr else '0000000000' end as paobjnr,
          beltp,
          rbukrs as BUKRS,
          rbusa as GSBER,
          rfarea as FKBER,
          scope,
          logsyso,
          --case when ( a.vrgng = 'COIN' or a.vrgng = 'COIE' or a.vrgng = 'KZRI' or
          --            a.vrgng = 'INV1' or a.vrgng = 'INV2' or a.vrgng = 'INV3' or
          --            a.vrgng = 'INV4' or a.vrgng = 'INV5' or a.vrgng = 'INV6' )
          --     then '' else gkont end as pkstar,
          '' as pkstar,
          pbukrs,
          sfarea as PFKBER,
          pscope,
          logsysp,
          dabrz,
          bwstrat,
          objnr_hk,
      --- timestamp as TIMESTMP, --- calculation on higher level
          case when timestamp > 0 then  cast(substring(cast(timestamp as abap.char(19)),1,4) as abap.numc(4)) else '0000' end as tsgjahr,
          case when timestamp > 0 then  cast(substring(cast(timestamp as abap.char(19)),5,2) as abap.numc(2)) else '00' end as tsmonth,
          case when timestamp > 0 then  cast(substring(cast(timestamp as abap.char(19)),7,2) as abap.numc(2)) else '00' end as tsday,
          case when timestamp > 0 then  cast(substring(cast(timestamp as abap.char(19)),9,2) as abap.numc(2)) else '00' end as tshour,
          case when timestamp > 0 then  cast(substring(cast(timestamp as abap.char(19)),11,2) as abap.numc(2)) else '00' end as tsminute,
          case when timestamp > 0 then  cast(substring(cast(timestamp as abap.char(19)),13,2) as abap.numc(2)) else '00' end as tssecond,
          qmnum,
          rfund as GEBER,
          sfund as PGEBER,
          rgrant_nbr as GRANT_NBR,
          sgrant_nbr as PGRANT_NBR,
          case when ( a.vrgng = 'COIN' or a.vrgng = 'COIE' or a.vrgng = 'KZRI' or
                      a.vrgng = 'INV1' or a.vrgng = 'INV2' or a.vrgng = 'INV3' or
                      a.vrgng = 'INV4' or a.vrgng = 'INV5' or a.vrgng = 'INV6' )
               then a.buzei else '000' end as REFBZ_FI,
          segment,
          psegment,
          '0000000000' as posnr, -- not persisted in ACDOCA, POSNR was just used as BSEG-COEP link for logical document
          prctr,
          pprctr as PPRCT,
          rbudget_pd as BUDGET_PD,
          sbudget_pd as PBUDGET_PD,
          cast(concat(substring(a.prodper,1,4),substring(a.prodper,5,2)) as abap.numc(6) ) as prodper,
          // Do not delete this comment

          //<$VF>

//<$FIELDS>

//<$VF>

          awtyp,
          replace( replace( concat( rpad( awref, 10, '€' ), aworg), '€', ' €' ), '€', ' ' ) as awkey,
          awsys,
          accas,
          accasty,
          rcntr as KOSTL,
          lstar,
          aufnr,
          autyp,
          ps_posid as pspnr,
          ps_pspid as pspid,
          kdauf as vbeln,
          kdpos as vbposnr,
          case when accasty = 'EO' then substring(objnr,7,10) else case when paobjnr <> '0000000000' and xpaobjnr_co_rel = 'X' then paobjnr else '0000000000' end end as ce4key, --- 1. objnr EO...; 2. PAOBJNR
          a.erkrs as erkrs,
          paccas,
          paccasty,
          scntr as PKOSTL,
          plstar,
          paufnr,
          pautyp,
          pps_posid as ppspnr,
          pps_pspid as ppspid,
          pkdauf as pvbeln,
          pkdpos as pvbposnr,
          case when paccasty = 'EO' then substring(parob1,7,10) else case when paobjnr <> '0000000000' and xpaobjnr_co_rel = 'X' then ppaobjnr else '0000000000' end  end as pce4key, --- 1. parob1 EO...; 2. PPAOBJNR
          quant1,
          quant2,
          quant3,
          qunit1,
          qunit2,
          qunit3,
          co_accasty_n1,
          co_accasty_n2,
          co_accasty_n3
// Do not delete this comment 2

//<$VFAPP>

//<$FIELDSAPP>

//<$VFAPP>

    from acdoca  as a
    inner join finsc_cmp_versnc as v  on v.bukrs = a.rbukrs        --- select only the ledger which is assigned to version 000;
                                     and v.rldnr = a.rldnr         --- Ledger space is obsolete     or a.rldnr = '' )
                                     and v.versn = '000'
    inner join tka01            as t  on  t.mandt  = a.rclnt  
                                     and  t.kokrs  = a.kokrs 
    where a.co_belnr <> '' and a.co_buzei <> '000' and a.objnr <> ''
    and not ( accasty is null or accasty = '' )
      ;
      
  
 /*+[internal] {
"BASEINFO":
{
"FROM":
[
"ACDOCA",
"FINSC_CMP_VERSNC",
"TKA01"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/