Wednesday, 28 September 2016

How To Create SAP ABAP HR Reports Using A Logical Database (LDB).


Step 1: Create an executable program.

·         Go to SE38 transaction code.
·         Create program ZTEST_LDB_PRORGRAM. (1) Provide meaningful report Title (2) select Type as Executable Program (3) provide Logical Database as PNP and SAVE. Save as local / transportable.


Step 2: Assign the Report category. 

Report Category specify which master data fields to be displayed on selection-screen. When you assign logical database PNP to the program,  default report category is assigned. The selection-screen of the default report  category. 


·         Creation of the new Report Category
·         Steps to change default Report category to other category.











Step 3: ABAP Source code in the LDB program: 

·         Simple ABAP program with pnp logical database.
·         REPORT ztest_ldb_program.
·          
·         NODES: pernr.
·          
·         INFOTYPES:
·               0001,0002,0006.
·          
·         START-OF-SELECTION.
·          
·         GET pernr.
·          
·           rp-provide-from-last p0002 space pn-begda pn-endda.
·           IF pnp-sw-found = '1'.
·             WRITE: p0002-pernr, p0002-vorna, p0002-nachn.
·           ENDIF.
·          
·         END-OF-SELECTION.
·  

       NODES pernr:  We have to know about NODES statement. NODES statement is to pass data from logical databases to executable programs. Basically it defines an interface work area(In this case PERNR is workarea) and is allowed only in the global declaration section of executable programs that are associated with a logical database.
·         PERNR structure at SE11* .
·         INFOTYPES statement: It is used to define an internal table for HR Infotypes. When you define INFOTYPES 0001, An internal table P0001 is created with the structure of the info type P0001 and a header.
·         Standard LDB Selection Screen: When you use logical database selection screen, ldb PNP program filters employees based on selection input. 
·         When you use custom Selection fields along with logical database selection, filtering needs to be taken in our custom program .
·         GET pernr event: This event has to be used when program is associated with logical data base. When you run the program, When GET pernr event is triggered,  the interface workarea(PERNR) defined with NODES statement is populated and also all the tables defined using INFOTYPES statement also populated with data for one employee. One employee information is available until END-OF-SELECTION event. GET pernr event is triggered for each employee selected based on the selection screen input. 
Macro are used in HR LDB programs. All macro definitions are found
in Include DBPNPMAC. RP-PROVIDE-FROM-LAST macro is used to get latest record in the given period(PN-BEGDA and PN-ENNDA).

Step 4. Activate and Test the program


selection screen data:-

output :-



HR ABAP - Infotype tables and their structures

HR ABAP - Infotype tables and their structures


HR
Division

Infotypes

Screens

Structure

    Table
Infotype
Specific
Structure

Module
pool

Dialog
program
P.Admin.
Payroll


0000-0999
1000,
2000,
3000.


Pnnnn


PAnnnn


PSnnnn


MPnnnn00


RP_nnnn
P.D & Org.
1000-1999
    ,,
Pnnnn
HRPnnnn
HRInnnn
MPnnnn00
RH_INFOTYP_nnnn
Time Mgmt
2000-2999
    ,,
Pnnnn
PAnnnn
PSnnnn
MPnnnn00
RP_nnnn
Recruitment
4000-4999
    ,,
Pnnnn
PBnnnn
PSnnnn
MPnnnn00
RP_nnnn
-Do not   
    Use-
3000-3999
5000-8999

    -

    -

   -

   -

    -

     -
Custom
Infotypes
9000-9999
   ,,
Pnnnn
PAnnnn(PA&TM)
HRPnnnn(PD)
PBnnnn(Applicant)

PSnnnn
(PA,TM,AP)
HRInnnn(PD)
MPnnnn00
RP_nnnn
RH_INFOTYP_nnnn




















Each infotype has a database table and a structure associated with it. As HR is related to time , we require old data as well as new data. The data we enter into the infotypes are automatically checked for accuracy and against the table entries. In simple, HR data is huge and to access data easily we require infotype. It is easy to group huge data using Infotypes.

*nnnn  = Infotype number
*PA = Personnel Administration
*TM = Time Management
*PD = Personnel Development