‎2006 Oct 30 3:21 PM
I have a dynamic select like:
data: where_tab(50) occurs 0.
tables mara.
ranges s_matnr for mara-matnr
where_tab = 'matnr in s_matnr'.
select single * from mara where (where_tab).
and i get a dump.
Can i make a dynamic selection with the IN operator.
Thanks in advance
regards
‎2006 Oct 30 3:25 PM
‎2006 Oct 30 3:25 PM
‎2006 Oct 30 3:26 PM
‎2006 Oct 30 3:30 PM
I don´t understand the solution Rich, can you explain me a bit please what is your solution?
Thanks in advance
regards
‎2006 Oct 30 3:40 PM
Here is what I mean by a generated subroutine. You can see how you can build your select statement at runtime.
In this program, it is statically defined, but you can maniuplate the source as you need to.
report zrich_0001
no standard page heading.
types: t_source(72).
data: routine(32) value 'TEMP_ROUTINE',
program(8),
message(128),
line type i.
data: isource type table of t_source,
xsource type t_source.
data: imara type table of mara with header line.
ranges: r_matnr for imara-matnr.
start-of-selection.
r_matnr-sign = 'I'.
r_matnr-option = 'BT'.
r_matnr-low = '000000000040000100'.
r_matnr-high = '000000000040000200'.
append r_matnr.
perform build_select_statement.
generate subroutine pool isource name program
message message
line line.
if sy-subrc = 0.
perform (routine) in program (program) tables r_matnr imara.
else.
write:/ message.
endif.
loop at imara.
write:/ imara-matnr.
endloop.
*&---------------------------------------------------------------------*
*& Form build_select_statement
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_select_statement.
xsource = 'REPORT ZTEMP_REPORT.'.
append xsource to isource.
concatenate 'FORM' routine
'tables xr_matnr ximara .'
into xsource separated by space.
append xsource to isource.
xsource = 'select * into table ximara from mara'.
append xsource to isource.
xsource = 'where matnr in xr_matnr.'.
append xsource to isource.
xsource = 'ENDFORM.'.
append xsource to isource.
endform. " build_select_statement
Regards,
Rich Heilman
‎2006 Oct 30 3:42 PM
HI carl son,
Refer this link :
http://help.sap.com/saphelp_47x200/helpdata/en/9f/db996135c111d1829f0000e829fbfe/frameset.htm
Regards,
Ravi
‎2006 Oct 30 3:28 PM
hi Carlson,
try this way ..
concatenate ''' 's_matnr' ''' into str1.
condense str1 no-gaps.
concatenate 'matnr in ' str1
into where_tab separated by space.
select single * from mara where (where_tab).
Regards,
Santosh