2012 Dec 06 4:07 AM
HI all,
I am trying to execute a standard program,
but in GET PERNR event for some employees its taking the pernr-pernr as the employee number
but for some employee spernr-pernr is showing as "###########" like this . so i am not getting the data for those employees.
Please advise on this.
2012 Dec 06 4:19 AM
hi,
refer this link it will be helpful,
http://wiki.sdn.sap.com/wiki/display/Snippets/Report+in+HR+ABAP+(LDB)
2012 Dec 06 4:25 AM
Hi Vinoth,
the link is not available it seems.
when i tried to open that link i am getting the PAGE IS NOT FOUND.
2012 Dec 06 4:43 AM
hi,
refer this code.
http://help.sap.com/saphelp_47x200/helpdata/en/4f/d527ba575e11d189270000e8322f96/content.htm
Using Logical Database and Macro
Logical Databases used In HR:
PAP
PNP
PNPCE - Enhanced version of PNP available form SAP Enterprise version onwards
PCH
PTRVP
The LDB PAP is for Applicant administration, PNP and PNPCE for Personnel
Management, PCH for Organisational Management and PTVRP for Travel
Management.
The Logical Databases PNP/PNPCE and PCH are mostly used.
Step 1:
In the program attributes, include the name of the logical database.
If you want to customize selection screen, you can use HR report category button. But in this document, we are using PNP logical database selection screen itself.
Step2: We can see Logical database structure (Tcode SE36) PNP has PERNR in top. PERNR is a data dictionary structure without a database. That should be declared in program as
Tables PERNR.
After writing the statement and adding PNP in program attributes, if we execute the program we can see the selection screen of Logical Database PNP.
Step 3: We need to mention the infotypes we need from the LDB using infotypes declaration. In our program, we need data from organization data (Infotype 0001).
Infotypes 0001.
Step 4: Inorder to get the data inside the p0001, we need to mention GET PERNR statement inside start-of-selection and end-of-selection.
Event keywords for data retrieval from a logical database have the following syntax.
GET <TABLE>.
start-of-selection.
get pernr.
End-of-selection.
This statement will fetch the employee one at a time inside the block start-of-selection and end-of-selection. At the GET PERNR event, the PERNR structure contains the data for a
personnel number chosen on the basis for selection screen entries. The PERNR-PERNR field contains the personnel number which is selected for processing. Only the PERNR-PERNR field should be read from the work area of the PERNR table. The other fields are intended for internal use only.
Step 5: We can use Macros to get the particular record for that pernr.
Some of the Macros used in PNP logical database are:
RP-PROVIDE-FROM-FRST - Retrieve particular employee first record in the selected period.
RP-PROVIDE-FROM-LAST - Retrieve particular employee last record in the selected period.
The parameters to be passed to those macros are structure, subtype, begda and endda.
You can see the MACROS in database TRMAC table.
RP-READ-INFOTYPE - Retrieve all the records of the particular employee in the selected period.
Parameters to be passed to this macros are:
PERNR PERSONALNUMBER
INFTY INFOTYPNUMBER
INFTY-TABLE OUTPUT-TABLE LIKE PNNNN
BEGDA INTERVAL-BEGIN
ENDDA INTERVAL-END
Step 6: After calling the macro, PNP-SW-FOUND should be checked. If it is equal to 1,then it means the data is retrieved successfully. If it is equal to zero, then there is no entry.
TABLES pernr.
INFOTYPES : 0001.
START-OF-SELECTION.
GET pernr.
WRITE : / 'Result from Macros'.
rp-provide-from-frst p0001 space pn-begda pn-endda.
IF pnp-sw-found = 1.
WRITE : / '-------------------------------------'.
WRITE : / 'Result from rp-provide-from-frst'.
WRITE : / '-------------------------------------'.
WRITE : / p0001-pernr, p0001-begda, p0001-endda.
ENDIF.
rp-provide-from-last p0001 space pn-begda pn-endda.
IF pnp-sw-found = 1.
WRITE : / '-------------------------------------'.
WRITE : / 'Result from rp-provide-from-last'.
WRITE : / '-------------------------------------'.
WRITE : / p0001-pernr, p0001-begda, p0001-endda.
ENDIF.
rp-read-infotype pernr-pernr 0001 p0001 pn-begda pn-endda.
IF pnp-sw-found = 1.
WRITE : / '-------------------------------------'.
WRITE : / 'Result from rp-read-infotype'.
WRITE : / '-------------------------------------'.
LOOP AT p0001.
WRITE : / p0001-pernr, p0001-begda, p0001-endda.
ENDLOOP.
ENDIF.
END-OF-SELECTION.
Using Logical Database and ProvideEndProvide
Follow Steps 1 to 4 as explained above.
Step 5 : The infotype records are processed sequentially by PROVIDE-ENDPROVIDE loop.
provide * from p0001 between pn-begda and pn-endda.
write : / p0001-pernr, p0001-begda, p0001-endda.
endprovide.
TABLES pernr.
INFOTYPES : 0001.
START-OF-SELECTION.
GET pernr.
WRITE : / '-------------------------------------'.
WRITE : /'Result from ProvideEndprovide'.
WRITE : / '-------------------------------------'.
PROVIDE * FROM p0001 BETWEEN pn-begda AND pn-endda.
WRITE : / p0001-pernr, p0001-begda, p0001-endda.
ENDPROVIDE.
END-OF-SELECTION.