cancel
Showing results for 
Search instead for 
Did you mean: 

Use FM - HR_READ_INFOTYPE one time but to read mulitple Info types

Former Member
0 Kudos

Dear All,

I have a select-option where in users enter the Info types Numbers.

Now I have to read and every infotype and display related data from each info type .

I have to use FM - HR_READ_INFOTYPE but we need to declare data for each and every infotype so I need to use this 10 times in case If I have 10 infotype.

Is their any generlaised way exist where in I will pass the variable e.g., P0001 and build the internal table and use it for a FM. Kindly explain.

Regards,

Mangalagi S V

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Mary,

You have declared

DATA: wa_0008 TYPE STANDARD TABLE OF p0008,

0008_line LIKE LINE OF wa_0008.

You have given the example to read IT0008 so If we need to extended for other infotpye then we need to have the above declaration for each and every info type.

My problem is I don't what info types I am going to read, it might come from some Z table OR from Select-options.

Let say we will read for IT0001, so the general way is we declare like this

data : g_t_0001 like P0001 occurs 0 with header line and the use the internal table g_t_0001 for reading IT0001. On the same ground where in the declaration should go dynamically (based on select-option/table)

for example : g_t_gen like (infotype) occurs 0 with header line.

Now my (infotype) will be from Select-option/table, for example (infotype) should be P0001/P0002 etc . Kindly suggest.

Regards,

Mangalagi S V

Former Member
0 Kudos

Yes you can.

1.) Declare fields as follows:

FIELD-SYMBOLS <it> TYPE STANDARD TABLE.

DATA l_table_name LIKE feld-name.

DATA: wa_0008 TYPE STANDARD TABLE OF p0008,

0008_line LIKE LINE OF wa_0008.

2) In Step 3 I have a form that you will need to call like this:

MOVE 'wa_0008' TO l_table_name.

ASSIGN (l_table_name) TO <it>.

PERFORM read_infotype USING pernr

'0008'

begda

endda.

wa_0008 = <it>.

3) Your form will need to look like this

FORM read_infotype USING pers_num

it_num

begin

end.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = pers_num

infty = it_num

begda = begin

endda = end

TABLES

infty_tab = <it>

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

IF sy-subrc = 1.

.......

ENDIF.

ENDFORM. " read_infotype

You can then call your form passing different infotype numbers to it.

Hope that helps.

Mary

Former Member
0 Kudos

Try to write a function module like below and then use the field symbols to move the data from four generic strings to your infotype structure........

function z_get_emp_it_data.

*"----


""Local interface:

*" IMPORTING

*" VALUE(INFTY) LIKE PRELP-INFTY

*" VALUE(BEGDA) LIKE PRELP-BEGDA DEFAULT '18000101'

*" VALUE(ENDDA) LIKE PRELP-ENDDA DEFAULT '99991231'

*" TABLES

*" PERNR_RANGE_TAB STRUCTURE PERSNO_RANGE

*" INFTY_DATA_TAB STRUCTURE PRELP

*" PERNR_NOAUTH_TAB STRUCTURE PERNRTAB

*"----


data : begin of itab_pernr occurs 0,

pernr like p0003-pernr,

end of itab_pernr.

data : v_subrc like sy-subrc.

select distinct pernr from pa0003 into table itab_pernr where

pernr in pernr_range_tab.

loop at itab_pernr.

clear v_subrc.

call function 'HR_READ_INFOTYPE'

exporting

tclas = 'A'

pernr = itab_pernr-pernr

infty = infty

begda = begda

endda = endda

bypass_buffer = ' '

importing

subrc = v_subrc

tables

infty_tab = infty_data_tab.

if v_subrc gt 0.

  • If no authority then put the PERNR in PERNR_NOAUTH_TAB table

clear pernr_noauth_tab.

pernr_noauth_tab-pernr = itab_pernr-pernr.

append pernr_noauth_tab.

continue.

endif.

endloop.

endfunction.