Quantcast
Channel: SCN : Blog List - SAP ERP Human Capital Management (SAP ERP HCM)
Viewing all articles
Browse latest Browse all 889

Simpler and faster Payroll reporting with DDL views on top of payroll declustering tools

$
0
0

Please note that this document does not represent any official statement from SAP and is subject to change at any time without notice. The examples here contained are provided without a warranty of any kind

 

In this blog post you will see how to build DDL views content on top of the payroll results declustering tables and how to consume them within abap reports/programs.

 

If you are not yet familiar with the newly available ABAP core data services, you can have a look here: http://scn.sap.com/community/abap/eclipse/blog/2014/02/04/new-data-modeling-features-in-abap-for-hana

 

The big advantage of this data model is that you can define something like a virtual cube (similar to HANA analytic view) on a native abap repository object which is database independent so that you don’t have to code SQL for a specific database. In case the system’s primary database is HANA, the system will query the data in a similar way as if it were an analytic view (engaging column engine for example), therefore you also benefit by speed.

 

This post shows a use case example similar to the one built with analytic views on this post here, so for the theory behind it, it might be a good idea to read it first.

 

Lets start by creating a Database view (not a maintenance view) on the data dictionary, in transaction SE11. We can call the view ZV_WPBP_INDEX. Use the following tables and join conditions:

 

1.png

 

Tables:

 

P2RX_WPBP

P2RX_WPBP_INDEX


Join conditions:

 

P2RX_WPBP     DCT_PERNR     =     P2RX_WPBP_INDEX     DCT_PERNR

P2RX_WPBP     DCT_SEQNR     =     P2RX_WPBP_INDEX     DCT_SEQNR

P2RX_WPBP     APZNR         =     P2RX_WPBP_INDEX     WPBP_APZNR

P2RX_WPBP     MANDT         =     P2RX_WPBP_INDEX     MANDT

 

And you can add the fields you need (most important is the correct setup of the key fields of both tables, the remaining attribute fields of P2RX_WPBP is up to you):

 

2.png

 

MANDT      P2RX_WPBP       MANDT

DCT_PERNR  P2RX_WPBP       DCT_PERNR

DCT_SEQNR  P2RX_WPBP       DCT_SEQNR

RT_APZNR   P2RX_WPBP_INDEX RT_APZNR

WPBP_APZNR P2RX_WPBP_INDEX WPBP_APZNR

BEGDA      P2RX_WPBP       BEGDA

ENDDA      P2RX_WPBP       ENDDA

MASSN      P2RX_WPBP       MASSN

MASSG      P2RX_WPBP       MASSG

STAT1      P2RX_WPBP       STAT1

STAT2      P2RX_WPBP       STAT2

STAT3      P2RX_WPBP       STAT3

AKTIVJN    P2RX_WPBP       AKTIVJN

BUKRS      P2RX_WPBP       BUKRS

WERKS      P2RX_WPBP       WERKS

BTRTL      P2RX_WPBP       BTRTL

KOSTL      P2RX_WPBP       KOSTL

PERSG      P2RX_WPBP       PERSG

PERSK      P2RX_WPBP       PERSK

ABART      P2RX_WPBP       ABART

PLANS      P2RX_WPBP       PLANS

GSBER      P2RX_WPBP       GSBER

VDSK1      P2RX_WPBP       VDSK1

ANSVH      P2RX_WPBP       ANSVH

ORGEH      P2RX_WPBP       ORGEH

STELL      P2RX_WPBP       STELL

ZTERF      P2RX_WPBP       ZTERF

SCHKZ      P2RX_WPBP       SCHKZ

EMPCT      P2RX_WPBP       EMPCT

KSOLL      P2RX_WPBP       KSOLL

ASOLL      P2RX_WPBP       ASOLL

SSOLL      P2RX_WPBP       SSOLL

KDIVI      P2RX_WPBP       KDIVI

ADIVI      P2RX_WPBP       ADIVI

SDIVI      P2RX_WPBP       SDIVI

DIVGV      P2RX_WPBP       DIVGV

BSGRD      P2RX_WPBP       BSGRD

TRFAR      P2RX_WPBP       TRFAR

TRFGB      P2RX_WPBP       TRFGB

TRFGR      P2RX_WPBP       TRFGR

TRFST      P2RX_WPBP       TRFST

