‎2011 Nov 27 4:27 AM
Halo ,
I am trying to build dynamic select clause for a report . I pass all the select options from the report to Class.
In class I have an attribute my_ranges (type table of ref to data).
In the method build_dynamic_clause I write
data: l_range_1 type ref to data,
l_range_2 type ref to data,
like that til l_range_10.
*now i read table my_ranges with index addition to this individual variables*
read table my_ranges assigning l_range_1 index 1
like that till 10th index.
*Now I use this individual range variables in select like*
select * from (l_table_name) where field1 in l_range->*
and field2 in l_range_2->*
Like that
.
The problem is I dont know how many select options is passed from the report . Currently the report is handling only up to 10 select options . I want to make that dynamic by declaring variables (l_range_1 to l_range_n ).
Depending on the my_ranges number of entries ,EACH variables should be declared dynamically and then we can use it in dynamic select .
Is that possible?
Regards
Kallu
‎2011 Nov 27 7:50 AM
‎2011 Nov 27 9:20 PM
Actually [this blog|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/15837] [original link is broken] [original link is broken]; (also by Horst Keller) might be more appropriate.
Cheers
Graham Robbo
‎2011 Nov 27 4:50 PM
As you pass your ranges in table like parameter, I think you don't need any dynamic ranges defined inside the class. Simply loop at your ranges and build [dynamic where condition|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_DYNAMIC.htm] by concatenating each line. Then pass it to your select clause.
Regards
Marcin
‎2011 Nov 28 4:26 AM
Halo Marcin,
Thanks for the reply . But its not that easy.
There are 400 to 500 select options in the report . I dont want to declare this many select option ranges inside the class.
Moreover I am reusing the attributes to build the selection clause.
Is there any way to declare this local variables inside the class method dynamcially( l_range_1 to l_range_n ).
Regards
Kallu
‎2011 Nov 28 5:12 AM
Hi,
You can check my reply here for creating ranges dynamically inside the program
You say that the number of ranges in the parameter is not predictable, but the fields in the select query are fixed right.
In the select query create a where clause with all fields have a range parameter. Fill the range table when an entry comes in parameter.
Ex:
select * from abc where f1 in r1 "<--if r1 is required then populate it, else leave it blank
and f2 in r2 "<--if r2 is required then populate it, else leave it blank
Still I am bit confused with your question
Kesav
‎2011 Nov 28 8:57 AM
Halo Keshav,
I dont want to declare ranges attributes(400-500) inside the class because there are so many of them which are passed to the class from the report . ie y I build up the my_ranges type ref to table of data inside the class for each select options in the report.
In a way my reqment is similar with the Indrajit in link that you gave me
The code snippet provided by you will cause the field symbol <fs> changed in each loop pass and point to a different range
The reason I need separate range names (or pointers l_range_1 to l_range_n) is because I will use the same to populate 'where' clause of a select statement that gets executed after
the loop is over. So when the select statement gets executed, all the ranges should exist in class and be declared, else dynamic select clause will be syntactically incorrect
I guess dynamic declaration of variables is not possible in ABAP
Regards
Kallu
Edited by: KALLU MANACAUD on Nov 28, 2011 9:57 AM
Moderator message : Code tags removed
Edited by: Vinod Kumar on Nov 28, 2011 4:14 PM
‎2011 Dec 01 6:17 AM
‎2011 Dec 02 8:42 AM
halo rshankar,
the answer is no where related to the question that i asked.
Takeing your own data declaration.
DATA: prog TYPE string,
mess TYPE string,
sid TYPE string.
suppose i have an itab which contains this variable names ('prog',sid','mess').
I shud be able to do something like
loop at itab into wa.
data:(the value inside wa = >prog) type string.
endloop.
Regards
Kallu
Edited by: KALLU MANACAUD on Dec 2, 2011 9:43 AM