Skip to Content
avatar image
Former Member

Getting last record from Infotype

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Aug 12, 2010 at 03: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 12, 2010 at 03: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 12, 2010 at 04: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.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 12, 2010 at 04: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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 12, 2010 at 05: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

    Add comment
    10|10000 characters needed characters exceeded