08-11-2010 9:17 PM
Hi,
Is there FM or some other way (other then just getting all in internal table, srting, etc) of pulling just last/latest record for employee from pa0000?
thanks
08-12-2010 4:03 AM
Use macro : RP-PROVIDE-FROM-LAST
RP-PROVIDE-FROM-LAST inftytab subty beg end
REPORT ZTEST .
TABLES pernr.
INFOTYPES : 0000.
START-OF-SELECTION.
GET pernr.
WRITE : / 'Result from Macros'.
rp-provide-from-frst p0000 space pn-begda pn-endda.
IF pnp-sw-found = 1.
sucess
ENDIF.
08-12-2010 4:32 AM
Hi Emir
As suggested by pr@t, use RP-PROVIDE-FROM-LAST Macro to get the latest record of a pernr from the infotype tables.
Here is some additional info regarding this macro which i thought might be useful to you.
Refer to this [link|http://www.abaphr.com/macros-in-hr-abap/].
Hope this helps.
Harsh
08-12-2010 5:37 AM
Use this Macro.
Tables : PERNR.
INFOTYPES : 0001,0002.
Start-of-selection.
Get PERNR.
RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.
Write : / P0001-PERNR.
Thanks,
Srinivas.
08-12-2010 5:56 AM
Hello Emir,
To retrieve the latest/last record of an infotype use the macro
"RP_PROVIDE_FROM_LAST".
The functionality of this macro is that, it will retrieve the latest record of the infotype within the validity period.
The syntax is as follows :
RP_PROVIDE_FROM_LAST INFOTYPE SUBTYPE BEGDA ENDDA.
eg : RP_PROVIDE_FROM_LAST P0021 '1' PN-BEGDA PN-ENDDA.
In this example the latest record of the infotype 21 related to spouse data (subtype 1) in the period pn-begda and pn-endda is retrieved.
To check the successfulness of the record retrieval use PNP-SW-FOUND.
ie. if PNP-SW-FOUND = 0 --> Failed
else if PNP-SW-FOUND = 1 --> Successful.
Thanks & Regards
Santosh
08-12-2010 6:39 AM
Hi,
with the below logic, you can get the last record of the infotype;
TABLES: PA0000.
SELECT * FROM PA0000 UP TO 1 ROWS ORDER BY PERNR DESCENDING.
WRITE:/ PA0000-PERNR.
ENDSELECT.
thanks\
Mahesh