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: 

HOW TO USE A SINGLE PERFORM FOR VARIOUS TABLES ?

Former Member
0 Kudos

perform test TABLES t_header.

select

KONH~KNUMH

konh~datab

konh~datbi

konp~kbetr

konp~konwa

konp~kpein

konp~kmein

KONP~KRECH

FROM konh INNER JOIN konp

ON konpknumh = konhknumh

into table iTABXXX

"ANY TEMPERARY INTERNAL TABLE.

for all entries in t_header

where

konh~kschl = t_header-kschl

AND konh~knumh = t_header-knumh.

endform.

how can I use above perform for various internal tables of DIFFERENT LINE TYPES but having the fields KSCHL & KNUMH.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

u can use single perform....

just see this example......hope this is what u r expecting....

tables : pa0001.

parameters : p_pernr like pa0001-pernr.

data : itab1 like pa0001 occurs 0 with header line.

data : itab2 like pa0002 occurs 0 with header line.

perform get_data tables itab1 itab2.

if not itab1[] is initial.

loop at itab1.

write 😕 itab1-pernr.

endloop.

endif.

if not itab2[] is initial.

loop at itab2.

write 😕 itab2-pernr.

endloop.

endif.

&----


*& Form get_data

&----


  • text

----


  • -->P_ITAB1 text

  • -->P_ITAB2 text

----


form get_data tables itab1 structure pa0001

itab2 structure pa0002.

select * from pa0001 into table itab1 where pernr = p_pernr and begda le sy-datum and endda ge sy-datum.

select * from pa0002 into table itab2 where pernr = p_pernr and begda le sy-datum and endda ge sy-datum.

endform. " get_data

Regards

vasu

2 REPLIES 2

Former Member
0 Kudos

u can use single perform....

just see this example......hope this is what u r expecting....

tables : pa0001.

parameters : p_pernr like pa0001-pernr.

data : itab1 like pa0001 occurs 0 with header line.

data : itab2 like pa0002 occurs 0 with header line.

perform get_data tables itab1 itab2.

if not itab1[] is initial.

loop at itab1.

write 😕 itab1-pernr.

endloop.

endif.

if not itab2[] is initial.

loop at itab2.

write 😕 itab2-pernr.

endloop.

endif.

&----


*& Form get_data

&----


  • text

----


  • -->P_ITAB1 text

  • -->P_ITAB2 text

----


form get_data tables itab1 structure pa0001

itab2 structure pa0002.

select * from pa0001 into table itab1 where pernr = p_pernr and begda le sy-datum and endda ge sy-datum.

select * from pa0002 into table itab2 where pernr = p_pernr and begda le sy-datum and endda ge sy-datum.

endform. " get_data

Regards

vasu

0 Kudos

hi vasu,

you are using the code.

if not itab1[] is initial.

loop at itab1.

write 😕 itab1-pernr.

endloop.

endif

two times.

what if i had, say 10 such tables for example ,

then i have to write the above code 10 times.

But i want to use the code,

if not itab1[] is initial.

loop at itab1.

write 😕 itab1-pernr.

endloop.

endif

only once for all the 10 tables with out repeating the same code.

but any how ,

thank you for your reply.