Accessing Cluster Tables

5
2/13/12 AcceVVing ClXVWeU TableV 1/5 fXlleU.miW.edX/hU/clXVWeU_WableV.hWml Accessing Cluster Tables in SAP Pa\roll Custer Tables KWWS://ZZZ.SODQHWVDS.FRP/ HR_ABAP_SD\UROO.KWP COXVWHU WDEOHV FRPELQH WKH GDWD IURP VHYHUDO WDEOHV ZLWK LGHQWLFDO (RU DOPRVW LGHQWLFDO) NH\V LQWR RQH SK\VLFDO UHFRUG RQ WKH GDWDEDVH. DDWD LV ZULWWHQ WR D GDWDEDVH LQ FRPSUHVVHG IRUP. RHWULHYDO RI GDWD LV YHU\ IDVW LI WKH SULPDU\ NH\ LV NQRZQ. COXVWHU WDEOHV DUH GHILQHG LQ WKH GDWD GLFWLRQDU\ DV WUDQVSDUHQW WDEOHV. E[WHUQDO SURJUDPV FDQ NOT LQWHUSUHW WKH GDWD LQ D FOXVWHU WDEOH. SSHFLDO ODQJXDJH HOHPHQWV EXPORT TO DATABASE, IMPORT TO DATABASE DQG DELETE FROM DATABASE DUH XVHG WR SURFHVV GDWD LQ WKH FOXVWHU WDEOHV. PCL1 - DDWDEDVH IRU HR ZRUN DUHD; (ORQJ WH[W , HWF) PCL2 - AFFRXQW LQJ RHVXOWV (WLPH, WUDYHO H[SHQVH DQG SD\UROO); (pa\roll results ) PCL3 - ASSO LFDQW WUDFNLQJ GDWD; PCL4 - DRFX PHQWV, PD\UROO \HDU-HQG TD[ GDWD (change logs , HWF) Database Tables PCLn PCLQ GDWDEDVH WDEOHV DUH GLYLGHG LQWR VXEDUHDV NQRZQ DV GDWD FOXVWHUV. DDWD COXVWHUV DUH LGHQWLILHG E\ D WZR-FKDUDFWHU FRGH. H.J RU IRU US SD\UROO UHVXOW, B2 IRU WLPH HYDOXDWLRQ UHVXOW, TX IRU ORQJ WH[W , LA IRU FKDQJH ORJV. EDFK HR VX EDUHD KDV LWV RZQ FOXVWHU. EDFK VX EDUHD KDV LWV RZQ NH\. Database Table PCL1 TKH GDWDEDVH WDEOH PCL1 FRQWDLQV WKH IROORZLQJ GDWD DUHDV: B1 WLPH HYHQWV/ PDC G1 JURXS LQFHQWLYH ZDJHV L1 LQGLYLGXDO LQFHQWLYH ZDJHV PC SHUVRQDO FDOHQGDU TE WUDYHO H[SHQVHV/SD\UROO UHVXOWV TS WUDYHO H[ SHQVHV/PDVWHU GDWD TX LQIRW\SH WH[WV ZI PDC LQWHUIDFH -> FRVW DFFRXQW SRTFD (PSKEY) = SHUQU (8) LQIR W\SH (4) VXEW\SH (4) REM LG (2) ORFN (1) HQGGD (8) EHJGD (8) VHTQU (3) Database Table PCL2 TKH GDWDEDVH WDEOH PCL2 FRQWDLQV WKH IROORZLQJ GDWD DUHDV: B2 WLPH DFFRXQWLQJ UHVXOWV CD FOXVWHU GLUHFWRU\ RI WKH CD P DQDJHU PS JHQHUDWHG VFKHPDV PT WH[WV IRU JHQHUDWHG VFKHPDV

Transcript of Accessing Cluster Tables

Page 1: Accessing Cluster Tables

2/13/12 Accessing Cluster Tables

1/5fuller.mit.edu/hr/cluster_tables.html

Accessing Cluster Tables in SAP

Payroll Custer Tables

http://www.planetsap.com/HR_ABAP_payroll.htm

Cluster tables combine the data from several tables with identical (or almost identical) keys into one physical record on the database.Data is written to a database in compressed form.Retrieval of data is very fast if the primary key is known.Cluster tables are defined in the data dictionary as transparent tables.External programs can NOT interpret the data in a cluster table.Special language elements EXPORT TO DATABASE, IMPORT TO DATABASE and DELETE FROM DATABASE are used toprocess data in the cluster tables.

