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: 

HR read infotype

Former Member
0 Kudos

Hi friends

I have to read recent (last) record from the following HR tables/infotypes. Shall I use RP_PROVIDE_FROM_LAST macro? Is there any other other good way to read data? Please give me some sample code. I will appreciate ur great help.

PA0001

PA0002

PA0006

PA0008

PA0041

HRP1001

HRP1015

Thanks in advance

Hari

5 REPLIES 5

former_member583013
Active Contributor
0 Kudos

Why don't you use <b>HR_READ_INFOTYPE</b>?

Greetings,

Blag.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Hari

The following coding shows you how to read any infotype (even simultaneously) for an employee.

METHOD get_infotype_0027 .
* define local data
  DATA:
    lif_employee      type if_pt_employee,
    lt_infotypes      TYPE tim_tmw_itlist_tab,
    lo_control        TYPE REF TO if_pt_td_control,
    lo_data           TYPE REF TO if_pt_td_base,
    lo_pnnnn          TYPE REF TO if_pt_td_itnnnn,
    ls_p0027          TYPE p0027.



* Create employee instance
  lif_employee = cl_pt_employee=>get_employee( p_pernr ).

* Append all required infotypes to itab
  APPEND '0027' TO lt_infotypes.

  CALL METHOD lif_employee->get_infotypes
    EXPORTING
      i_itlist      = lt_infotypes
      i_fromdate    = id_fromdate
      i_todate      = id_todate
*      I_FILTER      =
      i_noauthcheck = 'X'
    IMPORTING
      e_result      = me->mt_infty_request
      e_retcd       = me->md_retcd.
* Please see documentation of parameter e_retcd...


  LOOP AT me->mt_infty_request INTO lo_control.
    lo_data = lo_control->data.  " get data object

*   Casting
    TRY.
        lo_pnnnn ?= lo_data.

      CATCH cx_sy_move_cast_error.
        CONTINUE.
    ENDTRY.

*   Convert infotype (semi-transparent -> transparent)
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
      EXPORTING
        prelp = lo_pnnnn->prelp
      IMPORTING
        pnnnn = ls_p0027.

    APPEND ls_p0027 TO rt_p0027.
  ENDLOOP.


* Store infotype 0027 data
  me->mt_p0027 = rt_p0027.

ENDMETHOD.

Unfortunately, I do not have a similar solution for the HRP... tables.

Regards

Uwe

0 Kudos

For HRP tables, you have to use select statements.

0 Kudos

Hello Uwe,

The example that you gave us is very useful. When I implement your example I faced the following issues: I think it is mainly due to with SAP version that we use 4.6C. It seems to me SAP delivered Class "CL_PT_EMPLOYEE" in 4.6c which means there may be a way to implement this class.

Here are the problems:

1) When I typecast to "go_pnnnn ?= go_data." in order to obtain semi-transparent hr infotype data in PRELP, basically SAP short dumps at that line. I think the reason is winden-casting is not possible from go_data(type if_pt_td_base [super class]) to go_pnnnn (if_pt_td_itnnnn [sub class]).

2) Try, catch block doesn't get supported in 4.6c

3) I need to then type cast the "PRELP" to obtain infotype record. But the class in the example "CL_HR_PNNNN_TYPE" does not available in 4.6C version. But I think there is another way to obtain the same results.

4) Instead of write a method (e.g. get_infotype_0027) for each infotype, is it possible to write a generic method to read data for many infotypes at one time or pass infotype as a parameter ?

Please correct me if I am wrong and also please can you help me on this ?

Thank you

Muralitharan

amit_khare
Active Contributor
0 Kudos

Hi,

if possible try to use PNP logiacl database to extract all these values then with the same macro you will be able to the accurate value.

For IT 41 you may use FM - 'HR_ECM_GET_DATETYP_FROM_IT0041'.

For HRP tables either use select or FM 'RH_READ_OBJECT'.

I will suggest you to use FM since there is a major performance issues with HRP1001.

Regards,

Amit