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

Function module problem

Former Member
0 Likes
651

Hi Guy's,

Please help me presently i am working with this functionmodule : HR_RECOGNIZE_EMPLOYEE.

to get the p0002-tab results i wrote the code like this

REPORT ZEMPLOYEE_DATA.

tables : pa0002.

types : begin of ty_0002,

pernr type PERSNO,

NACHN type PAD_NACHN,

vorna type PAD_VORNA,

gbdat type GBDAT,

PERID type PERID,

end of ty_0002.

data : it_0002 type standard table of ty_0002,

wa_0002 type ty_0002.

data : it_result type standard table of p0002.

select-options : s_pernr for pa0002-pernr.

start-of-selection.

select pernr

nachn

vorna

gbdat

perid

from pa0002

into table it_0002

where pernr in s_pernr.

if sy-subrc = 0.

sort it_0002 by pernr.

endif.

loop at it_0002 into wa_0002.

CALL FUNCTION 'HR_RECOGNIZE_EMPLOYEE'

EXPORTING

vorna = wa_0002-vorna

nachn = wa_0002-nachn

gbdat = wa_0002-gbdat

perid = wa_0002-perid

  • GESCH =

EXCLUDE_PERNR = wa_0002-pernr

IMPORTING

P0002_TAB = it_result

EXCEPTIONS

NO_PERNR_FOUND = 1

LACK_OF_INPUT = 2

OTHERS = 3

.

*IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

endloop.

But every time it giving single record.

Kindly hlep me friends, based on the selection entries i nedd it_results.

Thanks and Regards,

Sai.

4 REPLIES 4
Read only

Former Member
0 Likes
597

hi,

Create one more internal table and append the records of it_result into the internal table after calling function module HR_RECOGNIZE_EMPLOYEE inside your loop statement.

Read only

gautam_totekar
Active Participant
0 Likes
597

Inside loop check for sy-subrc for error and append it to an internal table to get final table with all entries.. then clear your table.

loop at it_0002 into wa_0002.

CALL FUNCTION 'HR_RECOGNIZE_EMPLOYEE'

EXPORTING

vorna = wa_0002-vorna

nachn = wa_0002-nachn

gbdat = wa_0002-gbdat

perid = wa_0002-perid

  • GESCH =

EXCLUDE_PERNR = wa_0002-pernr

IMPORTING

P0002_TAB = it_result

EXCEPTIONS

NO_PERNR_FOUND = 1

LACK_OF_INPUT = 2

OTHERS = 3

IF sy-subrc EQ 0.

      • Append it_result to an Internal Table say ITAB

      • clear it_result[]

ENDIF.

endloop.

Read only

Former Member
0 Likes
597

Writing a Function Module inside a loop slows down the program !

Read only

Former Member
0 Likes
597

Hello,

Create one more internal table of type pa0002.

After fetching the record in it_result in fuction module, Append the record in the new internal table.

Then clear the internal table it_resultin the loop itself.

Regards