PCL1 - Database for HR work area; (long text, etc)PCL2 - Accounting Results (time, travel expense and payroll); (payroll results)PCL3 - Applicant tracking data; PCL4 - Documents, Payroll year-end Tax data (change logs, etc)

Database Tables PCLn

PCLn database tables are divided into subareas known as data clusters.Data Clusters are identified by a two-character code. e.g RU for US payroll result, B2 for time evaluation result, TX for long text, LA for change logs.Each HR subarea has its own cluster.Each subarea has its own key.

Database Table PCL1

The database table PCL1 contains the following data areas:

B1 time events/PDCG1 group incentive wages L1 individual incentive wagesPC personal calendarTE travel expenses/payroll resultsTS travel expenses/master dataTX infotype textsZI PDC interface -> cost account

SRTFD (PSKEY) = pernr (8) info type (4) subtype (4) obj id (2) lock (1) endda (8) begda (8) seqnr (3)

Database Table PCL2

The database table PCL2 contains the following data areas:

B2 time accounting resultsCD cluster directory of the CD managerPS generated schemasPT texts for generated schemas

Page 2: Accessing Cluster Tables

2/13/12 Accessing Cluster Tables

2/5fuller.mit.edu/hr/cluster_tables.html

RX payroll accounting results/internationalRn payroll accounting results/country-specific ( n = HR country indicator RU for US payroll result)ZL personal work schedule

SRTFD (PC200) = pernr (8) sequence (5)

Database Table PCL3

The database table PCL3 contains the following data areas:

AP action log / time scheduleTY texts for applicant data infotypes

Database Table PCL4

The database table PCL4 contains the following data areas:

LA change logs (long term documents)SA Short-Term Documents for HR Master DataSB Short-Term Documents for Applicant Master

SRTFD (PC400) = trans class always A for master data (1) pernr (8) info type (4) modified date (8) modified time (8) seqnr (4)

Data Management of PCLn

The ABAP commands IMPORT and EXPORT are used for management of read/write to database tables PCLn.A unique key has to be used when reading data from or writing data to the PCLn.

MANDT(3) clientRELID (2) cluster ID (RU,TX, LA..)SRTFD (40) Work Area KeySRTF2 (4) Sort key for dup. key

Cluster Definition

Naming convention for INCLUDES when defining clusters. These INCLUDES will define the work area key above and the cluster data that isreturned from an IMPORT:

RPCnxxy0

n = 1, 2, 3 or 4 (for PCL1, PCL2, PCL3, PCL4) xx = cluster ID y = country grouping (0 for international otherwise country indicator T500L)Description of Cluster Data using Cluster RX as an Example The data description is stored in the include RPC2RX00 in accordance with the above naming conventions.

Page 3: Accessing Cluster Tables

2/13/12 Accessing Cluster Tables

3/5fuller.mit.edu/hr/cluster_tables.html

RPC1TX00 - Long text cluster ID in table PCL1RPC2RUU0 - Payroll results for the US cluster ID in table PCL2RPC4LA00 - Change log cluster ID in table PCL4

Importing Data (I)

The IMPORT command causes data objects with the specified key values to be read from PCLn.If the import is successful, SY-SUBRC is 0; if not, it is 4.

REPORT ZRPIMPORT. TABLES: PCLn. INCLUDE RPCnxxy0. "Cluster definition * Fill cluster Key * Import record IMPORT TABLE1 FROM DATABASE PCLn(xx) ID xx-KEY. IF SY-SUBRC EQ 0. * Display data object ENDIF.

See sample program for long text.

Importing data (II)

Import data using macro RP-IMP-Cn-xy.Check return code SY-SUBRC. If 0, it is successful. If 4, error.Need include buffer management routines RPPPXM00

REPORT ZRPIMPORT. *Buffer definition INCLUDE RPPPXD00. DATA: BEGIN OF COMMON PART 'BUFFER'. INCLUDE RPPPXD10. DATA: END OF COMMON PART 'BUFFER'. *import data to buffer RP-IMP-Cn-xy. .... *Buffer management routines INCLUDE RPPPXM00.

Cluster Authorization

Simple EXPORT/IMPORT statement does not check for cluster authorization.Use EXPORT/IMPORT via buffer, the buffer management routines check for cluster authorization.

rpcbdt00 - include needed for importing from database PCL4(la) (Change log cluster ID)