KOSTVJN    P2RX_WPBP       KOSTVJN

DYSCH      P2RX_WPBP       DYSCH

ARBST      P2RX_WPBP       ARBST

WKWDY      P2RX_WPBP       WKWDY

FISTL      P2RX_WPBP       FISTL

GEBER      P2RX_WPBP       GEBER

FKBER      P2RX_WPBP       FKBER

GRANT_NBR  P2RX_WPBP       GRANT_NBR

SGMNT      P2RX_WPBP       SGMNT

BUDGET_PD  P2RX_WPBP       BUDGET_PD

 

Activate the view.

 

Now to create the DDL view: For this step it is necessary to have the ABAP development tools for eclipse installed.

 

Add the development system to the list of systems you are working with and create a package or chose one you will work with. Then right-click on it and chose: New->other abap repository object

 

3.png

 

Type ‘DDL’ on the filter popup:

 

4.png

 

Press “next” and input an object name and title on the next screen:

For example: Z_DDL_EVAL_INPER_RES, Payroll results evaluation periods. Press next. The system will prompt you to select a transport request to save the object, select a request and save.

Then, insert the following coding into the new created object and adjust it to the fields you need (in the code editor window), finally, activate the object:




---------------------------------------------------------------

@ClientDependent

@AbapCatalog.sqlViewName: 'ZPRX_RT_EVAL'

@EndUserText.label: 'Payroll results evluation periods'

 

view zp2rx_rt_evalp as

select from p2rx_rt as rt inner join vp2rx_wpbp_apznr as wpbp on

rt.mandt = wpbp.mandt and

rt.dct_pernr = wpbp.dct_pernr and

rt.dct_seqnr = wpbp.dct_seqnr and

rt.apznr = wpbp.rt_apznr

inner join p2rx_eval_period as eval on

rt.mandt     = eval.mandt and

rt.dct_pernr = eval.dct_pernr and

rt.dct_seqnr = eval.dct_seqnr

 

{

 

rt.dct_pernr,

rt.dct_seqnr,

//

rt.abart,

rt.lgart,

rt.apznr,

//rt.cntr1,

//rt.cntr2,

//rt.cntr3,

//rt.alznr,

//rt.c1znr,

//rt.btznr,

//rt.abznr,

//rt.v0typ,

//rt.v0znr,

rt.zeinh,

sum(rt.betpe) as sbetpe,

max(rt.betpe) as max_betpe,

min(rt.betpe) as min_betpe,

sum(rt.anzhl) as sanzhl,

sum(rt.betrg) as sbetrg,

sum( case eval.srtza when 'P' then betrg*-1 else rt.betrg end ) as rbetrg,

sum( case eval.srtza when 'P' then anzhl*-1 else rt.anzhl end ) as ranzhl,

//rt.anzhl) as sanzhl,

//sum(rt.betrg) as sbetrg,

rt.rte_curr,

rt.amt_curr,

//

eval.iabkrs,

eval.inper,

eval.ipend,

eval.inpty,

eval.inpid,

eval.srtza,

eval.abkrs,

eval.fpper,

eval.fpend,

eval.payty,

eval.payid,

//

 

 

wpbp.rt_apznr,

wpbp.wpbp_apznr,

wpbp.begda,

wpbp.endda,

wpbp.massn,

wpbp.massg,

wpbp.stat1,

wpbp.stat2,

wpbp.stat3,

wpbp.aktivjn,

wpbp.bukrs,

wpbp.werks,

wpbp.btrtl,

wpbp.kostl,

wpbp.persg,

wpbp.persk,

wpbp.abart as wpbp_abart,

wpbp.plans,

wpbp.gsber,

wpbp.vdsk1,

wpbp.ansvh,

wpbp.orgeh,

wpbp.stell,

//wpbp.zterf,

//wpbp.schkz,

//wpbp.empct,

//wpbp.ksoll,

//wpbp.asoll,

//wpbp.ssoll,

//wpbp.kdivi,

//wpbp.adivi,

//wpbp.sdivi,

//wpbp.divgv,

wpbp.bsgrd,

wpbp.trfar,

wpbp.trfgb,

wpbp.trfgr,

wpbp.trfst,

wpbp.kostvjn,

//wpbp.dysch,

//wpbp.arbst,

//wpbp.wkwdy,

//wpbp.fistl,

wpbp.geber

//wpbp.fkber,

//wpbp.grant_nbr,

//wpbp.sgmnt,

//wpbp.budget_pd

 

}

