Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

creation of function module

Former Member
0 Likes
648

Hi,

I would like to create a FUNCTION MODULE to get the names of dependents of an employee from IT0021 by giving the pernr as an input parameter.

Any pointers on the source code would helpful.

Thanks,

1 ACCEPTED SOLUTION
Read only

former_member195383
Active Contributor
0 Likes
608

its quite simple..cretae an FM with import parameter as im_pernr. u can use a table tb_details(in Tables Tab) to collate the details. In the source code of the FM fire a select query to fetch all the reqd details from IT0021.

4 REPLIES 4
Read only

Former Member
0 Likes
608

HI

You can directly use HR_Read_INFOTYPE for this purpose.

Infotype 0021 stores family details of an employee so you can get info of dependents from it.

function hr_read_infotype.

IMPORTING

VALUE(TCLAS) TYPE PSPAR-TCLAS DEFAULT 'A'

VALUE(PERNR) TYPE PRELP-PERNR ---> put pernr

VALUE(INFTY) TYPE PRELP-INFTY ---> '0021'

VALUE(BEGDA) TYPE PRELP-BEGDA DEFAULT '18000101'

VALUE(ENDDA) TYPE PRELP-ENDDA DEFAULT '99991231'

REFERENCE(BYPASS_BUFFER) TYPE FLAG DEFAULT ' '

REFERENCE(LEGACY_MODE) TYPE BOOLE_D DEFAULT SPACE

EXPORTING

VALUE(SUBRC) TYPE SY-SUBRC

TABLES

INFTY_TAB --> itab compatible to PA0021

EXCEPTIONS

INFTY_NOT_FOUND

Read only

former_member195383
Active Contributor
0 Likes
609

its quite simple..cretae an FM with import parameter as im_pernr. u can use a table tb_details(in Tables Tab) to collate the details. In the source code of the FM fire a select query to fetch all the reqd details from IT0021.

Read only

Former Member
0 Likes
608

Hi narender,

Actually you already have a standard Function Module HR_READ_INFOTYPE which can fetch you the right information..

You do not need to create a new one.

Example

CALL FUNCTION 'HR_READ_INFOTYPE'
      EXPORTING
        pernr           = fs_pa00-pernr
        infty           = '0041'
        begda           = fs_pa0000-begda
        endda           = fs_pa0000-endda
        bypass_buffer   = 'X'
      TABLES
        infty_tab       = t_pa0041
      EXCEPTIONS
        infty_not_found = 1
        OTHERS          = 2.

    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.                             " IF SY-SUBRC NE 0.

Best of luck,

Bhumika

Read only

Former Member
0 Likes
608

Hi,

Check HR_ESS_EMPSALARYDETAIL_10 to solve your query

check this table for employee salary details.

PA0008 - HR Master Record: Infotype 0008 (Basic Pay)

1. There is no ONE fm which will retrieve ALL infotypes data

with all fields in one shot.

2. The reason is that all infotypes have different fields.

3. To do this, u may have to call this FM

more than once , (for each infotype - one time)

and get the data in different structures/itabs P0001, P0002, P0006 etc.

Thanks.

Ashok