Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting last record from Infotype

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

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.

former_member217316
Contributor
0 Kudos

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

Former Member
0 Kudos

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.

santosh_dv
Explorer
0 Kudos

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

former_member222860
Active Contributor
0 Kudos

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