group by

rt.dct_pernr,

rt.dct_seqnr,

//

rt.abart,

rt.lgart,

rt.apznr,

//rt.cntr1,

//rt.cntr2,

//rt.cntr3,

//rt.alznr,

//rt.c1znr,

//rt.btznr,

//rt.abznr,

//rt.v0typ,

//rt.v0znr,

rt.zeinh,

//rt.anzhl) as sanzhl,

//sum(rt.betrg) as sbetrg,

rt.rte_curr,

rt.amt_curr,

//

eval.iabkrs,

eval.inper,

eval.ipend,

eval.inpty,

eval.inpid,

eval.srtza,

eval.abkrs,

eval.fpper,

eval.fpend,

eval.payty,

eval.payid,

//

 

 

wpbp.rt_apznr,

wpbp.wpbp_apznr,

wpbp.begda,

wpbp.endda,

wpbp.massn,

wpbp.massg,

wpbp.stat1,

wpbp.stat2,

wpbp.stat3,

wpbp.aktivjn,

wpbp.bukrs,

wpbp.werks,

wpbp.btrtl,

wpbp.kostl,

wpbp.persg,

wpbp.persk,

wpbp.abart,

wpbp.plans,

wpbp.gsber,

wpbp.vdsk1,

wpbp.ansvh,

wpbp.orgeh,

wpbp.stell,

//wpbp.zterf,

//wpbp.schkz,

//wpbp.empct,

//wpbp.ksoll,

//wpbp.asoll,

//wpbp.ssoll,

//wpbp.kdivi,

//wpbp.adivi,

//wpbp.sdivi,

//wpbp.divgv,

wpbp.bsgrd,

wpbp.trfar,

wpbp.trfgb,

wpbp.trfgr,

wpbp.trfst,

wpbp.kostvjn,

//wpbp.dysch,

//wpbp.arbst,

//wpbp.wkwdy,

//wpbp.fistl,

wpbp.geber

//wpbp.fkber,

//wpbp.grant_nbr,

//wpbp.sgmnt,

//wpbp.budget_pd

---------------------------------------------------------------


Note that the data dictionary relevant name is the one given here:

@AbapCatalog.sqlViewName: 'ZPRX_RT_EVAL'

 

 

Consuming the abap view ZPRX_RT_EVAL

 

Now the DDL view can be consumed from abap code, for example:


REPORT z_test.

data lt_test type table of ZPRX_RT_EVAL.

select  bukrs inper sum( rbetrg ) from ZPRX_RT_EVAL
into corresponding fields of table
lt_test
where bukrs = 'US01' and inper = '201401'
and lgart = '/101' group by  bukrs inper .

OR…

select bukrs inper fpper  srtza sum( rbetrg ) from ZPRX_RT_EVAL
into corresponding fields of table
lt_test
where bukrs = 'US01' and inper = '201301' and lgart = '/101'
group by  bukrs  srtza inper fpper
.

The results of queries above might be returned incredibly faster as if the same query is setup on the wagetype reporter (H99CWTR0). Note that there is no authorization filter on employee data here, so you must be careful when allowing users to access the report you create to access these queries.

 

An alternative to PNP authorizations can be also modeled within SQL by means of table PCTR_T_AUTH_INDX (available only in release SAP HR 608, see http://help.sap.com/erp_hcm_ias2_2014_01/helpdata/en/CF/EF985209274D27E10000000A441470/frameset.htm ). This will be discussed in a future post.

 

It is important to know that the amount of selected columns and the restriction applied on the where-clause play an important role on performance. Select as less columns as possible and restrict the groups for which you are running the queries on the where-clause.

This view will perform very well on aggregations, for example, performing a total of wagetypes per company code. For this it is important not to select the PERNR field (because if details are show per PERNR level, then the number of rows returned by the query will be large)

 

Similarly, other DDL views can be generated, with more complex SQL code

 

You can also test the view directly on SE16(but there the measures will not work since they will be also "grouped by"). There it makes sense to first select the output columns on the menu and to use some filters, since the unfiltered payroll data produced by this view might return several million rows.


Viewing all articles
Browse latest Browse all 889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>