Posted: Sat Oct 06, 2007 2:00 am Post subject: Generate subroutine pool
Author: Rich Heilman
Hi again, so if you can not use the IN in a dynamic where clause you might be forced to dynamically build the entire select statement, Here is a sample program which may give you some ideas, notice that we are writing the select statement code, putting it in another program and generating the subroutine at runtime, then call this routine. I'm sure that this will help you see what you need to do.
Code:
report zrich_0003 .
tables: kna1.
types: t_source(72).
data: routine(32) value 'DYNAMIC_SELECT',
program(8),
message(128),
line type i.
data: isource type table of t_source,
xsource type t_source.
ranges:
r_kunnr for kna1-kunnr.
data: ikna1 type table of kna1.
data: xkna1 type kna1.
xsource = 'REPORT ZTEMP.'.
insert xsource into isource index 1.
xsource = 'FORM dynamic_select'.
insert xsource into isource index 2.
xsource = 'Tables r_kunnr ikna1.'.
append xsource to isource.
xsource = 'select * into table ikna1 from kna1'.
append xsource to isource.
xsource = 'where kunnr in r_kunnr.'.
append xsource to isource.
xsource = 'ENDFORM.'.
append xsource to isource.
generate subroutine pool isource name program
message message
line line.
if sy-subrc = 0.
perform (routine) in program (program) tables r_kunnr
ikna1.
else.
write:/ message.
endif.
loop at ikna1 into xkna1.
write:/ xkna1-kunnr.
endloop.
Regards,
Rich Heilman
PS: There is limit in 36 generate subroutine pool in one internal session.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.