Professional Documents
Culture Documents
HR Abap LDB: Logical Database
HR Abap LDB: Logical Database
Logical database
A logical database is a special ABAP/4 program which combines the contents of
certain database tables. Using logical databases facilitates the process of reading
database tables.
To use logical database PNP in your program, specify in your program attributes.
Date selection
Date selection delimits the time period for which data is evaluated. GET
PERNR retrieves all records of the relevant infotypes from the database.
When you enter a date selection period, the PROVIDE loop retrieves the
infotype records whose validity period overlaps with at least one day of this
period.
Person selection
Person selection is the 'true' selection of choosing a group of employees for
whom the report is to run.
Sorting Data
· The standard sort sequence lists personnel numbers in ascending order.
· SORT function allows you to sort the report data otherwise. All the sorting
fields are from infotype 0001.
Report Class
· You can suppress input fields which are not used on the selection screen by
assigning a report class to your program.
· If SAP standard delivered report classes do not satisfy your requirements,
you can create your own report class through the IMG.
Start-of-selection.
GET PERNR.
End-0f-selection.
Infotype structures (after GET PERNR) are internal tables loaded with data.
The infotype records (selected within the period) are processed sequentially
by the PROVIDE - ENDPROVIDE loop.
GET PERNR.
PROVIDE * FROM Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA
If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. endif.
ENDPROVIDE.
Period-Related Data
All infotype records are time stamped.
Which record to be read depends on the date selection period specified on the
selection screen. PN/BEGDA PN/ENDDA.
Current Data
IT0006 Address - 01/01/1990 12/31/9999 present
Process Infotypes
REPORT ZHR00001.
INFOTYPE: 0002.
PARAMETERS: PERNR LIKE P0002-PERNR.
RP-READ-INFOTYPE PERNR 0002 P0002 <BEGIN> <END>.
PROVIDE * FROM P0002
if ... then ...endif.
ENDPROVIDE.
The RP-UPDATE macro updates the database. The parameters of this macro are the
OLD internal table containing the unchanged records and the NEW internal table
containing the changed records. You cannot create or delete data. Only modification
is possible.
INFOTYPES: Pnnnn NAME OLD,
Pnnnn NAME NEW.
GET PERNR.
PROVIDE * FROM OLD
WHERE .... = ... "Change old record
*Save old record in alternate table
NEW = OLD.
ENDPROVIDE.
RP-UPDATE OLD NEW. "Update changed record
b. In the infotype structure, fields are grouped by the same name followed by
sequence number.
P0005-UARnn P0005-UANnn P0005-UBEnn
P0005-UENnn P0005-UABnn
Repeat Structures
· Data is entered on the infotype screen in table format but stored on the database in
a linear
structure.
· Each row of the table is stored in the same record on the database.
· When evaluating a repeat structure, you must define the starting point, the
increment and the
work area which contains the complete field group definition.
GET PERNR.
RP-PROVIDE-FROM-LAST P0005 SPACE PN/BEGDA PN/ENDDA.
DO 6 TIMES VARYING VACATION
FROM P0005-UAR01 "Starting point
NEXT P0005-UAR02. "Increment
If p0005-xyz then ... endif.
ENDDO.
HR ABAP - Time
Database Tables in HR
· Personnel Administration (PA) - master and time data infotype tables (transparent
tables).
PAnnnn: e.g. PA0001 for infotype 0001
· Personnel Development (PD) - Org Unit, Job, Position, etc. (transparent tables).
HRPnnnn: e.g. HRP1000 for infotype 1000
Cluster Table
· 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 to process data in the cluster tables.
Cluster Definition
· The data definition of a work area for PCLn is specified in separate programs which
comply
with fixed naming conventions.
· They are defined as INCLUDE programs (RPCnxxy0). The following naming
convention applies:
n = 1 or 2 (PCL1 or PCL2)
xx = Relation ID (e.g. RX)
y = 0 for international clusters or country indicator (T500L) for different country
cluster
REPORT ZHREXPRT.
TABLES: PCLn.
INCLUDE: RPCnxxy0. "Cluster definition
* Fill cluster KEY
xy-key-field = <value>.
* Fill data object
....
* Export record
EXPORT TABLE1 TO DATABASE PCLn(xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
WRITE: / 'Update successful'.
ENDIF.
REPORT ZHREXPRT.
*Buffer definition
INCLUDE RPPPXD00. INCLUDE RPPPXM00. "Buffer management
DATA: BEGIN OF COMMON PART 'BUFFER'.
INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
...
RP-EXP-Cn-xy.
IF SY-SUBRC EQ 0.
PERFORM PREPARE_UPDATE USING 'V'..
ENDIF.
REPORT RPIMPORT.
TABLES: PCLn.
INCLUDE RPCnxxy0. "Cluster definition
* Import record
IMPORT TABLE1 FROM DATABASE PCLn(xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
* Display data object
ENDIF.
REPORT RPIMPORT.
*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.
The first INCLUDE defines the country-independent part; The second INCLUDE
defines the country-specific part (US).
*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.
Authorization Check
Authorization for Persons
· In the authorization check for persons, the system determines whether the user
has the
authorizations required for the organizational features 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'