SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Unified Access to All HR Infotypes



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri Sep 07, 2007 11:58 pm    Post subject: Unified Access to All HR Infotypes Reply with quote

Author: Uwe Schieferstein

The code snippet shows how to access any HR infotype using unified class-based methods.
The SAP standard class CL_PT_EMPLOYEE provides us with two methods for reading either a default set of infotypes or any other required infotype(s).
The infotypes are returned either in transparent form (default infotypes) or in semi-transparent form (structure PRELP "HR Master Data Buffer") which can be easily converted into their corresponding transparent form (table PAnnnn).

Code:
*&---------------------------------------------------------------------*
*& Report  Z_SDN_CL_PT_EMPLOYEE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  z_sdn_cl_pt_employee.

TABLES: pa0000.

DATA:
  go_employee    TYPE REF TO cl_pt_employee,
* generic variables for retrieving infotype data
  gd_infty       TYPE infty,
  gt_infty       TYPE tim_tmw_itlist_tab,
  gt_result      TYPE tim_blp_request_tab,
  gd_result      LIKE LINE OF gt_result,
  go_data        TYPE REF TO cl_pt_td_itnnnn,
* specific infotype variables
  gs_prelp       TYPE prelp,   " HR Master Data Buffer
  gs_p0009       TYPE pa0009.  " HR Master Record: Infotype 0009 (Bank
"                               Details)

FIELD-SYMBOLS:
  <gd_fld>       TYPE ANY.

PARAMETERS:
  p_pernr        TYPE pa0000-pernr  DEFAULT '00900222',
  p_begda        TYPE begda         DEFAULT syst-datum,
  p_endda        TYPE endda         DEFAULT syst-datum.



START-OF-SELECTION.

* Create an instance of the employee
  go_employee ?= cl_pt_employee=>get_employee( p_pernr ).

* The class has a method GET_MASTER_DATA which returns several
* basic infotypes of the employee in a transparent form.
  CALL METHOD go_employee->get_master_data
    EXPORTING
      im_begda = p_begda
      im_endda = p_endda
*    IMPORTING
*      EX_I0000 =  " infotype 0000 = Actions
*      EX_I0001 =  " infotype 0001 = Organizational Assignment
*      EX_I0002 =  " infotype 0002 = Personal Data
*      EX_I0007 =  " infotype 0007 = Planned Working Time
*      EX_I0008 =  " infotype 0008 = Basic Pay
      .


* Using this method you can access any infotype(s)
  APPEND '0009' TO gt_infty.  " Bank Details
* APPEND '0010' TO gt_infty.  " Capital Formation
  CALL METHOD go_employee->if_pt_employee~get_infotypes
    EXPORTING
      i_itlist      = gt_infty
      i_fromdate    = '20000101'
      i_todate      = syst-datum
*      I_FILTER      =
      i_noauthcheck = ' '  " do authority check (if required)
    IMPORTING
      e_result      = gt_result.
*      E_RETCD       =
  .

* Method GET_INFOTYPES returns a list of infotype objects
* containing the infotype data in semi-transparent form
  LOOP AT gt_result INTO gd_result.
    go_data ?= gd_result->data.

*   Get infotype in semi-transparent form
    gs_prelp = go_data->if_pt_td_infotype~get_prelp( ).

*   Convert: semi-transparent -> transparent infotype
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
      EXPORTING
        prelp = gs_prelp
      IMPORTING
        pnnnn = gs_p0009.
  ENDLOOP.

* Print-Out infotype data
  DO.
    ASSIGN COMPONENT syst-index OF STRUCTURE gs_p0009 TO <gd_fld>.
    IF ( syst-subrc NE 0 ).
      EXIT.
    ELSE.
      WRITE: / <gd_fld>.
    ENDIF.
  ENDDO.

END-OF-SELECTION.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.