Uday's website
Published on Uday's website (https://uday.net)

Home > SAP HCM > Technical information

Technical information

Here you will get some technical information in detail.

  • Log in [1] to post comments

How to read data from infotype

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.

  • Log in [2] to post comments

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.

  • Log in [3] to post comments

 Valid XHTML 1.0 StrictCreative Commons LicenseVerbatim copying and redistribution of this entire page are permitted provided this notice is preserved. All content on this website including archives (including text, photographs, audio files and any other original work), unless otherwise noted, is licensed under a Creative Commons License or later.


Source URL:https://uday.net/SAP-HCM-technical

Links
[1] https://uday.net/user/login?destination=node/484%23comment-form [2] https://uday.net/user/login?destination=node/487%23comment-form [3] https://uday.net/user/login?destination=node/488%23comment-form