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).
*&---------------------------------------------------------------------*
*& 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:
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
IF ( syst-subrc NE 0 ).
EXIT.
ELSE.
WRITE: /
ENDIF.
ENDDO.
END-OF-SELECTION.
Other HR Links :
Processing 'Time Data'.
HR ABAP Logical Database
Processing Payroll infotypes/Cluster
Download HR Infotypes tutorial
ABAP,ABAP report,Interactive Report,ALV grid,ALV list,IDOC,User Exit,RFC,Smartform,sapscript,ABAP Performance,Remote Function Module( RFC ),Function Module,Modularization techniques,ABAP tools,ALV report Generator,ABAP Interview Questions,BDC,BAPI,ALE,BADI, EDI,InternalTable,DataStructure,LSMW,Domain,DataElement,Basis and Administration ,ABAP HR development,ABAP Debugger,BW,ExceptionHandling,Download FI, CO, MM, PP, SD, PM, PS, QM, SM, HR, BW, APO,ABAP Tutorial
Wednesday, June 20, 2007
Unified Access to All HR Infotypes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment