Here you will get some technical information in detail.
Here are 2 ways you can read data from an infotype.
1) You can use macros.
* IT0041 "Get Date Specifications
rp_provide_from_last p0041 space pn-begda pn-endda.
IF pnp-sw-found = 1.
gs_output-hire_date = p0041-dat02.
gs_output-grade_entry_date = p0041-dat09.
gs_output-position_entry_date = p0041-dat10.
gs_output-job_entry_date = p0041-dat11.
ELSE.
CLEAR p0041.
ENDIF.
2) You can use function module. (For example: writing code for BADI since you cannot use macro inside BADI).
* Read IT0041 for the employee.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
* TCLAS = 'A'
pernr = iv_pernr
infty = '0041'
begda = iv_keydate
endda = iv_keydate
* BYPASS_BUFFER = ' '
* LEGACY_MODE = ' '
* IMPORTING
* SUBRC =
TABLES
infty_tab = it_p0041
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
There are 2 ways you can read data from an infotype having subtype.
I am showing example of reading data from infotype IT0105 subtype 0001.
1) Use macro
* IT0105 "Get user name
rp_provide_from_last p0105 '0001' pn-begda pn-endda.
IF pnp-sw-found = 1.
gs_output-username = p0105-usrid.
ELSE.
CLEAR p0105.
ENDIF.
2) Use function module
"Read IT0105 for the employee.
CALL FUNCTION 'HR_READ_SUBTYPE'
EXPORTING
* TCLAS = 'A'
pernr = iv_pernr
infty = '0105'
subty = '0001'
begda = iv_keydate
endda = iv_keydate
* BYPASS_BUFFER = ' '
* LEGACY_MODE = ' '
* IMPORTING
* SUBRC =
TABLES
infty_tab = it_p0105
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.