How to read data from subtype

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.