Application Development 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: 

rp_provide_from_last dynamic table

0 Kudos
308

Hi,

I have a report which uses logical database PNPCE to fetch employee data and macros like rp_provide_from_last to read infotypes.

INFOTYPES: 0001 name gtab1,

002 name gtab2.

rp_provide_from_last gtab1 space pn-begda pn-endda

rp_provide_from_last gtab2 space pn-begda pn-endda.

I want to use a dynamic fieldname instead of gtab1 / gtab2. Basically i want to use this above macro statement to check if the infotype exists for a employee. So if there are 50 infotypes to be checked, i donot want to write this macro 50 times with 50 tables, is there a way to use a dynamic table name in the macro statement ?

Thanks

Subha

1 REPLY 1

Former Member
0 Kudos
95

Your requirement can be met by modelling the program based on the below source code. This program will list all infotypes that have been maintained for a PERNR. This proram excludes certain infotypes like PD infotypes. The source code can be changed to include all desired infotypes.

&----


*& Report ZTEST_CHECK_INFY

*&

&----


*&

*&

&----


REPORT ZTEST_CHECK_INFY.

tables: t777d.

DATA SUBRC LIKE SY-SUBRC.

DATA PAR1 LIKE SY-MSGV1.

DATA: BEGIN OF SELTAB OCCURS 5.

INCLUDE STRUCTURE PRELP AS prelp. "UC

DATA: OPERA(1).

DATA: END OF SELTAB.

data: it_777d like t777d occurs 0.

data: wa_777d type t777d.

data: ls_index(4) type n.

select-options: so_infty for t777d-infty.

select-options: so_inft1 for t777d-infty no intervals.

Initialization.

so_infty-sign = 'I'.

so_infty-option = 'BT'.

so_infty-low = '0000'.

so_infty-high = '9999'.

append so_infty.

select * from t777d into corresponding fields of table it_777d where infty in so_infty.

loop at it_777d into wa_777d.

so_inft1-sign = 'I'.

so_inft1-option = 'EQ'.

so_inft1-low = wa_777d-infty.

append so_inft1.

endloop.

start-of-selection.

CALL FUNCTION 'HR_INITIALIZE_BUFFER'

EXPORTING

TCLAS = 'A'

PERNR = '40101017'

EXCEPTIONS

OTHERS = 1.

Loop at so_inft1 where not low between '1000' and '8999'.

REFRESH SELTAB.

CLEAR SELTAB.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

TCLAS = 'A'

PERNR = '40101017'

INFTY = so_INFT1-low

BEGDA = '19000101'

ENDDA = '99991231'

IMPORTING

SUBRC = SUBRC

TABLES

INFTY_TAB = SELTAB

EXCEPTIONS

INFTY_NOT_FOUND = 1

OTHERS = 2.

if subrc eq 0.

write:/ so_inft1-low, 'has been maintained for employee: ', '40101017'.

endif.

endloop.