When we upgraded to ERP2005, we encountered a problem because a couple of our programs tested the version (VERNR) number todetermine which structure the detail used. The SAP include program, RPCBDT00, indicates that VERNR 01 & 02 use the same structure whichis PC404. Therefore, we made our programs match SAP.

Payroll Results (I)

US Payroll results are stored in cluster RU of PCL2 as field string and internal tables.Standard reports read the results from cluster RU.

Report RPCLSTRU lists all US payroll results;

Page 4: Accessing Cluster Tables

2/13/12 Accessing Cluster Tables

4/5fuller.mit.edu/hr/cluster_tables.html

Report RPCEDTU0 lists the US results on a payroll form.

Payroll Results (II)

The cluster definition of payroll results is stored in two INLCUDE reports:include: RPC2RX09. "Definition Cluster Ru (I)include: RPC2RUU0. "Definition Cluster Ru (II)

The first INCLUDE defines the country-independent part; The second INCLUDE defines the country-specific part (US).The cluster key is stored in the field string RX-KEY.

RX-KEY = (PC200) = pernr (8) sequence (5)

Payroll Results (III)

All the field string and internal tables stored in PCL2 are defined in the ABAP/4 dictionary. This allows you to use the same structures indifferent definitions and nonetheless maintain data consistency.The structures for cluster definition comply with the name convention PCnnn. Unfortunately, 'nnn' can be any set of alphanumericcharacters.To read payroll results, you need two keys: pernr and seqnoYou can get SEQNO by importing the cluster directory (CD) for a pernr first. (see cluster directory)

*Key definition DATA: BEGIN OF RX-KEY. INCLUDE STRUCTURE PC200. DATA: END OF RX-KEY.

*Payroll directory DATA: BEGIN OF RGDIR OCCURS 100. INCLUDE STRUCTURE PC261. DATA: END OF RGDIR. Payroll Cluster Directory

REPORT ZHRIMPRT. TABLES: PERNR, PCL1, PCL2. INLCUDE: RPC2CD09. "definition cluster CD PARAMETERS: PERSON LIKE PERNR-PERNR. ... RP-INIT-BUFFER. " macro to get one person at a time based on single parameter for pernr*Import cluster Directory CD-KEY-PERNR = PERNR-PERNR. RP-IMP-C2-CU. " defined in include file CHECK SY-SUBRC = 0. LOOP AT RGDIR. RX-KEY-PERNR = PERSON. UNPACK RGDIR-SEQNR TO RX-KEY-SEQNO. " converts rgdir-seqnr (numc 5) to packed and moves to char 5 *Import data from PCL2 RP-IMP-C2-RU.

Page 5: Accessing Cluster Tables

2/13/12 Accessing Cluster Tables

5/5fuller.mit.edu/hr/cluster_tables.html

INLCUDE: RPPPXM00. "PCL1/PCL2 BUFFER HANDLING

Function Module (I)

CD_EVALUATION_PERIODS

After importing the payroll directory, which record to read is up to the programmer.Each payroll result has a status.

'P' - previous result'A' - current (actual) result'O' - old result

Function module CD_EVALUATION_PERIODS will restore the payroll result status for a period when that payroll is initially run. It alsowill select all the relevant periods to be evaluated.

Function Module (II)

CD_EVALUATION_PERIODS

call function 'CD_EVALUATION_PERIODS' exporting bonus_date = ref_periods-bondt " Key Date for Check (optional) inper_modif = pn-permo " Period parameters inper = ref_periods-inper " Payroll Period pay_type = ref_periods-payty " Payroll category (optional) pay_ident = ref_periods-payid " Payroll identifier (optional) tables rgdir = rgdir " Cluster Directory evpdir = evp " Periods to be Evaluated iabkrs = pnpabkrs " Payroll Areas (optional) exceptions no_record_found = 1.

Authorization Check

Authorization for Persons

In the authorization check for persons, the system determines whether the user has the authorizations required for the organizationalfeatures of the employees selected with GET PERNR.Employees for which the user has no authorization are skipped and appear in a list at the end of the report.Authorization object: 'HR: Master data'

Authorization for Data

In the authorization check for data, the system determines whether the user is authorized to read the infotypes specified in the report.If the authorization for a particular infotype is missing, the evaluation is terminated and an error message is displayed.

Deactivating the Authorization Check

In certain reports, it may be useful to deactivate the authorization check in order to improve performance. (e.g. when running payroll)You can store this information in the object 'HR: Reporting'.