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: 

Using HR Macro to sort... is it possible?

Wil_Wilstroth
Active Participant
0 Kudos

Hi all,

I had been looking up and down my materials for a specific HR macro to do sorting. I couldn't found one.

Thus, is there a HR Macro that do sorting on infotypes?

Thanks

William Wilstroth

William Wilstroth
1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I think what you can do is put a sort statement inside the GET loop. For example, an infotype 0000 has been declared you can put the below sort statement before looping the infotype in a PROVIDE loop.

SORT P0000 BY BEGDA.

4 REPLIES 4

suresh_datti
Active Contributor
0 Kudos

Not sure what you meant by sort, but

Within a date range, <i>rp-provide-from-last</i> would give you the most recent record &

<i>rp-provide-from-first</i> will give you the earliet record.

~Suresh

Former Member
0 Kudos

Hi,

I think what you can do is put a sort statement inside the GET loop. For example, an infotype 0000 has been declared you can put the below sort statement before looping the infotype in a PROVIDE loop.

SORT P0000 BY BEGDA.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

As suggested, the below macros will help you to get the first and last records in time sort order respectively.

RP-PROVIDE-FROM-FRST

RP-PROVIDE-FROM-LAST

Here is an example.

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.

Wil_Wilstroth
Active Participant
0 Kudos

Hi Lily, Suresh and Jaya,

thanks for the reply, I guess there is no specific HR macro that can sort except if i use rp_provide_last or the rp_provide first... i think i use either one of this to accmplish my work.

Thanks a lot

William Wilstroth

William Wilstroth