Application Development and Automation 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: 
Read only

HR Programming

Former Member
0 Likes
1,714

I want to know how to retrieve the latest infotype for a particular employee or a list of employees. What is the shortcut. Can somebody give a sample code?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,591

You can use HR_READ_INFOTYPE too.

If the requirement is to read the most current Infotype, you have to pass sy-datum as the BEGDA & ENDDA in this FM.

If the requirement is to read the last Infotype record, you have to pass '18000101' as the BEGDA & '99991231' ENDDA, then sort the Return itab by BEGDA Descending, so that the first record is the Last Infotype record.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = Pernr

infty = '9010' (example)

begda = <begin date>

endda = <end date.

TABLES

infty_tab = p9010

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

16 REPLIES 16
Read only

Former Member
0 Likes
1,591

Hi Rane,

Using logincal database you can do this

Ex: PNP

*Main Prog.

Get Pernr

  • form

rp-provide-from-last p0000 0000 pnpbegde pnpbegda.

if pnp-sw-found eq 1.

<your process>

endif.

Best Regards,

Aslam Riaz

Read only

Former Member
0 Likes
1,591

This will require declaring INFOTYPE: 0001. Statement.

This is obsolete now so how can one retrieve the data without declaring Infotypes. Please email me a sample Infotype program at paragrane@yahoo.com.

Read only

0 Likes
1,591

INFOTYPES statement is not obsolete (at least in 4.7). It cannot be used in ABAP OO context. But most of HR reports use PNP (or PNPCE) logical databases, and therefore use INFOTYPES statement.

Message was edited by: Sergei Korolev

Read only

0 Likes
1,591

Hi,

just want to add on to what Sergei mentioned..

Basically, the statement INFOTYPES: 0001 declares an internal table of structure p0001 with header line. And in ABAP Objects declaring tables in this way is not allowed. Hence INFOTYPEs statement cannot be used in ABAP Objects but is not 'Obsolete'.

hope this is clear..

Regards,

Suresh Datti

Read only

0 Likes
1,591

INFOTYPES statement is obsolete in 5.0.

Read only

Former Member
0 Likes
1,591

Are you sure, declaring INFOTYPE is become obselete? We are still using in 4.7 and never had any probelm, never got any warning messages. Are you working on 5.0 and is it obselete in that version?

Read only

0 Likes
1,591

It is Obsolete in 5.0

Read only

Former Member
0 Likes
1,591

Try using this sample code, if it helps, please close the issue with appropriate points.

Good luck.

DATA: gs_return TYPE bapireturn1,

gs_key TYPE bapipakey OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'HR_INFOTYPE_GETLIST'

EXPORTING

infty = '0001'

number = '1009'

  • SUBTYPE =

timeintervallow = '20051212'

timeintervalhigh = '20051212'

tclas = 'A'

IMPORTING

return = gs_return

TABLES

key = gs_key

.

LOOP AT gs_key.

WRITE:/ gs_key.

ENDLOOP.

Read only

0 Likes
1,591

I need to get an internal table for a range of employees passed to the bapi thru an internal table

Read only

0 Likes
1,591

It does not return the latest infotype but returns all data for the employee. I want only latest and for a range of employees passed thru an internal table.

Read only

Former Member
0 Likes
1,592

You can use HR_READ_INFOTYPE too.

If the requirement is to read the most current Infotype, you have to pass sy-datum as the BEGDA & ENDDA in this FM.

If the requirement is to read the last Infotype record, you have to pass '18000101' as the BEGDA & '99991231' ENDDA, then sort the Return itab by BEGDA Descending, so that the first record is the Last Infotype record.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = Pernr

infty = '9010' (example)

begda = <begin date>

endda = <end date.

TABLES

infty_tab = p9010

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

Read only

0 Likes
1,591

hi

use hr_read_infotype and pass the relevant date u'll get the data!!

PLease reward points for this post if it helps!!

regards

gunjan

Read only

0 Likes
1,591

I need to pass an internal table having many Employees and get an internale table in return for a particulat employee.

Read only

Former Member
0 Likes
1,591

Hi Parag,

Even I didnt see any problem using infotypes

declaration in 4.7 version.

Please let us know which version you r working?

Meanwhile u can use the function module

<b>'HR_READ_INFOTYPE'</b>.

Thanks&Regards,

Siri.

Read only

Former Member
0 Likes
1,591

Hi,

As I explained in my prvious reploy you can use

CALL FUNCTION 'HR_INFOTYPE_GETLIST' or you can also use HR_READ_INFOTYPE suggested by our co forum Gurus.

It should work.

Good luck.

Venu

Read only

Former Member
0 Likes
1,591

Hi Parag,

Just repeating what others have already said.

But this is the BEST way to work

with HR programming and its infotypes

rather than using logical database

and keyword infotypes.

1. Declare Internal table in this fashion

and use the FM recommended by SAP

2. Data : P0001 Like table of P0001 with header line.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

  • TCLAS = 'A'

pernr = '55'

infty = '0001'

  • BEGDA = '18000101'

  • ENDDA = '99991231'

  • BYPASS_BUFFER = ' '

  • LEGACY_MODE = ' '

  • IMPORTING

  • SUBRC =

tables

infty_tab = P0001

  • EXCEPTIONS

  • INFTY_NOT_FOUND = 1

  • OTHERS = 2

.

Regards,

Amit M.